1010import liquidjava .rj_language .ast .LiteralReal ;
1111import liquidjava .rj_language .ast .Var ;
1212
13- public class VariableExtractor {
13+ public class VariableCollector {
1414
15- public static Map <String , Expression > extract (Expression exp ) {
15+ public static Map <String , Expression > collect (Expression exp ) {
1616 Map <String , Expression > assertions = new HashMap <>();
1717
1818 // only extract assertions if the expression contains conjunctions (&&)
1919 if (containsConjunction (exp )) {
20- extractRecursive (exp , assertions );
20+ collectRecursive (exp , assertions );
2121 }
2222 return assertions ;
2323 }
@@ -41,20 +41,19 @@ private static boolean containsConjunction(Expression exp) {
4141 return false ;
4242 }
4343
44- private static void extractRecursive (Expression exp , Map <String , Expression > assertions ) {
44+ private static void collectRecursive (Expression exp , Map <String , Expression > assertions ) {
4545 if (exp instanceof BinaryExpression ) {
4646 BinaryExpression binExp = (BinaryExpression ) exp ;
4747 String operator = binExp .getOperator ();
4848
4949 if (operator .equals ("&&" )) {
5050 // for conjunctions recursively extract from both sides
51- extractRecursive (binExp .getFirstOperand (), assertions );
52- extractRecursive (binExp .getSecondOperand (), assertions );
51+ collectRecursive (binExp .getFirstOperand (), assertions );
52+ collectRecursive (binExp .getSecondOperand (), assertions );
5353 } else if (operator .equals ("==" )) {
5454 // for assertions check if one side is a variable and the other is a literal
5555 Expression left = binExp .getFirstOperand ();
5656 Expression right = binExp .getSecondOperand ();
57-
5857 if (left instanceof Var && isLiteral (right )) {
5958 assertions .put (((Var ) left ).getName (), right );
6059 } else if (right instanceof Var && isLiteral (left )) {
@@ -65,7 +64,7 @@ private static void extractRecursive(Expression exp, Map<String, Expression> ass
6564 // for other expressions, recurse into children
6665 else if (exp .hasChildren ()) {
6766 for (Expression child : exp .getChildren ()) {
68- extractRecursive (child , assertions );
67+ collectRecursive (child , assertions );
6968 }
7069 }
7170 }
0 commit comments