Documentation
¶
Overview ¶
Package op defines opcodes used by the Risor compiler and virtual machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryOpType ¶
type BinaryOpType uint16
BinaryOpType describes a type of binary operation, as in an operation that takes two operands. For example, addition, subtraction, multiplication, etc.
const ( Add BinaryOpType = 1 Subtract BinaryOpType = 2 Multiply BinaryOpType = 3 Divide BinaryOpType = 4 Modulo BinaryOpType = 5 And BinaryOpType = 6 Or BinaryOpType = 7 Xor BinaryOpType = 8 Power BinaryOpType = 9 LShift BinaryOpType = 10 RShift BinaryOpType = 11 BitwiseAnd BinaryOpType = 12 BitwiseOr BinaryOpType = 13 )
func (BinaryOpType) String ¶
func (bop BinaryOpType) String() string
String returns a string representation of the binary operation. For example "+" for addition.
type Code ¶
type Code uint16
Code is an integer opcode that indicates an operation to execute.
const ( Invalid Code = 0 // Execution Nop Code = 1 Halt Code = 2 Call Code = 3 ReturnValue Code = 4 // Defer (removed in v2) Code = 5 // Go (removed in v2) Code = 6 CallSpread Code = 7 // Call with args from list on stack // Jump JumpBackward Code = 10 JumpForward Code = 11 PopJumpForwardIfFalse Code = 12 PopJumpForwardIfTrue Code = 13 PopJumpForwardIfNotNil Code = 14 PopJumpForwardIfNil Code = 15 // Load LoadAttr Code = 20 LoadFast Code = 21 LoadFree Code = 22 LoadGlobal Code = 23 LoadConst Code = 24 LoadAttrOrNil Code = 25 // Like LoadAttr but returns nil instead of error for missing attrs // Store StoreAttr Code = 30 StoreFast Code = 31 StoreFree Code = 32 StoreGlobal Code = 33 // Operations BinaryOp Code = 40 CompareOp Code = 41 UnaryNegative Code = 42 UnaryNot Code = 43 // Build BuildList Code = 50 BuildMap Code = 51 BuildString Code = 53 ListAppend Code = 54 // Append TOS to list at TOS-1 ListExtend Code = 55 // Extend list at TOS-1 with iterable at TOS MapMerge Code = 56 // Merge map at TOS into map at TOS-1 MapSet Code = 57 // Set key (TOS-1) to value (TOS) in map at TOS-2 // Containers BinarySubscr Code = 60 StoreSubscr Code = 61 ContainsOp Code = 62 Length Code = 63 Slice Code = 64 Unpack Code = 65 // Stack Swap Code = 70 Copy Code = 71 PopTop Code = 72 // Push constants Nil Code = 80 False Code = 81 True Code = 82 // Closures LoadClosure Code = 120 MakeCell Code = 121 // Partials Partial Code = 130 // Exception handling PushExcept Code = 140 // Push exception handler: operand1=catch offset, operand2=finally offset PopExcept Code = 141 // Pop exception handler (normal try completion) Throw Code = 142 // Throw TOS as exception EndFinally Code = 143 // End finally block, re-raise pending exception if any )
type CompareOpType ¶
type CompareOpType uint16
CompareOpType describes a type of comparison operation. For example, less than, greater than, equal, etc.
const ( LessThan CompareOpType = 1 LessThanOrEqual CompareOpType = 2 Equal CompareOpType = 3 NotEqual CompareOpType = 4 GreaterThan CompareOpType = 5 GreaterThanOrEqual CompareOpType = 6 )
func (CompareOpType) String ¶
func (cop CompareOpType) String() string
String returns a string representation of the comparison operation. For example "<" for less than.
Click to show internal directories.
Click to hide internal directories.