Change get_state and set_state fcode primitives to take a register

This commit is contained in:
Ulf Norell
2019-09-23 14:51:15 +02:00
parent 99ecda4b7b
commit d0fdd06d66
2 changed files with 28 additions and 7 deletions
+6 -5
View File
@@ -298,6 +298,12 @@ to_scode(Env, {remote, ArgsT, RetT, Ct, Fun, [Gas, Value | Args]}) ->
call_to_scode(Env, Call, [Ct, Value, Gas | Args])
end;
to_scode(_Env, {get_state, Reg}) ->
[push(?s(Reg))];
to_scode(Env, {set_state, Reg, Val}) ->
call_to_scode(Env, [aeb_fate_ops:store(?s(Reg), ?a),
tuple(0)], [Val]);
to_scode(Env, {closure, Fun, FVs}) ->
to_scode(Env, {tuple, [{lit, {string, make_function_id(Fun)}}, FVs]});
@@ -420,11 +426,6 @@ call_to_scode(Env, CallCode, Args) ->
[[to_scode(notail(Env), A) || A <- lists:reverse(Args)],
CallCode].
builtin_to_scode(_Env, get_state, []) ->
[push(?s(1))];
builtin_to_scode(Env, set_state, [_] = Args) ->
call_to_scode(Env, [aeb_fate_ops:store(?s(1), ?a),
tuple(0)], Args);
builtin_to_scode(Env, chain_event, Args) ->
call_to_scode(Env, [erlang:apply(aeb_fate_ops, log, lists:duplicate(length(Args), ?a)),
tuple(0)], Args);