Get rid of redundant arity field from op defs. Reorder and renumber ops. Fix bb_end for abort and exit. (#41)

This commit is contained in:
Erik Stenman 2019-05-23 13:37:32 +02:00 committed by GitHub
parent 11a8997ac7
commit 3e0e289f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 129 additions and 134 deletions

View File

@ -27,129 +27,127 @@ generate(Src, Include) ->
%% TODO: Some real gas numbers... %% TODO: Some real gas numbers...
ops_defs() -> ops_defs() ->
%% Opname, Opcode, args, end_bb, gas, format, Constructor, Documentation %% Opname, Opcode, end_bb, gas, format, Constructor, Documentation
[ { 'RETURN', 16#00, 0, true, 2, atomic, return, "Return from function call pop stack to arg0. The type of the retun value has to match the return type of the function."} [ { 'RETURN', 16#00, true, 2, [], return, "Return from function call pop stack to arg0. The type of the retun value has to match the return type of the function."}
, { 'RETURNR', 16#01, 1, true, 2, [a], returnr, "Return from function call copy Arg0 to arg0. The type of the retun value has to match the return type of the function."} , { 'RETURNR', 16#01, true, 2, [a], returnr, "Return from function call copy Arg0 to arg0. The type of the retun value has to match the return type of the function."}
, { 'CALL', 16#02, 1, true, 4, [a], call, "Call the function Arg0 with args on stack. The types of the arguments has to match the argument typs of the function."} , { 'CALL', 16#02, true, 4, [a], call, "Call the function Arg0 with args on stack. The types of the arguments has to match the argument typs of the function."}
, { 'CALL_R', 16#03, 3, true, 8, [a,is,a], call_r, "Remote call to contract Arg0 and function Arg1 with value Arg2. The types of the arguments has to match the argument typs of the function."} , { 'CALL_R', 16#03, true, 8, [a,is,a], call_r, "Remote call to contract Arg0 and function Arg1 with value Arg2. The types of the arguments has to match the argument typs of the function."}
, { 'CALL_T', 16#04, 1, true, 4, [a], call_t, "Tail call to function Arg0. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."} , { 'CALL_T', 16#04, true, 4, [a], call_t, "Tail call to function Arg0. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."}
, { 'CALL_TR', 16#05, 3, true, 8, [a,is,a], call_tr, "Remote tail call to contract Arg0 and function Arg1 with value Arg2. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."} , { 'CALL_TR', 16#05, true, 8, [a,is,a], call_tr, "Remote tail call to contract Arg0 and function Arg1 with value Arg2. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."}
, { 'JUMP', 16#06, 1, true, 3, [ii], jump, "Jump to a basic block. The basic block has to exist in the current function."} , { 'CALL_GR', 16#06, true, 8, [a,is,a,a], call_gr, "Remote call with gas cap in Arg3. Otherwise as CALL_R."}
, { 'JUMPIF', 16#07, 2, true, 4, [a,ii], jumpif, "Conditional jump to a basic block. If Arg0 then jump to Arg1."} , { 'CALL_GTR', 16#07, true, 8, [a,is,a,a], call_gtr, "Remote tail call with gas cap in Arg3. Otherwise as CALL_TR."}
, { 'SWITCH_V2', 16#08, 3, true, 4, [a,ii,ii], switch, "Conditional jump to a basic block on variant tag."} , { 'JUMP', 16#08, true, 3, [ii], jump, "Jump to a basic block. The basic block has to exist in the current function."}
, { 'SWITCH_V3', 16#09, 4, true, 4, [a,ii,ii,ii], switch, "Conditional jump to a basic block on variant tag."} , { 'JUMPIF', 16#09, true, 4, [a,ii], jumpif, "Conditional jump to a basic block. If Arg0 then jump to Arg1."}
, { 'SWITCH_VN', 16#0a, 2, true, 4, [a, li], switch, "Conditional jump to a basic block on variant tag."} , { 'SWITCH_V2', 16#0a, true, 4, [a,ii,ii], switch, "Conditional jump to a basic block on variant tag."}
, { 'PUSH', 16#0b, 1, false, 2, [a], push, "Push argument to stack."} , { 'SWITCH_V3', 16#0b, true, 4, [a,ii,ii,ii], switch, "Conditional jump to a basic block on variant tag."}
, { 'DUPA', 16#0c, 0, false, 3, atomic, dup, "push copy of accumulator on stack."} , { 'SWITCH_VN', 16#0c, true, 4, [a, li], switch, "Conditional jump to a basic block on variant tag."}
, { 'DUP', 16#0d, 1, false, 3, [a], dup, "push Arg0 stack pos on top of stack."} , { 'CALL_VALUE', 16#0d, false, 3, [a], call_value, "The value sent in the current remote call."}
, { 'POP', 16#0e, 1, false, 3, [a], pop, "Arg0 := top of stack."} , { 'PUSH', 16#0e, false, 2, [a], push, "Push argument to stack."}
, { 'STORE', 16#0f, 2, false, 3, [a,a], store, "Arg0 := Arg1."} , { 'DUPA', 16#0f, false, 3, [], dup, "push copy of accumulator on stack."}
, { 'INCA', 16#10, 0, false, 2, atomic, inc, "Increment accumulator."} , { 'DUP', 16#10, false, 3, [a], dup, "push Arg0 stack pos on top of stack."}
, { 'INC', 16#11, 1, false, 2, [a], inc, "Increment argument."} , { 'POP', 16#11, false, 3, [a], pop, "Arg0 := top of stack."}
, { 'DECA', 16#12, 0, false, 2, atomic, dec, "Decrement accumulator."} , { 'INCA', 16#12, false, 2, [], inc, "Increment accumulator."}
, { 'DEC', 16#13, 1, false, 2, [a], dec, "Decrement argument."} , { 'INC', 16#13, false, 2, [a], inc, "Increment argument."}
, { 'ADD', 16#14, 3, false, 3, [a,a,a], add, "Arg0 := Arg1 + Arg2."} , { 'DECA', 16#14, false, 2, [], dec, "Decrement accumulator."}
, { 'SUB', 16#15, 3, false, 3, [a,a,a], sub, "Arg0 := Arg1 - Arg2."} , { 'DEC', 16#15, false, 2, [a], dec, "Decrement argument."}
, { 'MUL', 16#16, 3, false, 3, [a,a,a], mul, "Arg0 := Arg1 * Arg2."} , { 'ADD', 16#16, false, 3, [a,a,a], add, "Arg0 := Arg1 + Arg2."}
, { 'DIV', 16#17, 3, false, 3, [a,a,a], divide, "Arg0 := Arg1 / Arg2."} , { 'SUB', 16#17, false, 3, [a,a,a], sub, "Arg0 := Arg1 - Arg2."}
, { 'MOD', 16#18, 3, false, 3, [a,a,a], modulo, "Arg0 := Arg1 mod Arg2."} , { 'MUL', 16#18, false, 3, [a,a,a], mul, "Arg0 := Arg1 * Arg2."}
, { 'POW', 16#19, 3, false, 3, [a,a,a], pow, "Arg0 := Arg1 ^ Arg2."} , { 'DIV', 16#19, false, 3, [a,a,a], divide, "Arg0 := Arg1 / Arg2."}
, { 'LT', 16#20, 3, false, 3, [a,a,a], lt, "Arg0 := Arg1 < Arg2."} , { 'MOD', 16#1a, false, 3, [a,a,a], modulo, "Arg0 := Arg1 mod Arg2."}
, { 'GT', 16#21, 3, false, 3, [a,a,a], gt, "Arg0 := Arg1 > Arg2."} , { 'POW', 16#1b, false, 3, [a,a,a], pow, "Arg0 := Arg1 ^ Arg2."}
, { 'EQ', 16#22, 3, false, 3, [a,a,a], eq, "Arg0 := Arg1 = Arg2."} , { 'STORE', 16#1c, false, 3, [a,a], store, "Arg0 := Arg1."}
, { 'ELT', 16#23, 3, false, 3, [a,a,a], elt, "Arg0 := Arg1 =< Arg2."} , { 'SHA3', 16#1d, false, 3, [], sha3, ""}
, { 'EGT', 16#24, 3, false, 3, [a,a,a], egt, "Arg0 := Arg1 >= Arg2."} , { 'SHA256', 16#1e, false, 3, [], sha256, ""}
, { 'NEQ', 16#25, 3, false, 3, [a,a,a], neq, "Arg0 := Arg1 /= Arg2."} , { 'BLAKE2B', 16#1f, false, 3, [], blake2b, ""}
, { 'AND', 16#26, 3, false, 3, [a,a,a], and_op, "Arg0 := Arg1 and Arg2."} , { 'LT', 16#20, false, 3, [a,a,a], lt, "Arg0 := Arg1 < Arg2."}
, { 'OR', 16#27, 3, false, 3, [a,a,a], or_op, "Arg0 := Arg1 or Arg2."} , { 'GT', 16#21, false, 3, [a,a,a], gt, "Arg0 := Arg1 > Arg2."}
, { 'NOT', 16#28, 2, false, 3, [a,a], not_op, "Arg0 := not Arg1."} , { 'EQ', 16#22, false, 3, [a,a,a], eq, "Arg0 := Arg1 = Arg2."}
, { 'TUPLE', 16#29, 1, false, 3, [ii], tuple, "Create a tuple of size = Arg0. Elements on stack."} , { 'ELT', 16#23, false, 3, [a,a,a], elt, "Arg0 := Arg1 =< Arg2."}
, { 'ELEMENT', 16#2a, 3, false, 3, [a,a,a], element_op, "Arg1 := element(Arg2, Arg3)."} , { 'EGT', 16#24, false, 3, [a,a,a], egt, "Arg0 := Arg1 >= Arg2."}
, { 'MAP_EMPTY', 16#2b, 1, false, 3, [a], map_empty, "Arg0 := #{}."} , { 'NEQ', 16#25, false, 3, [a,a,a], neq, "Arg0 := Arg1 /= Arg2."}
, { 'MAP_LOOKUP', 16#2c, 3, false, 3, [a,a,a], map_lookup, "Arg0 := lookup key Arg2 in map Arg1."} , { 'AND', 16#26, false, 3, [a,a,a], and_op, "Arg0 := Arg1 and Arg2."}
, { 'MAP_LOOKUPD', 16#2d, 4, false, 3, [a,a,a,a], map_lookup, "Arg0 := lookup key Arg2 in map Arg1 if key exists in map otherwise Arg0 := Arg3."} , { 'OR', 16#27, false, 3, [a,a,a], or_op, "Arg0 := Arg1 or Arg2."}
, { 'MAP_UPDATE', 16#2e, 4, false, 3, [a,a,a,a], map_update, "Arg0 := update key Arg2 in map Arg1 with value Arg3."} , { 'NOT', 16#28, false, 3, [a,a], not_op, "Arg0 := not Arg1."}
, { 'MAP_DELETE', 16#2f, 3, false, 3, [a,a,a], map_delete, "Arg0 := delete key Arg2 from map Arg1."} , { 'TUPLE', 16#29, false, 3, [ii], tuple, "Create a tuple of size = Arg0. Elements on stack."}
, { 'MAP_MEMBER', 16#30, 3, false, 3, [a,a,a], map_member, "Arg0 := true if key Arg2 is in map Arg1."} , { 'ELEMENT', 16#2a, false, 3, [a,a,a], element_op, "Arg1 := element(Arg2, Arg3)."}
, { 'MAP_FROM_LIST',16#31, 2, false, 3, [a,a], map_from_list, "Arg0 := make a map from (key, value) list in Arg1."} , { 'MAP_EMPTY', 16#2b, false, 3, [a], map_empty, "Arg0 := #{}."}
, { 'NIL', 16#32, 1, false, 3, [a], nil, "Arg0 := []."} , { 'MAP_LOOKUP', 16#2c, false, 3, [a,a,a], map_lookup, "Arg0 := lookup key Arg2 in map Arg1."}
, { 'IS_NIL', 16#33, 2, false, 3, [a,a], is_nil, "Arg0 := true if Arg1 == []."} , { 'MAP_LOOKUPD', 16#2d, false, 3, [a,a,a,a], map_lookup, "Arg0 := lookup key Arg2 in map Arg1 if key exists in map otherwise Arg0 := Arg3."}
, { 'CONS', 16#34, 3, false, 3, [a,a,a], cons, "Arg0 := [Arg1|Arg2]."} , { 'MAP_UPDATE', 16#2e, false, 3, [a,a,a,a], map_update, "Arg0 := update key Arg2 in map Arg1 with value Arg3."}
, { 'HD', 16#35, 2, false, 3, [a,a], hd, "Arg0 := head of list Arg1."} , { 'MAP_DELETE', 16#2f, false, 3, [a,a,a], map_delete, "Arg0 := delete key Arg2 from map Arg1."}
, { 'TL', 16#36, 2, false, 3, [a,a], tl, "Arg0 := tail of list Arg1."} , { 'MAP_MEMBER', 16#30, false, 3, [a,a,a], map_member, "Arg0 := true if key Arg2 is in map Arg1."}
, { 'LENGTH', 16#37, 2, false, 3, [a,a], length, "Arg0 := length of list Arg1."} , { 'MAP_FROM_LIST', 16#31, false, 3, [a,a], map_from_list, "Arg0 := make a map from (key, value) list in Arg1."}
, { 'APPEND', 16#38, 3, false, 3, [a,a,a], append, "Arg0 := Arg1 ++ Arg2."} , { 'NIL', 16#32, false, 3, [a], nil, "Arg0 := []."}
, { 'STR_JOIN', 16#39, 3, false, 3, [a,a,a], str_join, "Arg0 := string Arg1 followed by string Arg2."} , { 'IS_NIL', 16#33, false, 3, [a,a], is_nil, "Arg0 := true if Arg1 == []."}
, { 'INT_TO_STR', 16#40, 2, false, 3, [a,a], int_to_str, "Arg0 := turn integer Arg1 into a string."} , { 'CONS', 16#34, false, 3, [a,a,a], cons, "Arg0 := [Arg1|Arg2]."}
, { 'ADDR_TO_STR', 16#41, 2, false, 3, [a,a], addr_to_str, "Arg0 := turn address Arg1 into a string."} , { 'HD', 16#35, false, 3, [a,a], hd, "Arg0 := head of list Arg1."}
, { 'STR_REVERSE', 16#42, 2, false, 3, [a,a], str_reverse, "Arg0 := the reverse of string Arg1."} , { 'TL', 16#36, false, 3, [a,a], tl, "Arg0 := tail of list Arg1."}
, { 'INT_TO_ADDR', 16#43, 2, false, 3, [a,a], int_to_addr, "Arg0 := turn integer Arg1 into an address."} , { 'LENGTH', 16#37, false, 3, [a,a], length, "Arg0 := length of list Arg1."}
, { 'VARIANT', 16#44, 4, false, 3, [a,a,a,a], variant, "Arg0 := create a variant of size Arg1 with the tag Arg2 (Arg2 < Arg1) and take Arg3 elements from the stack."} , { 'APPEND', 16#38, false, 3, [a,a,a], append, "Arg0 := Arg1 ++ Arg2."}
, { 'VARIANT_TEST', 16#45, 3, false, 3, [a,a,a], variant_test, "Arg0 := true if variant Arg1 has the tag Arg2."} , { 'STR_JOIN', 16#39, false, 3, [a,a,a], str_join, "Arg0 := string Arg1 followed by string Arg2."}
, { 'VARIANT_ELEMENT',16#46, 3, false, 3, [a,a,a], variant_element, "Arg0 := element number Arg2 from variant Arg1."} , { 'INT_TO_STR', 16#3a, false, 3, [a,a], int_to_str, "Arg0 := turn integer Arg1 into a string."}
, { 'BITS_NONEA', 16#47, 0, false, 3, atomic, bits_none, "accumulator := empty bitmap."} , { 'ADDR_TO_STR', 16#3b, false, 3, [a,a], addr_to_str, "Arg0 := turn address Arg1 into a string."}
, { 'BITS_NONE', 16#48, 1, false, 3, [a], bits_none, "Arg0 := empty bitmap."} , { 'STR_REVERSE', 16#3c, false, 3, [a,a], str_reverse, "Arg0 := the reverse of string Arg1."}
, { 'BITS_ALLA', 16#49, 0, false, 3, atomic, bits_all, "accumulator := full bitmap."} , { 'INT_TO_ADDR', 16#3d, false, 3, [a,a], int_to_addr, "Arg0 := turn integer Arg1 into an address."}
, { 'BITS_ALL', 16#50, 1, false, 3, [a], bits_all, "Arg0 := full bitmap."} , { 'VARIANT', 16#3e, false, 3, [a,a,a,a], variant, "Arg0 := create a variant of size Arg1 with the tag Arg2 (Arg2 < Arg1) and take Arg3 elements from the stack."}
, { 'BITS_ALL_N', 16#51, 2, false, 3, [a,a], bits_all_n, "Arg0 := bitmap with Arg1 bits set."} , { 'VARIANT_TEST', 16#3f, false, 3, [a,a,a], variant_test, "Arg0 := true if variant Arg1 has the tag Arg2."}
, { 'BITS_SET', 16#52, 3, false, 3, [a,a,a], bits_set, "Arg0 := set bit Arg2 of bitmap Arg1."} , { 'VARIANT_ELEMENT', 16#40, false, 3, [a,a,a], variant_element, "Arg0 := element number Arg2 from variant Arg1."}
, { 'BITS_CLEAR', 16#53, 3, false, 3, [a,a,a], bits_clear, "Arg0 := clear bit Arg2 of bitmap Arg1."} , { 'BITS_NONEA', 16#41, false, 3, [], bits_none, "accumulator := empty bitmap."}
, { 'BITS_TEST', 16#54, 3, false, 3, [a,a,a], bits_test, "Arg0 := true if bit Arg2 of bitmap Arg1 is set."} , { 'BITS_NONE', 16#42, false, 3, [a], bits_none, "Arg0 := empty bitmap."}
, { 'BITS_SUM', 16#55, 2, false, 3, [a,a], bits_sum, "Arg0 := sum of set bits in bitmap Arg1. Exception if infinit bitmap."} , { 'BITS_ALLA', 16#43, false, 3, [], bits_all, "accumulator := full bitmap."}
, { 'BITS_OR', 16#56, 3, false, 3, [a,a,a], bits_or, "Arg0 := Arg1 v Arg2."} , { 'BITS_ALL', 16#44, false, 3, [a], bits_all, "Arg0 := full bitmap."}
, { 'BITS_AND', 16#57, 3, false, 3, [a,a,a], bits_and, "Arg0 := Arg1 ^ Arg2."} , { 'BITS_ALL_N', 16#45, false, 3, [a,a], bits_all_n, "Arg0 := bitmap with Arg1 bits set."}
, { 'BITS_DIFF', 16#58, 3, false, 3, [a,a,a], bits_diff, "Arg0 := Arg1 - Arg2."} , { 'BITS_SET', 16#46, false, 3, [a,a,a], bits_set, "Arg0 := set bit Arg2 of bitmap Arg1."}
, { 'ADDRESS', 16#59, 1, false, 3, [a], address, "Arg0 := The current contract address."} , { 'BITS_CLEAR', 16#47, false, 3, [a,a,a], bits_clear, "Arg0 := clear bit Arg2 of bitmap Arg1."}
, { 'BALANCE', 16#5a, 1, false, 3, [a], balance, "Arg0 := The current contract balance."} , { 'BITS_TEST', 16#48, false, 3, [a,a,a], bits_test, "Arg0 := true if bit Arg2 of bitmap Arg1 is set."}
, { 'ORIGIN', 16#5b, 1, false, 3, [a], origin, "Arg0 := Address of contract called by the call transaction."} , { 'BITS_SUM', 16#49, false, 3, [a,a], bits_sum, "Arg0 := sum of set bits in bitmap Arg1. Exception if infinit bitmap."}
, { 'CALLER', 16#5c, 1, false, 3, [a], caller, "Arg0 := The address that signed the call transaction."} , { 'BITS_OR', 16#4a, false, 3, [a,a,a], bits_or, "Arg0 := Arg1 v Arg2."}
, { 'GASPRICE', 16#5d, 1, false, 3, [a], gasprice, "Arg0 := The current gas price."} , { 'BITS_AND', 16#4b, false, 3, [a,a,a], bits_and, "Arg0 := Arg1 ^ Arg2."}
, { 'BLOCKHASH', 16#5e, 2, false, 3, [a, a], blockhash, "Arg0 := The blockhash at height."} , { 'BITS_DIFF', 16#4c, false, 3, [a,a,a], bits_diff, "Arg0 := Arg1 - Arg2."}
, { 'BENEFICIARY', 16#5f, 1, false, 3, [a], beneficiary, "Arg0 := The address of the current beneficiary."} , { 'ADDRESS', 16#4d, false, 3, [a], address, "Arg0 := The current contract address."}
, { 'TIMESTAMP', 16#60, 1, false, 3, [a], timestamp, "Arg0 := The current timestamp. Unrelaiable, don't use for anything."} , { 'BALANCE', 16#4e, false, 3, [a], balance, "Arg0 := The current contract balance."}
, { 'GENERATION', 16#61, 1, false, 3, [a], generation, "Arg0 := The block height of the cureent generation."} , { 'ORIGIN', 16#4f, false, 3, [a], origin, "Arg0 := Address of contract called by the call transaction."}
, { 'MICROBLOCK', 16#62, 1, false, 3, [a], microblock, "Arg0 := The current micro block number."} , { 'CALLER', 16#50, false, 3, [a], caller, "Arg0 := The address that signed the call transaction."}
, { 'DIFFICULTY', 16#63, 1, false, 3, [a], difficulty, "Arg0 := The current difficulty."} , { 'GASPRICE', 16#51, false, 3, [a], gasprice, "Arg0 := The current gas price."}
, { 'GASLIMIT', 16#64, 1, false, 3, [a], gaslimit, "Arg0 := The current gaslimit."} , { 'BLOCKHASH', 16#52, false, 3, [a,a], blockhash, "Arg0 := The blockhash at height."}
, { 'GAS', 16#65, 1, false, 3, [a], gas, "Arg0 := The amount of gas left."} , { 'BENEFICIARY', 16#53, false, 3, [a], beneficiary, "Arg0 := The address of the current beneficiary."}
, { 'TIMESTAMP', 16#54, false, 3, [a], timestamp, "Arg0 := The current timestamp. Unrelaiable, don't use for anything."}
, { 'GENERATION', 16#55, false, 3, [a], generation, "Arg0 := The block height of the cureent generation."}
, { 'MICROBLOCK', 16#56, false, 3, [a], microblock, "Arg0 := The current micro block number."}
, { 'DIFFICULTY', 16#57, false, 3, [a], difficulty, "Arg0 := The current difficulty."}
, { 'GASLIMIT', 16#58, false, 3, [a], gaslimit, "Arg0 := The current gaslimit."}
, { 'GAS', 16#59, false, 3, [a], gas, "Arg0 := The amount of gas left."}
, { 'LOG0', 16#66, 2, false, 3, [a,a], log, "Create a log message in the call object."} , { 'LOG0', 16#5a, false, 3, [a,a], log, "Create a log message in the call object."}
, { 'LOG1', 16#67, 3, false, 3, [a,a,a], log, "Create a log message with one topic in the call object."} , { 'LOG1', 16#5b, false, 3, [a,a,a], log, "Create a log message with one topic in the call object."}
, { 'LOG2', 16#68, 4, false, 3, [a,a,a,a], log, "Create a log message with two topics in the call object."} , { 'LOG2', 16#5c, false, 3, [a,a,a,a], log, "Create a log message with two topics in the call object."}
, { 'LOG3', 16#69, 5, false, 3, [a,a,a,a,a], log, "Create a log message with three topics in the call object."} , { 'LOG3', 16#5d, false, 3, [a,a,a,a,a], log, "Create a log message with three topics in the call object."}
, { 'LOG4', 16#6a, 6, false, 3, [a,a,a,a,a,a], log, "Create a log message with four topics in the call object."} , { 'LOG4', 16#5e, false, 3, [a,a,a,a,a,a], log, "Create a log message with four topics in the call object."}
, { 'DEACTIVATE', 16#6b, 0, false, 3, atomic, deactivate, "Mark the current contract for deactication."} , { 'DEACTIVATE', 16#5f, false, 3, [], deactivate, "Mark the current contract for deactication."}
%% Transaction ops %% Transaction ops
, { 'SPEND', 16#6c, 2, false,3, [a,a], spend, "Transfer Arg1 tokens to account Arg0. (If the contract account has at least that many tokens."} , { 'SPEND', 16#60, false, 3, [a,a], spend, "Transfer Arg1 tokens to account Arg0. (If the contract account has at least that many tokens."}
, { 'ORACLE_REGISTER', 16#6d, 6, false,3, [a,a,a,a,a,a], oracle_register, "Mark the current contract for deactication."} , { 'ORACLE_REGISTER', 16#61, false, 3, [a,a,a,a,a,a], oracle_register, "Mark the current contract for deactication."}
%% TODO: %% TODO:
, { 'ORACLE_QUERY', 16#6e, 0, false,3, atomic, oracle_query, ""} , { 'ORACLE_QUERY', 16#62, false, 3, [], oracle_query, ""}
, { 'ORACLE_RESPOND', 16#6f, 0, false,3, atomic, oracle_respond, ""} , { 'ORACLE_RESPOND', 16#63, false, 3, [], oracle_respond, ""}
, { 'ORACLE_EXTEND', 16#70, 0, false,3, atomic, oracle_extend, ""} , { 'ORACLE_EXTEND', 16#64, false, 3, [], oracle_extend, ""}
, { 'ORACLE_GET_ANSWER', 16#71, 0, false,3, atomic, oracle_get_answer, ""} , { 'ORACLE_GET_ANSWER', 16#65, false, 3, [], oracle_get_answer, ""}
, { 'ORACLE_GET_QUESTION', 16#72, 0, false,3, atomic,oracle_get_question, ""} , { 'ORACLE_GET_QUESTION', 16#66, false, 3, [], oracle_get_question, ""}
, { 'ORACLE_QUERY_FEE', 16#73, 0, false,3, atomic, oracle_query_fee, ""} , { 'ORACLE_QUERY_FEE', 16#67, false, 3, [], oracle_query_fee, ""}
, { 'AENS_RESOLVE', 16#74, 0, false,3, atomic, aens_resolve, ""} , { 'AENS_RESOLVE', 16#68, false, 3, [], aens_resolve, ""}
, { 'AENS_PRECLAIM', 16#75, 0, false,3, atomic, aens_preclaim, ""} , { 'AENS_PRECLAIM', 16#69, false, 3, [], aens_preclaim, ""}
, { 'AENS_CLAIM', 16#76, 0, false,3, atomic, aens_claim, ""} , { 'AENS_CLAIM', 16#6a, false, 3, [], aens_claim, ""}
, { 'AENS_UPDATE', 16#77, 0, false,3, atomic, aend_update, ""} , { 'AENS_UPDATE', 16#6b, false, 3, [], aend_update, ""}
, { 'AENS_TRANSFER', 16#78, 0, false,3, atomic, aens_transfer, ""} , { 'AENS_TRANSFER', 16#6c, false, 3, [], aens_transfer, ""}
, { 'AENS_REVOKE', 16#79, 0, false,3, atomic, aens_revoke, ""} , { 'AENS_REVOKE', 16#6d, false, 3, [], aens_revoke, ""}
, { 'ECVERIFY', 16#7a, 0, false,3, atomic, ecverify, ""} , { 'ECVERIFY', 16#6e, false, 3, [], ecverify, ""}
, { 'SHA3', 16#7b, 0, false,3, atomic, sha3, ""} , { 'BALANCE_OTHER', 16#6f, false, 3, [a,a], balance_other, "Arg0 := The balance of address Arg1."}
, { 'SHA256', 16#7c, 0, false,3, atomic, sha256, ""} , { 'SETELEMENT', 16#70, false, 3, [a,a,a,a], setelement, "Arg0 := a new tuple similar to Arg2, but with element number Arg1 replaced by Arg3."}
, { 'BLAKE2B', 16#7d, 0, false,3, atomic, blake2b, ""}
, { 'BALANCE_OTHER', 16#7e, 2, false,3, [a,a], balance_other, "Arg0 := The balance of address Arg1."}
, { 'SETELEMENT', 16#7f, 4, false,3, [a,a,a,a], setelement, "Arg0 := a new tuple similar to Arg2, but with element number Arg1 replaced by Arg3."}
, { 'CALL_GR', 16#80, 4, true,8, [a,is,a,a], call_gr, "Remote call with gas cap in Arg3. Otherwise as CALL_R."}
, { 'CALL_GTR', 16#81, 4, true,8, [a,is,a,a], call_gtr, "Remote tail call with gas cap in Arg3. Otherwise as CALL_TR."}
, { 'CALL_VALUE', 16#82, 1, false,3, [a], call_value, "The value sent in the current remote call."}
, { 'DUMMY7ARG', 16#f9, 7, false,3, [a,a,a,a,a,a,a], dummyarg, "Temporary dummy instruction to test 7 args."} , { 'ABORT', 16#fb, true, 3, [a], abort, "Abort execution (dont use all gas) with error message in Arg0."}
, { 'DUMMY8ARG', 16#fa, 8, false,3, [a,a,a,a,a,a,a,a],dummyarg, "Temporary dummy instruction to test 8 args."} , { 'EXIT', 16#fc, true, 3, [a], exit, "Abort execution (use upp all gas) with error message in Arg0."}
, { 'ABORT', 16#fb, 1, false, 3, [a], abort, "Abort execution (dont use all gas) with error message in Arg0."} , { 'NOP', 16#fd, false, 1, [], nop, "The no op. does nothing."}
, { 'EXIT', 16#fc, 1, false, 3, [a], exit, "Abort execution (use upp all gas) with error message in Arg0."}
, { 'NOP', 16#fd, 0, false, 1, atomic, nop, "The no op. does nothing."}
%% FUNCTION 16#fe "Function declaration and entrypoint." %% FUNCTION 16#fe "Function declaration and entrypoint."
%% EXTEND 16#ff "Reserved for future extensions beyond one byte opcodes." %% EXTEND 16#ff "Reserved for future extensions beyond one byte opcodes."
]. ].
@ -248,7 +246,7 @@ gen_type_exports(#{type_name := TypeName}) ->
gen_constructor_exports(#{constructor_type := Function}) -> gen_constructor_exports(#{constructor_type := Function}) ->
lists:flatten(io_lib:format(" , ~s\n", [Function])). lists:flatten(io_lib:format(" , ~s\n", [Function])).
gen_constructors(#{constructor := Function, format := atomic, gen_constructors(#{constructor := Function, format := [],
type_name := Type, opname := Name}) -> type_name := Type, opname := Name}) ->
lists:flatten(io_lib:format("-spec ~s() -> ~s.\n" lists:flatten(io_lib:format("-spec ~s() -> ~s.\n"
"~s() ->\n" "~s() ->\n"
@ -322,7 +320,7 @@ gen_m_to_op(#{opname := Name, macro := Macro}) ->
lists:flatten(io_lib:format("m_to_op(~21w) -> ~21s ;\n", lists:flatten(io_lib:format("m_to_op(~21w) -> ~21s ;\n",
[Name, Macro])). [Name, Macro])).
gen_args(#{macro := Macro, args := Args}) -> gen_args(#{macro := Macro, arity := Args}) ->
lists:flatten(io_lib:format("args(~21s) -> ~2w ;\n", lists:flatten(io_lib:format("args(~21s) -> ~2w ;\n",
[Macro, Args])). [Macro, Args])).
@ -349,13 +347,14 @@ gen_defines(#{opname := Name, opcode := OpCode}) ->
gen([]) -> gen([]) ->
[]; [];
gen([{OpName, OpCode, Args, EndBB, Gas, FateFormat, Constructor, Doc} | Rest]) -> gen([{OpName, OpCode, EndBB, Gas, FateFormat, Constructor, Doc} | Rest]) ->
Args = length(FateFormat),
Name = atom_to_list(OpName), Name = atom_to_list(OpName),
LowerName = string:to_lower(Name), LowerName = string:to_lower(Name),
TypeName = "fate_" ++ LowerName ++ "()", TypeName = "fate_" ++ LowerName ++ "()",
Macro = "?" ++ Name, Macro = "?" ++ Name,
Type = case FateFormat of Type = case FateFormat of
atomic -> io_lib:format("~w", [OpName]); [] -> io_lib:format("~w", [OpName]);
ArgTypes -> ArgTypes ->
io_lib:format("{~w, ~s}", [OpName, expand_types(ArgTypes)]) io_lib:format("{~w, ~s}", [OpName, expand_types(ArgTypes)])
end, end,
@ -363,7 +362,7 @@ gen([{OpName, OpCode, Args, EndBB, Gas, FateFormat, Constructor, Doc} | Rest]) -
[#{ opname => OpName [#{ opname => OpName
, opcode => OpCode , opcode => OpCode
, args => Args , arity => Args
, end_bb => EndBB , end_bb => EndBB
, format => FateFormat , format => FateFormat
, macro => Macro , macro => Macro
@ -458,7 +457,7 @@ gen_format(#{opname := Name}) when (Name =:= 'CALL_GR') or (Name =:= 'CALL_GTR')
"format_arg(a, Value), \" \", " "format_arg(a, Value), \" \", "
"format_arg(a, Gas)];\n", "format_arg(a, Gas)];\n",
[Name, atom_to_list(Name), Name, atom_to_list(Name)]); [Name, atom_to_list(Name), Name, atom_to_list(Name)]);
gen_format(#{opname := Name, format := atomic}) -> gen_format(#{opname := Name, format := []}) ->
io_lib:format("format_op(~w, _) -> [\"~s\"];", [Name, atom_to_list(Name)]); io_lib:format("format_op(~w, _) -> [\"~s\"];", [Name, atom_to_list(Name)]);
gen_format(#{opname := Name, format := Args}) -> gen_format(#{opname := Name, format := Args}) ->
NameAsString = atom_to_list(Name), NameAsString = atom_to_list(Name),
@ -547,7 +546,7 @@ test_asm_generator(Filename) ->
file:close(File). file:close(File).
gen_instruction(#{opname := Name, format := atomic}) -> gen_instruction(#{opname := Name, format := []}) ->
io_lib:format(" ~s\n", [Name]); io_lib:format(" ~s\n", [Name]);
gen_instruction(#{opname := Name, format := ArgTypes}) -> gen_instruction(#{opname := Name, format := ArgTypes}) ->
Args = lists:flatten(lists:join(" ", [gen_arg(A) || A <- ArgTypes])), Args = lists:flatten(lists:join(" ", [gen_arg(A) || A <- ArgTypes])),
@ -669,7 +668,7 @@ generate_documentation(Filename) ->
gen_doc(#{ opname := Name gen_doc(#{ opname := Name
, opcode := OpCode , opcode := OpCode
, args := _Args , arity := _Args
, end_bb := _EndBB , end_bb := _EndBB
, format := FateFormat , format := FateFormat
, macro := _Macro , macro := _Macro
@ -682,7 +681,7 @@ gen_doc(#{ opname := Name
}) -> }) ->
Arguments = Arguments =
case FateFormat of case FateFormat of
atomic -> ""; [] -> "";
_ -> lists:join(" ", _ -> lists:join(" ",
[format_arg_doc(A) || [format_arg_doc(A) ||
A <- A <-

View File

@ -226,10 +226,6 @@ FUNCTION foo () : {tuple, []}
BLAKE2B BLAKE2B
DUMMY7ARG a a 7607708484837907159893701471377343595877 (| [2,1] | 0 | ( [], [ 45, { 1 => 3441201581501946066216994494994943246334} ] ) |) a0 var56 "foo"
DUMMY8ARG 3673679924816289365509492271980889822579 a69 arg242 var237 a175 arg106 () var255
ABORT a ABORT a
EXIT var120 EXIT var120