Representation of method invocation expression.
| 34 | * Representation of method invocation expression. |
| 35 | */ |
| 36 | public abstract class InvokeExp implements RValue { |
| 37 | |
| 38 | /** |
| 39 | * The method reference at the invocation. |
| 40 | */ |
| 41 | protected final MethodRef methodRef; |
| 42 | |
| 43 | /** |
| 44 | * The arguments of the invocation. |
| 45 | */ |
| 46 | protected final List<Var> args; |
| 47 | |
| 48 | protected InvokeExp(MethodRef methodRef, List<Var> args) { |
| 49 | this.methodRef = methodRef; |
| 50 | this.args = List.copyOf(args); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public Type getType() { |
| 55 | return methodRef.getReturnType(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @return the method reference at the invocation. |
| 60 | */ |
| 61 | public MethodRef getMethodRef() { |
| 62 | return methodRef; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return the number of the arguments of the invocation. |
| 67 | */ |
| 68 | public int getArgCount() { |
| 69 | return args.size(); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @return the i-th argument of the invocation. |
| 74 | * @throws IndexOutOfBoundsException if the index is out of range |
| 75 | * (index < 0 || index ≥ getArgCount()) |
| 76 | */ |
| 77 | public Var getArg(int i) { |
| 78 | return args.get(i); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return a list of arguments of the invocation. |
| 83 | */ |
| 84 | public List<Var> getArgs() { |
| 85 | return args; |
| 86 | } |
| 87 | |
| 88 | public abstract String getInvokeString(); |
| 89 | |
| 90 | public String getArgsString() { |
| 91 | return "(" + args.stream() |
| 92 | .map(Var::toString) |
| 93 | .collect(Collectors.joining(", ")) + ")"; |
nothing calls this directly
no outgoing calls
no test coverage detected