This commit is contained in:
radrow 2022-07-03 17:27:21 +02:00
parent 85c14c512b
commit 5c14fc3fe6

View File

@ -376,14 +376,15 @@ to_scode1(Env, {loop, Init, It, Expr}) ->
ContRef = make_ref(), ContRef = make_ref(),
BreakRef = make_ref(), BreakRef = make_ref(),
{ItV, Env1} = bind_local(It, Env), {ItV, Env1} = bind_local(It, Env),
InitS = to_scode(notail(Env), Init) ++ [{jump, ContRef}], InitS = [to_scode(notail(Env), Init),
{jump, ContRef}],
ExprS = [aeb_fate_ops:store({var, ItV}, {stack, 0}), ExprS = [aeb_fate_ops:store({var, ItV}, {stack, 0}),
to_scode(bind_loop(ContRef, BreakRef, ItV, Env1), Expr), to_scode(bind_loop(ContRef, BreakRef, ItV, Env1), Expr),
{jump, BreakRef}], {jump, BreakRef}],
[{loop, InitS, It, ExprS, ContRef, BreakRef}]; [{loop, InitS, It, ExprS, ContRef, BreakRef}];
to_scode1(Env = #env{cont_ref = ContRef}, {continue, Expr}) -> to_scode1(Env = #env{cont_ref = ContRef}, {continue, Expr}) ->
ExprS = to_scode1(notail(Env), Expr), [to_scode1(notail(Env), Expr),
ExprS ++ [{jump, ContRef}]; {jump, ContRef}];
to_scode1(Env, {break, Expr}) -> to_scode1(Env, {break, Expr}) ->
to_scode1(Env, Expr); to_scode1(Env, Expr);
to_scode1(Env, {switch, Case}) -> to_scode1(Env, {switch, Case}) ->
@ -1727,7 +1728,6 @@ reorder_blocks(Ref, Code, Blocks, Acc) ->
[{'EXIT', _}|_] -> reorder_blocks(Blocks, Acc1); [{'EXIT', _}|_] -> reorder_blocks(Blocks, Acc1);
[{'ABORT', _}|_] -> reorder_blocks(Blocks, Acc1); [{'ABORT', _}|_] -> reorder_blocks(Blocks, Acc1);
[{switch, _, _}|_] -> reorder_blocks(Blocks, Acc1); [{switch, _, _}|_] -> reorder_blocks(Blocks, Acc1);
[{jumpif, _, _}|_] -> reorder_blocks(Blocks, Acc1);
[{jump, L}|_] -> [{jump, L}|_] ->
NotL = fun({L1, _}) -> L1 /= L end, NotL = fun({L1, _}) -> L1 /= L end,
case lists:splitwith(NotL, Blocks) of case lists:splitwith(NotL, Blocks) of
@ -1783,6 +1783,7 @@ tweak_returns(['RETURN', {'PUSH', A} | Code]) -> [{'RETURNR', A} | Code
tweak_returns(['RETURN' | Code = [{'CALL_T', _} | _]]) -> Code; tweak_returns(['RETURN' | Code = [{'CALL_T', _} | _]]) -> Code;
tweak_returns(['RETURN' | Code = [{'ABORT', _} | _]]) -> Code; tweak_returns(['RETURN' | Code = [{'ABORT', _} | _]]) -> Code;
tweak_returns(['RETURN' | Code = [{'EXIT', _} | _]]) -> Code; tweak_returns(['RETURN' | Code = [{'EXIT', _} | _]]) -> Code;
tweak_returns(['RETURN' | Code = [{jump, _} | _]]) -> Code;
tweak_returns(['RETURN' | Code = [loop | _]]) -> Code; tweak_returns(['RETURN' | Code = [loop | _]]) -> Code;
tweak_returns(Code) -> Code. tweak_returns(Code) -> Code.