|
@@ -405,32 +405,20 @@ and gen_expr ctx e =
|
|
in
|
|
in
|
|
(match get_locals e with [] -> eg | el -> EBlock [(EVars(el),p);eg],p)
|
|
(match get_locals e with [] -> eg | el -> EBlock [(EVars(el),p);eg],p)
|
|
| DTSwitch (e,cl) ->
|
|
| DTSwitch (e,cl) ->
|
|
- let est = gen_expr ctx e in
|
|
|
|
- let e = match follow e.etype with
|
|
|
|
- | TEnum(_) | TAbstract({a_this = TEnum(_)},_) -> field p est "index"
|
|
|
|
- | TInst({cl_path = [],"Array"},[t]) -> field p est "length"
|
|
|
|
- | _ -> est;
|
|
|
|
- in
|
|
|
|
|
|
+ let e = gen_expr ctx e in
|
|
let def = ref None in
|
|
let def = ref None in
|
|
- let pnull = ref None in
|
|
|
|
let cases = ExtList.List.filter_map (fun (e,dt) ->
|
|
let cases = ExtList.List.filter_map (fun (e,dt) ->
|
|
match e.eexpr with
|
|
match e.eexpr with
|
|
| TMeta((Meta.MatchAny,_,_),_) ->
|
|
| TMeta((Meta.MatchAny,_,_),_) ->
|
|
def := Some (loop dt);
|
|
def := Some (loop dt);
|
|
None
|
|
None
|
|
- | TConst (TNull) ->
|
|
|
|
- pnull := Some (loop dt);
|
|
|
|
- None;
|
|
|
|
| _ ->
|
|
| _ ->
|
|
Some (gen_expr ctx e,loop dt)
|
|
Some (gen_expr ctx e,loop dt)
|
|
) cl in
|
|
) cl in
|
|
- let e = EBlock [
|
|
|
|
|
|
+ EBlock [
|
|
(ESwitch (e,cases,!def),p);
|
|
(ESwitch (e,cases,!def),p);
|
|
goto num_labels;
|
|
goto num_labels;
|
|
- ],p in
|
|
|
|
- match !pnull with
|
|
|
|
- | None -> e
|
|
|
|
- | Some enull -> (EIf((EBinop ("==",est,null p),p),enull,Some e)),p
|
|
|
|
|
|
+ ],p
|
|
in
|
|
in
|
|
let acc = DynArray.create () in
|
|
let acc = DynArray.create () in
|
|
for i = num_labels -1 downto 0 do
|
|
for i = num_labels -1 downto 0 do
|