Strip switches on variants with only catch-all
This commit is contained in:
parent
2be3c9194d
commit
6380e04a97
@ -1480,11 +1480,15 @@ block(Blk = #blk{code = [{switch, Arg, Type, Alts, Default} | Code],
|
|||||||
_ -> {Blk#blk{code = Pop ++ AltCode ++ [{jump, RestRef}]}, [], []}
|
_ -> {Blk#blk{code = Pop ++ AltCode ++ [{jump, RestRef}]}, [], []}
|
||||||
end;
|
end;
|
||||||
{variant, _Ar} ->
|
{variant, _Ar} ->
|
||||||
MkBlk = fun(missing) -> {DefRef, []};
|
case lists:usort(Alts) == [missing] of
|
||||||
(ACode) -> FreshBlk(ACode ++ [{jump, RestRef}], DefRef)
|
true -> {Blk#blk{code = Pop ++ [{jump, DefRef}]}, [], []};
|
||||||
end,
|
false ->
|
||||||
{AltRefs, AltBs} = lists:unzip(lists:map(MkBlk, Alts)),
|
MkBlk = fun(missing) -> {DefRef, []};
|
||||||
{Blk#blk{code = []}, [{switch, Arg, AltRefs}], lists:append(AltBs)}
|
(ACode) -> FreshBlk(ACode ++ [{jump, RestRef}], DefRef)
|
||||||
|
end,
|
||||||
|
{AltRefs, AltBs} = lists:unzip(lists:map(MkBlk, Alts)),
|
||||||
|
{Blk#blk{code = []}, [{switch, Arg, AltRefs}], lists:append(AltBs)}
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
Blk2 = Blk1#blk{catchall = DefRef}, %% Update catchall ref
|
Blk2 = Blk1#blk{catchall = DefRef}, %% Update catchall ref
|
||||||
block(Blk2, Code1 ++ Acc, DefBlk ++ RestBlk ++ AltBlks ++ Blocks, BlockAcc);
|
block(Blk2, Code1 ++ Acc, DefBlk ++ RestBlk ++ AltBlks ++ Blocks, BlockAcc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user