Sophia FATE backend overhaul #671

Merged
zxq9 merged 28 commits from fate-optimization-fixes into lima 2019-11-25 19:29:35 +09:00
Showing only changes of commit 6380e04a97 - Show all commits

View File

@ -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);