|
|
@@ -134,10 +134,18 @@ let eval node =
|
|
|
| Binop (Mul, other, Const (IntVal 1l, _), _) ->
|
|
|
other
|
|
|
|
|
|
- (* true|false ? texp : fexp --> texp|fexp*)
|
|
|
+ (* true|false ? texp : fexp --> texp|fexp *)
|
|
|
| Cond (Const (BoolVal value, _), texp, fexp, _) ->
|
|
|
if value then texp else fexp
|
|
|
|
|
|
+ (* cond ? true : false --> cond *)
|
|
|
+ | Cond (cond, Const (BoolVal true, _), Const (BoolVal false, _), _) ->
|
|
|
+ cond
|
|
|
+
|
|
|
+ (* cond ? false : true --> !cond *)
|
|
|
+ | Cond (cond, Const (BoolVal false, _), Const (BoolVal true, _), ann) ->
|
|
|
+ Monop (Not, cond, ann)
|
|
|
+
|
|
|
| node -> node
|
|
|
|
|
|
let rec propagate consts node =
|