Skip to content

Commit 659bf69

Browse files
d367wangtxiang61
andauthored
Get arithmetic operation kind for compound assignments (#388)
Co-authored-by: Jenny Xiang <[email protected]>
1 parent 8a29a0e commit 659bf69

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/checkers/inference/model/ArithmeticConstraint.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,46 @@ private ArithmeticOperationKind(String opSymbol) {
3333
this.opSymbol = opSymbol;
3434
}
3535

36+
/**
37+
* Get the {@link ArithmeticOperationKind} corresponding to a {@link Tree.Kind}. For a compound
38+
* assignment tree, get the {@link ArithmeticOperationKind} for the arithmetic operation of the RHS.
39+
* @param kind a {@link Tree.Kind} for an arithmetic operation
40+
* @return the corresponding {@link ArithmeticOperationKind} for the given arithmetic operation
41+
*/
3642
public static ArithmeticOperationKind fromTreeKind(Kind kind) {
3743
switch (kind) {
3844
case PLUS:
45+
case PLUS_ASSIGNMENT:
3946
return PLUS;
4047
case MINUS:
48+
case MINUS_ASSIGNMENT:
4149
return MINUS;
4250
case MULTIPLY:
51+
case MULTIPLY_ASSIGNMENT:
4352
return MULTIPLY;
4453
case DIVIDE:
54+
case DIVIDE_ASSIGNMENT:
4555
return DIVIDE;
4656
case REMAINDER:
57+
case REMAINDER_ASSIGNMENT:
4758
return REMAINDER;
4859
case LEFT_SHIFT:
60+
case LEFT_SHIFT_ASSIGNMENT:
4961
return LEFT_SHIFT;
5062
case RIGHT_SHIFT:
63+
case RIGHT_SHIFT_ASSIGNMENT:
5164
return RIGHT_SHIFT;
5265
case UNSIGNED_RIGHT_SHIFT:
66+
case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
5367
return UNSIGNED_RIGHT_SHIFT;
5468
case AND:
69+
case AND_ASSIGNMENT:
5570
return AND;
5671
case OR:
72+
case OR_ASSIGNMENT:
5773
return OR;
5874
case XOR:
75+
case XOR_ASSIGNMENT:
5976
return XOR;
6077
default:
6178
throw new BugInCF("There are no defined ArithmeticOperationKinds "

0 commit comments

Comments
 (0)