Documentation ¶
Index ¶
- type BinaryAdd
- type BinaryConcat
- type BinaryEq
- type BinaryGt
- type BinaryGtEq
- type BinaryIn
- type BinaryListIndex
- type BinaryLt
- type BinaryLtEq
- type BinaryMapIndex
- type BinaryModulo
- type BinaryMul
- type BinaryNotEq
- type BinaryRealAdd
- type BinaryRealDiv
- type BinaryRealMul
- type BinaryRealSub
- type BinaryStringIndex
- type BinarySub
- type BuildClass
- type BuildList
- type BuildMap
- type BuildTuple
- type Bytecode
- type CallFunction
- type CheckLabel
- type CompiledProgram
- type CompiledProgramImport
- type DupTop
- type ForIter
- type GetIter
- type LookupMethod
- type Placeholder
- type PushConstBool
- type PushConstFunction
- type PushConstInt
- type PushConstRealNumber
- type PushConstStr
- type PushEnum
- type PushEnumIndex
- type PushField
- type PushName
- type PushTupleField
- type RelJump
- type RelJumpIfFalse
- type RelJumpIfFalseOrPop
- type RelJumpIfTrueOrPop
- type Return
- type RotThree
- type StoreField
- type StoreIndex
- type StoreMapIndex
- type StoreName
- type UnaryMinus
- type UnaryNot
- type UnpackTuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryConcat ¶
type BinaryConcat struct{}
Pop x, y from the stack and push x ++ y where x and y are strings.
func (*BinaryConcat) String ¶
func (b *BinaryConcat) String() string
type BinaryGtEq ¶
type BinaryGtEq struct{}
Pop x, y from the stack and push x >= y.
func (*BinaryGtEq) String ¶
func (b *BinaryGtEq) String() string
type BinaryListIndex ¶
type BinaryListIndex struct{}
Pop x, y from the stack and push x[y] where x is a list.
func (*BinaryListIndex) String ¶
func (b *BinaryListIndex) String() string
type BinaryLtEq ¶
type BinaryLtEq struct{}
Pop x, y from the stack and push x <= y.
func (*BinaryLtEq) String ¶
func (b *BinaryLtEq) String() string
type BinaryMapIndex ¶
type BinaryMapIndex struct{}
Pop x, y from the stack and push x[y] where x is a map.
func (*BinaryMapIndex) String ¶
func (b *BinaryMapIndex) String() string
type BinaryModulo ¶
type BinaryModulo struct{}
Pop x, y from the stack and push x % y.
func (*BinaryModulo) String ¶
func (b *BinaryModulo) String() string
type BinaryNotEq ¶
type BinaryNotEq struct{}
Pop x, y from the stack and push x != y.
func (*BinaryNotEq) String ¶
func (b *BinaryNotEq) String() string
type BinaryRealAdd ¶
type BinaryRealAdd struct{}
Same as BinaryAdd, BinaryMul, etc. except the operands are real numbers instead of integers.
func (*BinaryRealAdd) String ¶
func (b *BinaryRealAdd) String() string
type BinaryRealDiv ¶
type BinaryRealDiv struct{}
func (*BinaryRealDiv) String ¶
func (b *BinaryRealDiv) String() string
type BinaryRealMul ¶
type BinaryRealMul struct{}
func (*BinaryRealMul) String ¶
func (b *BinaryRealMul) String() string
type BinaryRealSub ¶
type BinaryRealSub struct{}
func (*BinaryRealSub) String ¶
func (b *BinaryRealSub) String() string
type BinaryStringIndex ¶
type BinaryStringIndex struct{}
Pop x, y from the stack and push x[y] where x is a string.
func (*BinaryStringIndex) String ¶
func (b *BinaryStringIndex) String() string
type BuildClass ¶
Pop N values from the stack, bundle them into a class object, and push it onto the stack.
func (*BuildClass) String ¶
func (b *BuildClass) String() string
type BuildList ¶
type BuildList struct {
N int
}
Pop N values from the stack, bundle them into a list, and push it onto the stack.
type BuildMap ¶
type BuildMap struct {
N int
}
Pop N*2 values from the stack where each key is before its corresponding value (e.g., [K, V, K, V]), bundle them into a map, and push it onto the stack.
type BuildTuple ¶
type BuildTuple struct {
N int
}
Pop N values from the stack, bundle them into a tuple, and push it onto the stack.
func (*BuildTuple) String ¶
func (b *BuildTuple) String() string
type CallFunction ¶
type CallFunction struct {
N int
}
Pop a function and N arguments from the top of stack (e.g., [arg3, arg2, arg1, f]), call the function with the arguments, and push the return value onto the stack if it is not void.
Note that in case the top of the stack is a bound method object created by LOOKUP_METHOD, N-1 arguments will be popped from the stack as the first argument will be supplied by the bound method object.
func (*CallFunction) String ¶
func (b *CallFunction) String() string
type CheckLabel ¶
type CheckLabel struct {
Name string
}
Check the top of the stack, which must be an enum object, and push true if it has the given label, or false otherwise.
Used to implement pattern-matching.
func (*CheckLabel) String ¶
func (b *CheckLabel) String() string
type CompiledProgram ¶
type CompiledProgram struct { Version int Imports []*CompiledProgramImport Code map[string][]Bytecode }
func NewCompiledProgram ¶
func NewCompiledProgram() *CompiledProgram
type CompiledProgramImport ¶
type DupTop ¶
type DupTop struct{}
Duplicate the value at the top of the stack. This only copies the reference, not the value itself.
type ForIter ¶
type ForIter struct {
N int
}
Call Next() on the top of the stack, which must be an iterator. If it returns nil, jump N instructions forward in the program. Otherwise, push the return value onto the stack.
type GetIter ¶
type GetIter struct{}
Pop the top of the stack, convert it into an iterator, and push the iterator onto the stack.
type LookupMethod ¶
type LookupMethod struct {
Name string
}
Pop the top of the stack, lookup the method called `Name`, and push a function object onto the stack.
func (*LookupMethod) String ¶
func (b *LookupMethod) String() string
type Placeholder ¶
type Placeholder struct {
Name string
}
Placeholder instruction used internally by the compiler.
func (*Placeholder) String ¶
func (b *Placeholder) String() string
type PushConstBool ¶
type PushConstBool struct {
Value bool
}
Push a constant boolean value onto the stack.
func (*PushConstBool) String ¶
func (b *PushConstBool) String() string
type PushConstFunction ¶
Push a constant function object onto the stack.
func (*PushConstFunction) String ¶
func (b *PushConstFunction) String() string
type PushConstInt ¶
type PushConstInt struct {
Value int
}
Push a constant integer value onto the stack.
func (*PushConstInt) String ¶
func (b *PushConstInt) String() string
type PushConstRealNumber ¶
type PushConstRealNumber struct {
Value float64
}
Push a constant real number value onto the stack.
func (*PushConstRealNumber) String ¶
func (b *PushConstRealNumber) String() string
type PushConstStr ¶
type PushConstStr struct {
Value string
}
Push a constant string value onto the stack.
func (*PushConstStr) String ¶
func (b *PushConstStr) String() string
type PushEnumIndex ¶
type PushEnumIndex struct {
Index int
}
Assuming the top of the stack is an enum object, push the value of the enum at `Index`.
Note that unlike PushField and PushTupleField, this instruction leaves the enum on the stack.
func (*PushEnumIndex) String ¶
func (b *PushEnumIndex) String() string
type PushField ¶
type PushField struct {
Index int
}
Assuming the top of the stack is a class object, pop it and push its field at `Index`.
Note that unlike PushEnumIndex, this instruction pops the class object from the stack.
type PushName ¶
type PushName struct {
Name string
}
Push the value of the given symbol onto the stack.
type PushTupleField ¶
type PushTupleField struct {
Index int
}
Assuming the top of the stack is a tuple, pop it and push its field at `Index`.
Note that unlike PushEnumIndex, this instruction pops the tuple from the stack.
func (*PushTupleField) String ¶
func (b *PushTupleField) String() string
type RelJump ¶
type RelJump struct {
N int
}
Jump N instructions forward in the program.
If N = 0, it loops forever. If N = 1, it is a no-op. If N > 1, it skips over 1 or more instructions.
type RelJumpIfFalse ¶
type RelJumpIfFalse struct {
N int
}
Pop the top of the stack, which must be a boolean value. If it is false, jump N instructions forward in the program. Otherwise, continue as normal.
func (*RelJumpIfFalse) String ¶
func (b *RelJumpIfFalse) String() string
type RelJumpIfFalseOrPop ¶
type RelJumpIfFalseOrPop struct {
N int
}
Pop the top of the stack, which must be a boolean value. If it is false, jump N instructions forward in the program. Otherwise, pop the top of the stack and continue as normal.
func (*RelJumpIfFalseOrPop) String ¶
func (b *RelJumpIfFalseOrPop) String() string
type RelJumpIfTrueOrPop ¶
type RelJumpIfTrueOrPop struct {
N int
}
Pop the top of the stack, which must be a boolean value. If it is true, jump N instructions forward in the program. Otherwise, pop the top of the stack and continue as normal.
func (*RelJumpIfTrueOrPop) String ¶
func (b *RelJumpIfTrueOrPop) String() string
type StoreField ¶
type StoreField struct {
Index int
}
Pop x, y from the stack and store y in x[Index].
func (*StoreField) String ¶
func (b *StoreField) String() string
type StoreIndex ¶
type StoreIndex struct{}
Pop x, y, z from the stack and store z in x[y] where x is a list.
func (*StoreIndex) String ¶
func (b *StoreIndex) String() string
type StoreMapIndex ¶
type StoreMapIndex struct{}
Pop x, y, z from the stack and store z in x[y] where x is a map.
func (*StoreMapIndex) String ¶
func (b *StoreMapIndex) String() string
type StoreName ¶
type StoreName struct {
Name string
}
Pop a value from the stack and store it under `Name` in the current environment.
type UnaryMinus ¶
type UnaryMinus struct{}
Pop x from the stack and push -x.
func (*UnaryMinus) String ¶
func (b *UnaryMinus) String() string
type UnpackTuple ¶
type UnpackTuple struct{}
Assuming the top of the stack is a tuple, pop it and push its contents individually onto the stack, e.g. if the stack is [..., x] and x = (a, b, c), then the stack will be [..., c, b, a].
func (*UnpackTuple) String ¶
func (b *UnpackTuple) String() string