![]() |
Phasor 3.1.1
Stack VM based Programming Language
|
Public Member Functions | |
| "Instruction" | halt (cls) |
| "Instruction" | push_const (cls, int const_index) |
| "Instruction" | load_var (cls, int var_index) |
| "Instruction" | store_var (cls, int var_index) |
| "Instruction" | call (cls, int name_const_index, int arg_count=0) |
| "Instruction" | jump (cls, int offset) |
| "Instruction" | jump_if_false (cls, int offset) |
| "Instruction" | jump_if_true (cls, int offset) |
| str | __repr__ (self) |
Static Public Attributes | |
| int | operand1 = 0 |
| int | operand2 = 0 |
| int | operand3 = 0 |
A single Phasor VM instruction with an :class:`~phasor.OpCode.OpCode` and up to five ``int32`` operands. Unused operands default to ``0``. The on-disk representation is always :data:`_WIRE_SIZE` (21) bytes: one ``uint8`` opcode followed by five ``int32`` fields. Prefer the factory class-methods (:meth:`halt`, :meth:`push_const`, etc.) for common opcodes rather than constructing instances directly.
Definition at line 26 of file Instruction.py.
| str phasor.Instruction.Instruction.__repr__ | ( | self | ) |
Return a concise debug representation showing the opcode name and non-zero operands.
Definition at line 85 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.call | ( | cls, | |
| int | name_const_index, | ||
| int | arg_count = 0 ) |
Return a :attr:`~phasor.OpCode.OpCode.CALL` instruction.
Args:
name_const_index: Index into the constant pool where the function name string is stored.
arg_count: Number of arguments already pushed onto the stack (default ``0``).
Definition at line 61 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.halt | ( | cls | ) |
Return a :attr:`~phasor.OpCode.OpCode.HALT` instruction.
Definition at line 41 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.jump | ( | cls, | |
| int | offset ) |
Return a :attr:`~phasor.OpCode.OpCode.JUMP` instruction that unconditionally transfers control to instruction *offset*.
Definition at line 71 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.jump_if_false | ( | cls, | |
| int | offset ) |
Return a :attr:`~phasor.OpCode.OpCode.JUMP_IF_FALSE` instruction that branches to *offset* and pops TOS when it is falsy.
Definition at line 76 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.jump_if_true | ( | cls, | |
| int | offset ) |
Return a :attr:`~phasor.OpCode.OpCode.JUMP_IF_TRUE` instruction that branches to *offset* and pops TOS when it is truthy.
Definition at line 81 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.load_var | ( | cls, | |
| int | var_index ) |
Return a :attr:`~phasor.OpCode.OpCode.LOAD_VAR` instruction that pushes variable slot *var_index* onto the stack.
Definition at line 51 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.push_const | ( | cls, | |
| int | const_index ) |
Return a :attr:`~phasor.OpCode.OpCode.PUSH_CONST` instruction that pushes :attr:`Bytecode.constants[const_index] <phasor.Bytecode.Bytecode.constants>` onto the stack.
Definition at line 46 of file Instruction.py.
| "Instruction" phasor.Instruction.Instruction.store_var | ( | cls, | |
| int | var_index ) |
Return a :attr:`~phasor.OpCode.OpCode.STORE_VAR` instruction that pops TOS into variable slot *var_index*.
Definition at line 56 of file Instruction.py.
|
static |
Definition at line 36 of file Instruction.py.
|
static |
Definition at line 37 of file Instruction.py.
|
static |
Definition at line 38 of file Instruction.py.