@@ -23,8 +23,6 @@ public boolean apply(){
23
23
@ Override
24
24
protected void buildVisitor () {
25
25
setDefaultVisit (this ::setDefaultVisit );
26
- addVisit ("Cycle" , this ::checkCycleCondition );
27
- addVisit ("Condition" , this ::checkIfElseCondition );
28
26
addVisit ("ParenthesesExpr" , this ::computeParenthesesExprResult );
29
27
addVisit ("NegationExpr" , this ::negateBooleanExpr );
30
28
addVisit ("ArithmeticExpr" , this ::computeArithmeticExprResult );
@@ -39,46 +37,6 @@ private Void setDefaultVisit(JmmNode jmmNode, Void unused) {
39
37
return null ;
40
38
}
41
39
42
- private Void checkIfElseCondition (JmmNode jmmNode , Void unused ) {
43
- JmmNode conditionNode = jmmNode .getJmmChild (0 );
44
- JmmNode ifCode = jmmNode .getJmmChild (1 );
45
- JmmNode elseCode = jmmNode .getJmmChild (2 );
46
- visit (conditionNode );
47
-
48
- if (conditionNode .getKind ().equals ("Boolean" )) {
49
- // if condition value is true, the code inside the 'ifCode' is executed
50
- // else, the code inside the 'elseCode' is executed.
51
- JmmNode reachedCode = conditionNode .get ("value" ).equals ("true" ) ? ifCode : elseCode ;
52
- replaceIfElseWithReachedCode (jmmNode , reachedCode );
53
-
54
- for (JmmNode child : reachedCode .getChildren ())
55
- visit (child );
56
- this .codeModified = true ;
57
- }
58
-
59
- //condition value is undefined
60
- else {
61
- visit (ifCode );
62
- visit (elseCode );
63
- }
64
- return null ;
65
- }
66
-
67
- private Void checkCycleCondition (JmmNode jmmNode , Void unused ) {
68
- JmmNode conditionNode = jmmNode .getJmmChild (0 );
69
- visit (conditionNode );
70
-
71
- if (conditionNode .getKind ().equals ("Boolean" ) && conditionNode .get ("value" ).equals ("false" )) { //Dead code
72
- jmmNode .delete ();
73
- this .codeModified = true ;
74
- }
75
- else { //Condition value is 'true' or undefined
76
- for (JmmNode child : jmmNode .getChildren ())
77
- visit (child );
78
- }
79
- return null ;
80
- }
81
-
82
40
private Void computeParenthesesExprResult (JmmNode jmmNode , Void unused ) {
83
41
JmmNode exprNode = jmmNode .getJmmChild (0 );
84
42
visit (exprNode );
0 commit comments