Representation of invocation statement, e.g., r = o.m(...) or o.m(...).
| 37 | * Representation of invocation statement, e.g., r = o.m(...) or o.m(...). |
| 38 | */ |
| 39 | public class Invoke extends DefinitionStmt<Var, InvokeExp> |
| 40 | implements Comparable<Invoke> { |
| 41 | |
| 42 | /** |
| 43 | * The variable receiving the result of the invocation. This field |
| 44 | * is null if no variable receives the invocation result, e.g., o.m(...). |
| 45 | */ |
| 46 | @Nullable |
| 47 | private final Var result; |
| 48 | |
| 49 | /** |
| 50 | * The invocation expression. |
| 51 | */ |
| 52 | private final InvokeExp invokeExp; |
| 53 | |
| 54 | /** |
| 55 | * The method containing this statement. |
| 56 | */ |
| 57 | private final JMethod container; |
| 58 | |
| 59 | public Invoke(JMethod container, InvokeExp invokeExp, @Nullable Var result) { |
| 60 | this.invokeExp = invokeExp; |
| 61 | this.result = result; |
| 62 | if (invokeExp instanceof InvokeInstanceExp) { |
| 63 | Var base = ((InvokeInstanceExp) invokeExp).getBase(); |
| 64 | base.addInvoke(this); |
| 65 | } |
| 66 | this.container = container; |
| 67 | } |
| 68 | |
| 69 | public Invoke(JMethod container, InvokeExp invokeExp) { |
| 70 | this(container, invokeExp, null); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | @Nullable |
| 75 | public Var getLValue() { |
| 76 | return result; |
| 77 | } |
| 78 | |
| 79 | @Nullable |
| 80 | public Var getResult() { |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public InvokeExp getRValue() { |
| 86 | return invokeExp; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @return the invocation expression of this invoke. |
| 91 | * @see InvokeExp |
| 92 | */ |
| 93 | public InvokeExp getInvokeExp() { |
| 94 | return invokeExp; |
| 95 | } |
| 96 |
nothing calls this directly
no test coverage detected