value

package
v0.0.0-...-a7237ab Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXCEPTION_BLOCK_RETURN uint8 = iota
	EXCEPTION_BLOCK_BREAK
	EXCEPTION_BLOCK_NEXT
	EXCEPTION_BLOCK_RAISE
)
View Source
const (
	VAL_NIL uint8 = iota
	VAL_TRUE
	VAL_FALSE
	VAL_OBJ
	VAL_INT
	VAL_DOUBLE
	VAL_FUNC
	VAL_CLASS
	VAL_INSTANCE
	VAL_STRING
	VAL_NATIVE
	VAL_ARRAY
	VAL_HASH
	VAL_CALLINFO
	VAL_UPVALUE
	VAL_CLOSURE
)

Variables

View Source
var VALUE_FALSE = Value{Type: VAL_FALSE}
View Source
var VALUE_NIL = Value{Type: VAL_NIL}
View Source
var VALUE_TRUE = Value{Type: VAL_TRUE}

Functions

func IsFalsey

func IsFalsey(v Value) bool

func PrintValue

func PrintValue(v Value)

func ToString

func ToString(v Value) string

Types

type Array

type Array struct {
	Data []Value
}

func NewArray

func NewArray() *Array

func NewArrayFrom

func NewArrayFrom(v []Value) *Array

func (*Array) ToString

func (a *Array) ToString() string

type CallInfo

type CallInfo struct {
	Keys  []string
	Block bool
	Name  string
	Arity uint8
	// inline cache
	Cache InlineCache
}

func (*CallInfo) ArgCount

func (i *CallInfo) ArgCount() int

type Chunk

type Chunk struct {
	Code      []uint8
	Constants []Value
	CallInfos []*CallInfo
}

type Class

type Class struct {
	Name         string
	ID           int
	Methods      map[string]interface{}
	Constants    map[string]Value
	Initializer  interface{}
	Enclosing    *Class
	SuperClass   *Class
	ChildClasses []*Class
}

func NewClass

func NewClass(name string, id int) *Class

func (*Class) IsIncest

func (c *Class) IsIncest(super *Class) bool

func (*Class) NewInstance

func (c *Class) NewInstance() *Instance

func (*Class) SetId

func (c *Class) SetId(id int)

type Closure

type Closure struct {
	*Function
	UpValues []UpValue
}

func NewClosure

func NewClosure(f *Function) *Closure

type DebugInfo

type DebugInfo struct {
	Filename string
	Lines    []OpcodeToLine
}

func (*DebugInfo) FindLine

func (d *DebugInfo) FindLine(opcodeIndex int) int

func (*DebugInfo) InsertDebugInfo

func (d *DebugInfo) InsertDebugInfo(opcodeIndex int, line int)

type ExceptionTable

type ExceptionTable []ExceptionTableEntry

func (ExceptionTable) FindEntry

func (t ExceptionTable) FindEntry(pc int, entryType uint8) (ExceptionTableEntry, bool)

type ExceptionTableEntry

type ExceptionTableEntry struct {
	Start int
	End   int
	Type  uint8
	*Function
}

type Function

type Function struct {
	Chunk
	ParamList
	Name string
	ExceptionTable
	LocalCount   uint8
	UpvalueCount uint8
}

func NewFunction

func NewFunction(name string) *Function

func (*Function) AddCallInfo

func (f *Function) AddCallInfo(i *CallInfo) uint16

func (*Function) AddExceptionBreakEntry

func (f *Function) AddExceptionBreakEntry(start int, end int)

func (*Function) AddExceptionNextEntry

func (f *Function) AddExceptionNextEntry(start int, end int)

func (*Function) AddExceptionRescueEntry

func (f *Function) AddExceptionRescueEntry(start int, end int, fn *Function)

func (*Function) AddExceptionReturnEntry

func (f *Function) AddExceptionReturnEntry(start int, end int)

type Hash

type Hash struct {
	Data map[Value]Value
}

func NewHash

func NewHash() *Hash

func (*Hash) Get

func (h *Hash) Get(k Value) Value

func (*Hash) Insert

func (h *Hash) Insert(k Value, v Value)

func (*Hash) ToString

func (h *Hash) ToString() string

type InlineCache

type InlineCache struct {
	Function interface{} // Function or NativeFunction
	ClassID  int
	Global   bool
}

type Instance

type Instance struct {
	*Class
	IVar map[string]Value
}

func (*Instance) IsInstanceOf

func (i *Instance) IsInstanceOf(c *Class) bool

type Keyword

type Keyword struct {
	Name       string
	DefaultVal Value
}

type NativeFunction

type NativeFunction struct {
	Func func(Value, []Value) Value
	ParamList
	Name string
}

type OpcodeToLine

type OpcodeToLine struct {
	OpcodeStart int
	Line        int
}

type ParamList

type ParamList struct {
	Arity    uint8
	Block    bool
	VarArg   bool
	Keywords []Keyword
}

func (*ParamList) IndexKeyword

func (p *ParamList) IndexKeyword(n string) int

func (*ParamList) NonSimpleArgs

func (p *ParamList) NonSimpleArgs() bool

type UpValue

type UpValue struct {
	Location *Value
	Next     *UpValue
	Closed   Value
}

type Value

type Value struct {
	Type    uint8
	Payload interface{}
}

func DoubleVal

func DoubleVal(d float64) Value

func IntVal

func IntVal(i int) Value

func StringVal

func StringVal(s string) Value

Jump to

Keyboard shortcuts

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