File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,10 @@ static const Expr* mul( const Expr* x, const Expr* y ) {
96
96
return new ValExpr (((ValExpr*)x)->value * ((ValExpr*)y)->value );
97
97
}
98
98
else if (x->kind ==Val && ((ValExpr*)x)->value ==0 ) {
99
- return x ;
99
+ return new ValExpr ( 0 ) ;
100
100
}
101
101
else if (y->kind ==Val && ((ValExpr*)y)->value ==0 ) {
102
- return y ;
102
+ return new ValExpr ( 0 ) ;
103
103
}
104
104
else if (x->kind ==Val && ((ValExpr*)x)->value ==1 ) {
105
105
return y;
Original file line number Diff line number Diff line change @@ -93,10 +93,10 @@ static Expr mul( Expr x, Expr y ) {
93
93
return new ValExpr ( a .value * b .value );
94
94
}
95
95
else if (x instanceof ValExpr a && a .value == 0 ) {
96
- return x ;
96
+ return new ValExpr ( 0 ) ;
97
97
}
98
98
else if (y instanceof ValExpr b && b .value == 0 ) {
99
- return y ;
99
+ return new ValExpr ( 0 ) ;
100
100
}
101
101
else if (x instanceof ValExpr a && a .value == 1 ) {
102
102
return y ;
@@ -110,7 +110,7 @@ else if (y instanceof ValExpr b) {
110
110
else if (x instanceof ValExpr a && y instanceof MulExpr b && b .left instanceof ValExpr bl ) {
111
111
return mul (new ValExpr (a .value * bl .value ), b .right );
112
112
}
113
- else if (y instanceof MulExpr b && b .left instanceof MulExpr ) {
113
+ else if (y instanceof MulExpr b && b .left instanceof ValExpr ) {
114
114
return mul (b .left , mul (x ,b .right ));
115
115
}
116
116
else if (x instanceof MulExpr a ) {
You can’t perform that action at this time.
0 commit comments