diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index daca7e5..54f61c7 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -653,6 +653,18 @@ expr_to_fcode(Env, _Type, {list, _, Es}) -> lists:foldr(fun(E, L) -> {op, '::', [expr_to_fcode(Env, E), L]} end, nil, Es); +expr_to_fcode(Env, _Type, {app, _, {'..', _}, [A, B]}) -> + AV = fresh_name(), + BV = fresh_name(), + WithA = fun(X) -> {'let', AV, expr_to_fcode(Env, A), X} end, + WithB = fun(X) -> {'let', BV, expr_to_fcode(Env, B), X} end, + St = fresh_name(), + Init = {var, AV}, + Loop = {loop, Init, St, make_if({op, '<', [{var, St}, {var, BV}]}, + {continue, {op, '+', [{var, St}, {lit, {int, 1}}]}}, + {break, nil} + )}, + WithA(WithB(Loop)); expr_to_fcode(Env, _Type, {app, _, {'..', _}, [A, B]}) -> AV = fresh_name(), BV = fresh_name(), diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index 23e8b31..ff34f42 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -378,10 +378,10 @@ to_scode1(Env, {loop, Init, It, Expr}) -> InitS = to_scode(Env, Init) ++ [{jump, ContRef}], {ItV, Env1} = bind_local(It, Env), ExprS = to_scode(bind_loop(ContRef, BreakRef, ItV, Env1), Expr) ++ [{jumpif, ?a, ContRef}, {jump, BreakRef}], - [{loop, InitS, It, ExprS, ContRef, BreakRef}]; + [{loop, InitS, ItV, ExprS, ContRef, BreakRef}]; to_scode1(Env = #env{cont_ref = ContRef, loop_it = It}, {continue, Expr}) -> ExprS = to_scode1(Env, Expr), - ExprS ++ [{'POP', It}, push(?i(1))]; + ExprS ++ [{'STORE', It, ?a}, push(?i(1))]; to_scode1(Env = #env{break_ref = BreakRef}, {break, Expr}) -> ExprS = to_scode1(Env, Expr), ExprS ++ [push(?i(0))];