bytecode

package
v0.0.0-...-4a27929 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryAdd

type BinaryAdd struct{}

Pop x, y from the stack and push x + y.

func (*BinaryAdd) String

func (b *BinaryAdd) String() string

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 BinaryEq

type BinaryEq struct{}

Pop x, y from the stack and push x == y.

func (*BinaryEq) String

func (b *BinaryEq) String() string

type BinaryGt

type BinaryGt struct{}

Pop x, y from the stack and push x > y.

func (*BinaryGt) String

func (b *BinaryGt) 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 BinaryIn

type BinaryIn struct{}

Pop x, y from the stack and push x in y.

func (*BinaryIn) String

func (b *BinaryIn) 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 BinaryLt

type BinaryLt struct{}

Pop x, y from the stack and push x < y.

func (*BinaryLt) String

func (b *BinaryLt) 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 BinaryMul

type BinaryMul struct{}

Pop x, y from the stack and push x * y.

func (*BinaryMul) String

func (b *BinaryMul) 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 BinarySub

type BinarySub struct{}

Pop x, y from the stack and push x - y.

func (*BinarySub) String

func (b *BinarySub) String() string

type BuildClass

type BuildClass struct {
	Name string
	N    int
}

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.

func (*BuildList) String

func (b *BuildList) String() string

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.

func (*BuildMap) String

func (b *BuildMap) String() string

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 Bytecode

type Bytecode interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

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 CompiledProgramImport struct {
	Path string
	Name string
}

type DupTop

type DupTop struct{}

Duplicate the value at the top of the stack. This only copies the reference, not the value itself.

func (*DupTop) String

func (b *DupTop) String() string

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.

func (*ForIter) String

func (b *ForIter) String() string

type GetIter

type GetIter struct{}

Pop the top of the stack, convert it into an iterator, and push the iterator onto the stack.

func (*GetIter) String

func (b *GetIter) String() string

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

type PushConstFunction struct {
	Name      string
	IsBuiltin bool
}

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 PushEnum

type PushEnum struct {
	Name string
	N    int
}

Push a constant enum object onto the stack.

func (*PushEnum) String

func (b *PushEnum) 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.

func (*PushField) String

func (b *PushField) String() string

type PushName

type PushName struct {
	Name string
}

Push the value of the given symbol onto the stack.

func (*PushName) String

func (b *PushName) String() string

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.

func (*RelJump) String

func (b *RelJump) String() string

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 Return

type Return struct{}

Return from the current function.

func (*Return) String

func (b *Return) String() string

type RotThree

type RotThree struct{}

Pop x, y, z from the stack and push z, x, y.

func (*RotThree) String

func (b *RotThree) 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.

func (*StoreName) String

func (b *StoreName) String() string

type UnaryMinus

type UnaryMinus struct{}

Pop x from the stack and push -x.

func (*UnaryMinus) String

func (b *UnaryMinus) String() string

type UnaryNot

type UnaryNot struct{}

Pop x from the stack and push not x.

func (*UnaryNot) String

func (b *UnaryNot) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL