Popularized use of builtin_call function
This commit is contained in:
parent
8eaafa736c
commit
bb5a710626
@ -173,8 +173,7 @@ ast_body({qid, _, [Con, "put"]}, #{ contract_name := Con }) ->
|
|||||||
|
|
||||||
%% Abort
|
%% Abort
|
||||||
ast_body(?id_app("abort", [String], _, _), Icode) ->
|
ast_body(?id_app("abort", [String], _, _), Icode) ->
|
||||||
#funcall{ function = #var_ref{ name = {builtin, abort} },
|
builtin_call(abort, [ast_body(String, Icode)]);
|
||||||
args = [ast_body(String, Icode)] };
|
|
||||||
|
|
||||||
%% Authentication
|
%% Authentication
|
||||||
ast_body({qid, _, ["Auth", "tx_hash"]}, _Icode) ->
|
ast_body({qid, _, ["Auth", "tx_hash"]}, _Icode) ->
|
||||||
@ -370,13 +369,11 @@ ast_body(?qid_app(["String", "blake2b"], [String], _, _), Icode) ->
|
|||||||
%% Strings
|
%% Strings
|
||||||
%% -- String length
|
%% -- String length
|
||||||
ast_body(?qid_app(["String", "length"], [String], _, _), Icode) ->
|
ast_body(?qid_app(["String", "length"], [String], _, _), Icode) ->
|
||||||
#funcall{ function = #var_ref{ name = {builtin, string_length} },
|
builtin_call(string_length, [ast_body(String, Icode)]);
|
||||||
args = [ast_body(String, Icode)] };
|
|
||||||
|
|
||||||
%% -- String concat
|
%% -- String concat
|
||||||
ast_body(?qid_app(["String", "concat"], [String1, String2], _, _), Icode) ->
|
ast_body(?qid_app(["String", "concat"], [String1, String2], _, _), Icode) ->
|
||||||
#funcall{ function = #var_ref{ name = {builtin, string_concat} },
|
builtin_call(string_concat, [ast_body(String1, Icode), ast_body(String2, Icode)]);
|
||||||
args = [ast_body(String1, Icode), ast_body(String2, Icode)] };
|
|
||||||
|
|
||||||
%% -- String hash (sha3)
|
%% -- String hash (sha3)
|
||||||
ast_body(?qid_app(["String", "sha3"], [String], _, _), Icode) ->
|
ast_body(?qid_app(["String", "sha3"], [String], _, _), Icode) ->
|
||||||
@ -602,13 +599,11 @@ ast_binop(Op, Ann, {typed, _, A, Type}, B, Icode)
|
|||||||
Builtin =
|
Builtin =
|
||||||
case OtherType of
|
case OtherType of
|
||||||
string ->
|
string ->
|
||||||
#funcall{ function = #var_ref{name = {builtin, str_equal}},
|
builtin_call(str_equal, Args);
|
||||||
args = Args };
|
|
||||||
{tuple, Types} ->
|
{tuple, Types} ->
|
||||||
case lists:usort(Types) of
|
case lists:usort(Types) of
|
||||||
[word] ->
|
[word] ->
|
||||||
#funcall{ function = #var_ref{name = {builtin, str_equal_p}},
|
builtin_call(str_equal_p, [ #integer{value = 32 * length(Types)} | Args]);
|
||||||
args = [ #integer{value = 32 * length(Types)} | Args] };
|
|
||||||
_ -> gen_error({cant_compare, Ann, Op, Type})
|
_ -> gen_error({cant_compare, Ann, Op, Type})
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
@ -617,8 +612,7 @@ ast_binop(Op, Ann, {typed, _, A, Type}, B, Icode)
|
|||||||
Neg(Builtin)
|
Neg(Builtin)
|
||||||
end;
|
end;
|
||||||
ast_binop('++', _, A, B, Icode) ->
|
ast_binop('++', _, A, B, Icode) ->
|
||||||
#funcall{ function = #var_ref{ name = {builtin, list_concat} },
|
builtin_call(list_concat, [ast_body(A, Icode), ast_body(B, Icode)]);
|
||||||
args = [ast_body(A, Icode), ast_body(B, Icode)] };
|
|
||||||
ast_binop(Op, _, A, B, Icode) ->
|
ast_binop(Op, _, A, B, Icode) ->
|
||||||
#binop{op = Op, left = ast_body(A, Icode), right = ast_body(B, Icode)}.
|
#binop{op = Op, left = ast_body(A, Icode), right = ast_body(B, Icode)}.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user