Provides common functionalities for BinaryExp implementations.
| 31 | * Provides common functionalities for {@link BinaryExp} implementations. |
| 32 | */ |
| 33 | abstract class AbstractBinaryExp implements BinaryExp { |
| 34 | |
| 35 | protected final Var operand1; |
| 36 | |
| 37 | protected final Var operand2; |
| 38 | |
| 39 | protected AbstractBinaryExp(Var operand1, Var operand2) { |
| 40 | this.operand1 = operand1; |
| 41 | this.operand2 = operand2; |
| 42 | validate(); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Validates type correctness of the two values of this expression. |
| 47 | */ |
| 48 | protected void validate() { |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Var getOperand1() { |
| 53 | return operand1; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public Var getOperand2() { |
| 58 | return operand2; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public Set<RValue> getUses() { |
| 63 | Set<RValue> uses = new ArraySet<>(2); |
| 64 | Collections.addAll(uses, operand1, operand2); |
| 65 | return uses; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public String toString() { |
| 70 | return operand1 + " " + getOperator() + " " + operand2; |
| 71 | } |
| 72 | } |
nothing calls this directly
no outgoing calls
no test coverage detected