Add require builtin

This commit is contained in:
Ulf Norell
2019-06-14 10:27:07 +02:00
parent 5628cf90b8
commit 17a1fd8095
14 changed files with 19 additions and 30 deletions
+3 -1
View File
@@ -170,7 +170,7 @@ builtins() ->
MkName = fun(NS, Fun) ->
list_to_atom(string:to_lower(string:join(NS ++ [Fun], "_")))
end,
Scopes = [{[], [{"abort", 1}]},
Scopes = [{[], [{"abort", 1}, {"require", 2}]},
{["Chain"], [{"spend", 2}, {"balance", 1}, {"block_hash", 1}, {"coinbase", none},
{"timestamp", none}, {"block_height", none}, {"difficulty", none},
{"gas_limit", none}]},
@@ -765,6 +765,8 @@ op_builtins() ->
bits_difference, int_to_str, address_to_str, crypto_ecverify,
crypto_ecverify_secp256k1, crypto_sha3, crypto_sha256, crypto_blake2b].
builtin_to_fcode(require, [Cond, Msg]) ->
make_if(Cond, {tuple, []}, {builtin, abort, [Msg]});
builtin_to_fcode(map_delete, [Key, Map]) ->
{op, map_delete, [Map, Key]};
builtin_to_fcode(map_member, [Key, Map]) ->