Documentation
¶
Index ¶
- Constants
- Variables
- func Disassemble(sets []*InstructionSet) string
- func SerializeChunk(w io.Writer, main *InstructionSet) error
- type Generator
- type Instruction
- func (i *Instruction) ActionName() string
- func (i *Instruction) AnchorLine() int
- func (i *Instruction) CacheGen() uint32
- func (i *Instruction) CacheVal() Value
- func (i *Instruction) Inspect() string
- func (i *Instruction) Line() int
- func (i *Instruction) SetCache(gen uint32, val Value)
- func (i *Instruction) SourceLine() int
- type InstructionSet
- func (is *InstructionSet) HasTry() bool
- func (is *InstructionSet) LocalsResolved() bool
- func (is *InstructionSet) MarkLocalsResolved()
- func (is *InstructionSet) Name() string
- func (is *InstructionSet) SetHasTry(b bool)
- func (is *InstructionSet) SetSource(name string)
- func (is *InstructionSet) Source() string
- func (is *InstructionSet) Type() string
- type UpvalueDesc
- type Value
Constants ¶
View Source
const ( Program = "ProgramStart" FunctionDef = "Function" )
View Source
const ( LoadNil uint8 = iota LoadTrue LoadFalse LoadInt LoadFloat LoadString LoadVararg Closure GetLocal SetLocal GetUpvalue SetUpvalue GetGlobal SetGlobal NewTable GetTable SetTable GetField SetField Self SetList Add Sub Mul Div FloorDiv Mod Pow Neg BitAnd BitOr BitXor Shl Shr BitNot Concat Len Eq NotEq Lt Le Gt Ge Not Jump JumpIfFalse JumpIfTrue JumpIfFalseKeep JumpIfTrueKeep Call Return ForPrep ForLoop TForCall TForLoop Pop Dup Leave MarkArgs Defer CloseUpvalues Try EndTry Throw MarkTBC CloseTBC JumpIfNil InstructionCount )
View Source
const DefaultChunkName = "script"
View Source
const SerialVersion = 3
Variables ¶
View Source
var InstructionNameTable = []string{ LoadNil: "loadnil", LoadTrue: "loadtrue", LoadFalse: "loadfalse", LoadInt: "loadint", LoadFloat: "loadfloat", LoadString: "loadstring", LoadVararg: "loadvararg", Closure: "closure", GetLocal: "getlocal", SetLocal: "setlocal", GetUpvalue: "getupvalue", SetUpvalue: "setupvalue", GetGlobal: "getglobal", SetGlobal: "setglobal", NewTable: "newtable", GetTable: "gettable", SetTable: "settable", GetField: "getfield", SetField: "setfield", Self: "self", SetList: "setlist", Add: "add", Sub: "sub", Mul: "mul", Div: "div", FloorDiv: "floordiv", Mod: "mod", Pow: "pow", Neg: "neg", BitAnd: "band", BitOr: "bor", BitXor: "bxor", Shl: "shl", Shr: "shr", BitNot: "bnot", Concat: "concat", Len: "len", Eq: "eq", NotEq: "neq", Lt: "lt", Le: "le", Gt: "gt", Ge: "ge", Not: "not", Jump: "jump", JumpIfFalse: "jumpiffalse", JumpIfTrue: "jumpiftrue", JumpIfFalseKeep: "jumpiffalsekeep", JumpIfTrueKeep: "jumpiftruekeep", Call: "call", Return: "return", ForPrep: "forprep", ForLoop: "forloop", TForCall: "tforcall", TForLoop: "tforloop", Pop: "pop", Dup: "dup", Leave: "leave", MarkArgs: "markargs", CloseUpvalues: "closeupvalues", Defer: "defer", Try: "try", EndTry: "endtry", Throw: "throw", MarkTBC: "marktbc", CloseTBC: "closetbc", JumpIfNil: "jumpifnil", }
Functions ¶
func Disassemble ¶
func Disassemble(sets []*InstructionSet) string
func SerializeChunk ¶
func SerializeChunk(w io.Writer, main *InstructionSet) error
Types ¶
type Generator ¶
type Generator struct {
REPL bool
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator() *Generator
func (*Generator) GenerateInstructions ¶
func (g *Generator) GenerateInstructions(stmts []ast.Statement) []*InstructionSet
func (*Generator) InitTopLevelScope ¶
func (*Generator) ResetInstructionSets ¶
func (g *Generator) ResetInstructionSets()
type Instruction ¶
type Instruction struct {
Opcode uint8
A int32
B int32
BoxedAny any
StrA string
Params []any
// contains filtered or unexported fields
}
func (*Instruction) ActionName ¶
func (i *Instruction) ActionName() string
func (*Instruction) AnchorLine ¶
func (i *Instruction) AnchorLine() int
func (*Instruction) CacheGen ¶
func (i *Instruction) CacheGen() uint32
func (*Instruction) CacheVal ¶
func (i *Instruction) CacheVal() Value
func (*Instruction) Inspect ¶
func (i *Instruction) Inspect() string
func (*Instruction) Line ¶
func (i *Instruction) Line() int
func (*Instruction) SetCache ¶
func (i *Instruction) SetCache(gen uint32, val Value)
func (*Instruction) SourceLine ¶
func (i *Instruction) SourceLine() int
type InstructionSet ¶
type InstructionSet struct {
Instructions []*Instruction
NumParams int
IsVararg bool
NumLocals int
Upvalues []UpvalueDesc
Constants []any
Protos []*InstructionSet
// contains filtered or unexported fields
}
func DeserializeChunk ¶
func DeserializeChunk(r io.Reader) (*InstructionSet, error)
func (*InstructionSet) HasTry ¶
func (is *InstructionSet) HasTry() bool
func (*InstructionSet) LocalsResolved ¶
func (is *InstructionSet) LocalsResolved() bool
func (*InstructionSet) MarkLocalsResolved ¶
func (is *InstructionSet) MarkLocalsResolved()
func (*InstructionSet) Name ¶
func (is *InstructionSet) Name() string
func (*InstructionSet) SetHasTry ¶
func (is *InstructionSet) SetHasTry(b bool)
func (*InstructionSet) SetSource ¶
func (is *InstructionSet) SetSource(name string)
func (*InstructionSet) Source ¶
func (is *InstructionSet) Source() string
func (*InstructionSet) Type ¶
func (is *InstructionSet) Type() string
type UpvalueDesc ¶
Click to show internal directories.
Click to hide internal directories.