Skip to content

Commit

Permalink
Get arithmetic operation kind for compound assignments (#388)
Browse files Browse the repository at this point in the history
Co-authored-by: Jenny Xiang <j.tt.xiang@gmail.com>
  • Loading branch information
d367wang and txiang61 authored Mar 7, 2022
1 parent 8a29a0e commit 659bf69
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/checkers/inference/model/ArithmeticConstraint.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,46 @@ private ArithmeticOperationKind(String opSymbol) {
this.opSymbol = opSymbol;
}

/**
* Get the {@link ArithmeticOperationKind} corresponding to a {@link Tree.Kind}. For a compound
* assignment tree, get the {@link ArithmeticOperationKind} for the arithmetic operation of the RHS.
* @param kind a {@link Tree.Kind} for an arithmetic operation
* @return the corresponding {@link ArithmeticOperationKind} for the given arithmetic operation
*/
public static ArithmeticOperationKind fromTreeKind(Kind kind) {
switch (kind) {
case PLUS:
case PLUS_ASSIGNMENT:
return PLUS;
case MINUS:
case MINUS_ASSIGNMENT:
return MINUS;
case MULTIPLY:
case MULTIPLY_ASSIGNMENT:
return MULTIPLY;
case DIVIDE:
case DIVIDE_ASSIGNMENT:
return DIVIDE;
case REMAINDER:
case REMAINDER_ASSIGNMENT:
return REMAINDER;
case LEFT_SHIFT:
case LEFT_SHIFT_ASSIGNMENT:
return LEFT_SHIFT;
case RIGHT_SHIFT:
case RIGHT_SHIFT_ASSIGNMENT:
return RIGHT_SHIFT;
case UNSIGNED_RIGHT_SHIFT:
case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
return UNSIGNED_RIGHT_SHIFT;
case AND:
case AND_ASSIGNMENT:
return AND;
case OR:
case OR_ASSIGNMENT:
return OR;
case XOR:
case XOR_ASSIGNMENT:
return XOR;
default:
throw new BugInCF("There are no defined ArithmeticOperationKinds "
Expand Down

0 comments on commit 659bf69

Please sign in to comment.