Add value and gas to remote calls (#64)
* Add value and gas to remote calls
This commit is contained in:
parent
f8ee8f7129
commit
251b876495
@ -3,7 +3,7 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
|
|
||||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git",
|
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git",
|
||||||
{ref, "08a09b0"}}}
|
{ref, "2f4e188"}}}
|
||||||
, {getopt, "1.0.1"}
|
, {getopt, "1.0.1"}
|
||||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git",
|
, {jsx, {git, "https://github.com/talentdeficit/jsx.git",
|
||||||
{tag, "2.8.0"}}}
|
{tag, "2.8.0"}}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{"1.1.0",
|
{"1.1.0",
|
||||||
[{<<"aebytecode">>,
|
[{<<"aebytecode">>,
|
||||||
{git,"https://github.com/aeternity/aebytecode.git",
|
{git,"https://github.com/aeternity/aebytecode.git",
|
||||||
{ref,"08a09b065b9c5c4d1c499372a90914c80349dace"}},
|
{ref,"2f4e1888c241a7347ffec855ab6761c2c2972f37"}},
|
||||||
0},
|
0},
|
||||||
{<<"aeserialization">>,
|
{<<"aeserialization">>,
|
||||||
{git,"https://github.com/aeternity/aeserialization.git",
|
{git,"https://github.com/aeternity/aeserialization.git",
|
||||||
|
@ -235,12 +235,24 @@ to_scode(Env, {funcall, Fun, Args}) ->
|
|||||||
to_scode(Env, {builtin, B, Args}) ->
|
to_scode(Env, {builtin, B, Args}) ->
|
||||||
builtin_to_scode(Env, B, Args);
|
builtin_to_scode(Env, B, Args);
|
||||||
|
|
||||||
to_scode(Env, {remote, Ct, Fun, [_Gas, _Value | Args]}) ->
|
to_scode(Env, {remote, Ct, Fun, [{builtin, call_gas_left, _}, Value | Args]}) ->
|
||||||
%% TODO: FATE doesn't support value and gas arguments yet
|
%% Gas is not limited.
|
||||||
Lbl = make_function_name(Fun),
|
Lbl = make_function_name(Fun),
|
||||||
Call = if Env#env.tailpos -> aeb_fate_code:call_tr(?a, Lbl);
|
Call = if Env#env.tailpos -> aeb_fate_code:call_tr(?a, Lbl, ?a);
|
||||||
true -> aeb_fate_code:call_r(?a, Lbl) end,
|
true -> aeb_fate_code:call_r(?a, Lbl, ?a)
|
||||||
call_to_scode(Env, [to_scode(Env, Ct), Call], Args);
|
end,
|
||||||
|
call_to_scode(Env, [to_scode(Env, Value), to_scode(Env, Ct), Call], Args);
|
||||||
|
|
||||||
|
to_scode(Env, {remote, Ct, Fun, [Gas, Value | Args]}) ->
|
||||||
|
%% Gas is limited.
|
||||||
|
Lbl = make_function_name(Fun),
|
||||||
|
Call = if Env#env.tailpos -> aeb_fate_code:call_gtr(?a, Lbl, ?a, ?a);
|
||||||
|
true -> aeb_fate_code:call_gr(?a, Lbl, ?a, ?a)
|
||||||
|
end,
|
||||||
|
call_to_scode(Env, [to_scode(Env, Gas),
|
||||||
|
to_scode(Env, Value),
|
||||||
|
to_scode(Env, Ct), Call],
|
||||||
|
Args);
|
||||||
|
|
||||||
to_scode(Env, {closure, Fun, FVs}) ->
|
to_scode(Env, {closure, Fun, FVs}) ->
|
||||||
to_scode(Env, {tuple, [{lit, {string, make_function_name(Fun)}}, FVs]});
|
to_scode(Env, {tuple, [{lit, {string, make_function_name(Fun)}}, FVs]});
|
||||||
@ -622,9 +634,11 @@ attributes(I) ->
|
|||||||
'RETURN' -> Impure(pc, []);
|
'RETURN' -> Impure(pc, []);
|
||||||
{'RETURNR', A} -> Impure(pc, A);
|
{'RETURNR', A} -> Impure(pc, A);
|
||||||
{'CALL', _} -> Impure(?a, []);
|
{'CALL', _} -> Impure(?a, []);
|
||||||
{'CALL_R', A, _} -> Impure(?a, A);
|
{'CALL_R', A, _, B} -> Impure(?a, [A, B]);
|
||||||
|
{'CALL_GR', A, _, B, C} -> Impure(?a, [A, B, C]);
|
||||||
{'CALL_T', _} -> Impure(pc, []);
|
{'CALL_T', _} -> Impure(pc, []);
|
||||||
{'CALL_TR', A, _} -> Impure(pc, A);
|
{'CALL_TR', A, _, B} -> Impure(pc, [A, B]);
|
||||||
|
{'CALL_GTR', A, _, B, C} -> Impure(pc, [A, B, C]);
|
||||||
{'JUMP', _} -> Impure(pc, []);
|
{'JUMP', _} -> Impure(pc, []);
|
||||||
{'JUMPIF', A, _} -> Impure(pc, A);
|
{'JUMPIF', A, _} -> Impure(pc, A);
|
||||||
{'SWITCH_V2', A, _, _} -> Impure(pc, A);
|
{'SWITCH_V2', A, _, _} -> Impure(pc, A);
|
||||||
@ -1281,7 +1295,8 @@ reorder_blocks(Ref, Code, Blocks, Acc) ->
|
|||||||
['RETURN'|_] -> reorder_blocks(Blocks, Acc1);
|
['RETURN'|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{'RETURNR', _}|_] -> reorder_blocks(Blocks, Acc1);
|
[{'RETURNR', _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{'CALL_T', _}|_] -> reorder_blocks(Blocks, Acc1);
|
[{'CALL_T', _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{'CALL_TR', _, _}|_] -> reorder_blocks(Blocks, Acc1);
|
[{'CALL_TR', _, _, _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
|
[{'CALL_GTR', _, _, _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{'ABORT', _}|_] -> reorder_blocks(Blocks, Acc1);
|
[{'ABORT', _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{switch, _, _}|_] -> reorder_blocks(Blocks, Acc1);
|
[{switch, _, _}|_] -> reorder_blocks(Blocks, Acc1);
|
||||||
[{jump, L}|_] ->
|
[{jump, L}|_] ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user