|
@@ -1147,10 +1147,14 @@ module ConstPropagation = struct
|
|
e
|
|
e
|
|
end
|
|
end
|
|
| _ ->
|
|
| _ ->
|
|
- e
|
|
|
|
|
|
+ try
|
|
|
|
+ let ct = awkward_get_enum_index2 ssa e in
|
|
|
|
+ {e with eexpr = TConst ct}
|
|
|
|
+ with Not_found ->
|
|
|
|
+ e
|
|
|
|
|
|
(* TODO: the name is quite accurate *)
|
|
(* TODO: the name is quite accurate *)
|
|
- let awkward_get_enum_index ssa e =
|
|
|
|
|
|
+ and awkward_get_enum_index2 ssa e =
|
|
let e = awkward_get_enum_index ssa.com e in
|
|
let e = awkward_get_enum_index ssa.com e in
|
|
let ev = (value ssa true e) in
|
|
let ev = (value ssa true e) in
|
|
match ev.eexpr with
|
|
match ev.eexpr with
|
|
@@ -1251,7 +1255,7 @@ module ConstPropagation = struct
|
|
let rec check_constant e = match e.eexpr with
|
|
let rec check_constant e = match e.eexpr with
|
|
| TConst ct -> ct
|
|
| TConst ct -> ct
|
|
| TParenthesis e1 | TCast(e1,None) | TMeta(_,e1) -> check_constant e1
|
|
| TParenthesis e1 | TCast(e1,None) | TMeta(_,e1) -> check_constant e1
|
|
- | _ -> awkward_get_enum_index ssa e
|
|
|
|
|
|
+ | _ -> raise Not_found
|
|
in
|
|
in
|
|
begin try
|
|
begin try
|
|
let ct = check_constant e1 in
|
|
let ct = check_constant e1 in
|
|
@@ -1272,7 +1276,11 @@ module ConstPropagation = struct
|
|
{e with eexpr = TSwitch(e1,cases,edef)}
|
|
{e with eexpr = TSwitch(e1,cases,edef)}
|
|
end
|
|
end
|
|
| _ ->
|
|
| _ ->
|
|
- Type.map_expr loop e
|
|
|
|
|
|
+ try
|
|
|
|
+ let ct = awkward_get_enum_index2 ssa e in
|
|
|
|
+ {e with eexpr = TConst ct}
|
|
|
|
+ with Not_found ->
|
|
|
|
+ Type.map_expr loop e
|
|
in
|
|
in
|
|
loop e
|
|
loop e
|
|
end
|
|
end
|