You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add HASKEY, KEYS, VALUES, DCALL four NeoVM OpCode.
NeoVM already have the opcode NEWMAP. that is to say, map is a baisc type of NeoVM, acctually, NeoVM has bytearray, interger, boolean, array, interop, struct type. Now NeoVM opcode can get these type's characteristic, like element of array, len of bytearray, etc. however NeoVM now can only new a map through NEWMAP opcode. and do not have any other way to get the map's characteristic, like keys, values. this lackless limited the usage of neovm baisc map type. any language convert it's type to neovm map can not get any other infomation. casually, the python map object almost have the same semantic of neovm map. so the python map object convert neovm map object is the best choice. however, now can not get the keys, and values.
as we know, the CALL only leave 2 bytes to save the offsets which is equal jump target sub call offset(address). now a smartcontract's source code exceed more than 1000 lines. usually, the compile will failed due to the call 2 bytes limit.
Specification
HASKEY
this opcode used to check whether arg 'key' is a map's key. the typical python code is below:
acctually this opcode is not necessary if realize the keys already. haskey function can get the keys first. then compare to the arg key by travel all elements in keys. if find a element equal. return True, else return False.
VALUES
this opcode used to get the values of a map, and return the map's values as a list on the top of the stack. the typical python code is below:
the keys attribute function will compile to opcode KEYS as a builtin function.
DCALL
this opcode used to do the vm context switch. however different with CALL get the two bytes offset after CALL opcode, stored in the avm code stream, DCALL just get the jump target(not relative offset compare to CALL offset) from the top stack of the evaluation stack. this will solve the function call distance two long which can not convert such offset to two bytes. and gives more flexibility.
The text was updated successfully, but these errors were encountered:
Title: Add Four NeoVM OpCode
Author: [email protected]
Created Dec. 20th. 2018
Add Four NeoVM OpCode
Abstraction
add HASKEY, KEYS, VALUES, DCALL four NeoVM OpCode.
NeoVM already have the opcode NEWMAP. that is to say, map is a baisc type of NeoVM, acctually, NeoVM has bytearray, interger, boolean, array, interop, struct type. Now NeoVM opcode can get these type's characteristic, like element of array, len of bytearray, etc. however NeoVM now can only new a map through NEWMAP opcode. and do not have any other way to get the map's characteristic, like keys, values. this lackless limited the usage of neovm baisc map type. any language convert it's type to neovm map can not get any other infomation. casually, the python map object almost have the same semantic of neovm map. so the python map object convert neovm map object is the best choice. however, now can not get the keys, and values.
as we know, the CALL only leave 2 bytes to save the offsets which is equal jump target sub call offset(address). now a smartcontract's source code exceed more than 1000 lines. usually, the compile will failed due to the call 2 bytes limit.
Specification
HASKEY
this opcode used to check whether arg 'key' is a map's key. the typical python code is below:
acctually this opcode is not necessary if realize the keys already. haskey function can get the keys first. then compare to the arg key by travel all elements in keys. if find a element equal. return True, else return False.
VALUES
this opcode used to get the values of a map, and return the map's values as a list on the top of the stack. the typical python code is below:
the values attribute function will compile to opcode VALUES as a builtin function.
KEYS
this opcode used to get the keys of a map, and return the map's keys as a list on the top of the stack. the typical python code is below:
the keys attribute function will compile to opcode KEYS as a builtin function.
DCALL
this opcode used to do the vm context switch. however different with CALL get the two bytes offset after CALL opcode, stored in the avm code stream, DCALL just get the jump target(not relative offset compare to CALL offset) from the top stack of the evaluation stack. this will solve the function call distance two long which can not convert such offset to two bytes. and gives more flexibility.
The text was updated successfully, but these errors were encountered: