Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getParameterCount for methodSignature #1131

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions sootup.core/src/main/java/sootup/core/model/SootMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
public class SootMethod extends SootClassMember<MethodSignature> implements Method {

@Nonnull private final ImmutableSet<MethodModifier> modifiers;
/**
* An array of parameter types taken by this <code>SootMethod</code> object, in declaration order.
*/
@Nonnull protected final ImmutableList<Type> parameterTypes;

/** Declared exceptions thrown by this method. Created upon demand. */
@Nonnull protected final ImmutableList<ClassType> exceptions;
Expand All @@ -79,7 +75,6 @@ public SootMethod(
super(methodSignature, position);

this.bodySource = source;
this.parameterTypes = ImmutableUtils.immutableListOf(methodSignature.getParameterTypes());
this.modifiers = ImmutableUtils.immutableEnumSetOf(modifiers);
this.exceptions = ImmutableUtils.immutableListOf(thrownExceptions);
}
Expand Down Expand Up @@ -154,19 +149,32 @@ public Type getReturnType() {

/** Returns the number of parameters taken by this method. */
public int getParameterCount() {
return parameterTypes.size();
return getSignature().getParameterCount();
}

/** Gets the type of the <i>n</i>th parameter of this method. */
@Nonnull
public Type getParameterType(int n) {
return parameterTypes.get(n);
return getSignature().getParameterType(n);
}

@Nonnull
public MethodSubSignature getSubSignature() {
return getSignature().getSubSignature();
}

/** Returns a read-only list of the parameter types of this method. */
@Nonnull
public List<Type> getParameterTypes() {
return parameterTypes;
return getSignature().getParameterTypes();
}

@Nonnull
public ClassType getDeclClassType() {
return getSignature().getDeclClassType();
}

@Nonnull
public String getName() {
return getSignature().getName();
}

@Nonnull private final Supplier<Body> _lazyBody = Suppliers.memoize(this::lazyBodyInitializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ public MethodSignature(
public List<Type> getParameterTypes() {
return this.getSubSignature().getParameterTypes();
}

/** Returns the number of parameters. */
public int getParameterCount() {
return this.getSubSignature().getParameterTypes().size();
}

@Nonnull
public Type getParameterType(int n) {
return getParameterTypes().get(n);
}
}
Loading