From 659bf69e6d448ab4143fd3788fe3cc8f41e0a24b Mon Sep 17 00:00:00 2001 From: d367wang <55197967+d367wang@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:20:02 -0500 Subject: [PATCH] Get arithmetic operation kind for compound assignments (#388) Co-authored-by: Jenny Xiang --- .../inference/model/ArithmeticConstraint.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/checkers/inference/model/ArithmeticConstraint.java b/src/checkers/inference/model/ArithmeticConstraint.java index 83074a7e..85992820 100644 --- a/src/checkers/inference/model/ArithmeticConstraint.java +++ b/src/checkers/inference/model/ArithmeticConstraint.java @@ -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 "