|
|
@@ -162,14 +162,13 @@ let rec prune_vardecs consts = function
|
|
|
| VarDec (ctype, name, init, ann) when Hashtbl.mem consts name -> DummyNode
|
|
|
| node -> transform_children (prune_vardecs consts) node
|
|
|
|
|
|
-let rec phase input =
|
|
|
- log_line 1 "- Constant propagation";
|
|
|
- match input with
|
|
|
- | Ast node ->
|
|
|
- if args.optimize then
|
|
|
+let phase = function
|
|
|
+ | Ast node as input ->
|
|
|
+ if args.optimize then (
|
|
|
+ log_line 1 "- Constant propagation";
|
|
|
let consts = Hashtbl.create 32 in
|
|
|
let node = propagate consts node in
|
|
|
Ast (prune_vardecs consts node)
|
|
|
- else
|
|
|
+ ) else
|
|
|
input
|
|
|
| _ -> raise (InvalidInput "constant propagation")
|