ethers.js/docs.wrm/api/other/assembly/api.wrm

87 lines
2.8 KiB
Plaintext
Raw Normal View History

2020-02-18 01:56:13 +03:00
_section: Utilities @<asm-utilities>
_subsection: Assembler
The assembler utilities allow parsing and assembling an
[Ethers ASM Dialect](asm-dialect) source file.
_property: asm.parse(code) => [[asm-node]] @<asm-parse> @SRC<asm/assembler>
Parse an ethers-format assembly file and return the [[asm-ast]].
2020-05-08 10:24:40 +03:00
_property: asm.assemble(node) => string<[[DataHexString]]> @SRC<asm/assembler:function.assemble>
2020-02-18 01:56:13 +03:00
Performs assembly of the [[asm-ast]] //node// and return the
resulting bytecode representation.
_subsection: Disassembler
The **Disassembler** utilities make it easy to convert bytecode
into an object which can easily be examined for program structure.
_property: asm.disassemble(bytecode) => [[asm-bytecode]] @SRC<asm/assembler>
Returns an array of Operations given //bytecode//.
_property: asm.formatBytecode(operations) => string @SRC<asm/assembler>
Create a formatted output of an array of [[asm-operation]].
_heading: Bytecode @<asm-bytecode> @INHERIT<Array\<[[asm-operation]]\>>
2020-10-03 19:30:15 +03:00
Each array index represents an operation, collapsing multi-byte operations
2020-02-18 01:56:13 +03:00
(i.e. ``PUSH``) into a single operation.
_property: bytecode.getOperation(offset) => [[asm-operation]]
Get the operation at a given //offset// into the bytecode. This ensures that
the byte at //offset// is an operation and not data contained within a ``PUSH``,
in which case null it returned.
_heading: Operation @<asm-operation>
An **Operation** is a single command from a disassembled bytecode
stream.
_property: operation.opcode => [[asm-opcode]]
The opcode for this Operation.
_property: operation.offset => number
The offset into the bytecode for this Operation.
2020-05-08 10:24:40 +03:00
_property: operation.pushValue => string<[[DataHexString]]>
2020-02-18 01:56:13 +03:00
If the opcode is a ``PUSH``, this is the value of that push
_subsection: Opcode @<asm-opcode> @SRC<asm/opcodes:class.Opcode>
_property: asm.Opcode.from(valueOrMnemonic) => [[asm-opcode]]
2020-10-03 19:30:15 +03:00
Create a new instance of an Opcode for a given numeric value
2020-02-18 01:56:13 +03:00
(e.g. 0x60 is PUSH1) or mnemonic string (e.g. "PUSH1").
_heading: Properties
_property: opcode.value => number
The value (bytecode as a number) of this opcode.
_property: opcode.mnemonic => string
The mnemonic string of this opcode.
_property: opcode.delta => number
The number of items this opcode will consume from the stack.
_property: opcode.alpha => number
The number of items this opcode will push onto the stack.
_property: opcode.doc => string
A short description of what this opcode does.
_property: opcode.isMemory() => "read" | "write" | "full"
Returns true if the opcode accesses memory.
_property: opcode.isStatic() => boolean
Returns true if the opcode cannot change state.
_property: opcode.isJump() => boolean
Returns true if the opcode is a jumper operation.
_property: opcode.isPush() => number
Returns 0 if the opcode is not a ``PUSH*``, or the number
of bytes this opcode will push if it is.