Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get arithmetic operation kind for compound assignments #388

Merged
merged 4 commits into from
Mar 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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