tools/vm: Enhance Callable Opcodes #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Makes
Op
opcodes callable and the resulting bytecode automatically sets the stack up.If the opcode has data portion, the first argument is required and it becomes the data that is appended after the opcode.
The rest of the arguments are considered the stack, and they are appended before opcode byte, in LIFO order (the last argument is pushed first to the stack, and the first argument is pushed last).
E.g.
In this example, the
Op.SSTORE
saves the result of theOp.CALL
into the0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
key of the storage, and the parameters ofOp.CALL
are pushed into the stack before its execution (0x1234
is pushed first to the stack using an implicitOp.PUSH2
, then0x20
usingOp.PUSH1
, and so on untilOp.GAS
).