Module ketos::bytecode
[−]
[src]
Implements encoding and decoding of bytecode instruction format.
Bytecode instructions consist of a one-byte operand, followed by zero or more
unsigned integer operands in the range [0, 0x7fff]
(15 bits).
Operands in the range [0, 0x7f]
are encoded as a single byte. Operands in
the range [0x80, 0x7fff]
are encoded as two bytes: the first containing
the higher 7 bits of the operand with the 8th bit set; the second containing
the lower 8 bits of the operand.
Combination instructions exist to combine the operation of two or more
instructions which commonly follow, e.g. ConstPush(n)
operates as
Const(n)
followed by Push
.
Shortcut opcodes exist for common instructions that accept operands,
such as Const
and Load
. These opcodes replace a long-form instruction
with a single opcode, e.g. the CONST_0
opcode replaces the two-byte
sequence CONST
, followed by operand 0
.
Modules
code_flags |
Bit flag values for |
opcodes |
Opcode values of compiled bytecode. |
Structs
Code |
Represents a compiled bytecode function or expression. |
CodeBlock |
Contains a series of bytecode instructions |
CodeReader |
Reads |
Enums
Instruction |
Represents an instruction and any immediate parameters. |
JumpInstruction |
Partial representation of jump |
Constants
BYTECODE_VERSION |
Bytecode version number, indicating the version of the most recent breaking
change to the bytecode format. The version represents a |
MAX_LONG_OPERAND |
Maximum value of a long-encoded operand. |
MAX_SHORT_OPERAND |
Maximum value of a short-encoded operand. |