Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterExternalClass(path string, c ...ClassLoader)
- type ArrayObject
- func (a *ArrayObject) EqualTo(compared Object) bool
- func (a *ArrayObject) Inspect(t *Thread) string
- func (a *ArrayObject) Len() int
- func (a *ArrayObject) Less(i, j int) bool
- func (a *ArrayObject) Swap(i, j int)
- func (a *ArrayObject) ToJSON(t *Thread) string
- func (a *ArrayObject) ToString(t *Thread) string
- func (a *ArrayObject) Value() interface{}
- type BaseObj
- func (b *BaseObj) Class() *RClass
- func (b *BaseObj) EqualTo(with Object) bool
- func (b *BaseObj) FindLookup(searchAncestor bool) (method Object)
- func (b *BaseObj) FindMethod(methodName string, super bool) (method Object)
- func (b *BaseObj) GetVariable(name string) (Object, bool)
- func (b *BaseObj) Inspect(t *Thread) string
- func (b *BaseObj) IsTruthy() bool
- func (b *BaseObj) SetVariable(name string, value Object) Object
- func (b *BaseObj) SetVariables(e Environment)
- func (b *BaseObj) ToJSON(t *Thread) string
- func (b *BaseObj) ToString(t *Thread) string
- func (b *BaseObj) Value() interface{}
- func (b *BaseObj) Variables() Environment
- type BlockObject
- type BooleanObject
- func (b BooleanObject) Class() *RClass
- func (b BooleanObject) EqualTo(with Object) bool
- func (b BooleanObject) FindLookup(searchAncestor bool) (method Object)
- func (b BooleanObject) FindMethod(methodName string, super bool) Object
- func (b BooleanObject) GetVariable(string) (Object, bool)
- func (b BooleanObject) Inspect(t *Thread) string
- func (b BooleanObject) IsTruthy() bool
- func (b BooleanObject) SetVariable(n string, o Object) Object
- func (b BooleanObject) SetVariables(Environment)
- func (b BooleanObject) ToJSON(t *Thread) string
- func (b BooleanObject) ToString(t *Thread) string
- func (b BooleanObject) Value() interface{}
- func (b BooleanObject) Variables() Environment
- type BuiltinMethodObject
- type CallFrame
- type ChannelObject
- type ClassInitFunc
- type ClassLoader
- type ConfigFunc
- type Environment
- type Error
- type FileObject
- type FloatObject
- func (f FloatObject) Class() *RClass
- func (f FloatObject) EqualTo(rightObject Object) bool
- func (f FloatObject) FindLookup(searchAncestor bool) (method Object)
- func (f FloatObject) FindMethod(methodName string, super bool) (method Object)
- func (f FloatObject) GetVariable(string) (Object, bool)
- func (f FloatObject) Inspect(t *Thread) string
- func (f FloatObject) IsTruthy() bool
- func (f FloatObject) SetVariable(string, Object) Object
- func (f FloatObject) SetVariables(Environment)
- func (f FloatObject) ToJSON(t *Thread) string
- func (f FloatObject) ToString(t *Thread) string
- func (f FloatObject) Value() interface{}
- func (f FloatObject) Variables() Environment
- type GoObject
- type HashObject
- type IntegerObject
- func (i IntegerObject) Class() *RClass
- func (i IntegerObject) EqualTo(rightObject Object) bool
- func (i IntegerObject) FindLookup(searchAncestor bool) (method Object)
- func (i IntegerObject) FindMethod(methodName string, super bool) Object
- func (i IntegerObject) GetVariable(string) (Object, bool)
- func (i IntegerObject) Inspect(t *Thread) string
- func (i IntegerObject) IsTruthy() bool
- func (i IntegerObject) SetVariable(n string, o Object) Object
- func (i IntegerObject) SetVariables(Environment)
- func (i IntegerObject) ToJSON(t *Thread) string
- func (i IntegerObject) ToString(t *Thread) string
- func (i IntegerObject) Value() interface{}
- func (i IntegerObject) Variables() Environment
- type LockObject
- type Method
- type MethodObject
- type NilObject
- type Numeric
- type Object
- type Pointer
- type RClass
- func (c *RClass) ClassMethods(methodList []*BuiltinMethodObject) *RClass
- func (c *RClass) EqualTo(with Object) bool
- func (c *RClass) FindLookup(searchAncestor bool) (method Object)
- func (c *RClass) FindMethod(methodName string, super bool) (method Object)
- func (c *RClass) Inspect(t *Thread) string
- func (c *RClass) InstanceMethods(methodList []*BuiltinMethodObject) *RClass
- func (c *RClass) MetaClass() *RClass
- func (c *RClass) SetClassConstant(constant *RClass)
- func (c *RClass) SetConstant(name string, constant Object) *RClass
- func (c *RClass) SetMetaClass(m *RClass)
- func (c *RClass) ToJSON(t *Thread) string
- func (c *RClass) ToString(t *Thread) string
- func (c *RClass) Value() interface{}
- type RObject
- type RangeObject
- type Regexp
- type RegexpObject
- type Stack
- type StringObject
- func (s StringObject) Class() *RClass
- func (s StringObject) EqualTo(compared Object) bool
- func (s StringObject) FindLookup(searchAncestor bool) (method Object)
- func (s StringObject) FindMethod(methodName string, super bool) (method Object)
- func (s StringObject) GetVariable(string) (Object, bool)
- func (s StringObject) Inspect(t *Thread) string
- func (s StringObject) IsTruthy() bool
- func (s StringObject) SetVariable(n string, o Object) Object
- func (s StringObject) SetVariables(Environment)
- func (s StringObject) ToJSON(t *Thread) string
- func (s StringObject) ToString(t *Thread) string
- func (s StringObject) Value() interface{}
- func (s StringObject) Variables() Environment
- type Thread
- func (t *Thread) BlockGiven() bool
- func (t *Thread) FindAndExecute(receiver Object, methodName string, super bool, receiverPr int, argPr int, ...)
- func (t *Thread) GetBlock() *CallFrame
- func (t *Thread) GetSourceLine() int
- func (t *Thread) VM() *VM
- func (t *Thread) Yield(blockFrame *CallFrame, args ...Object) Object
- func (t *Thread) YieldWithBlockArgument(blockFrame *CallFrame, block *CallFrame, args ...Object) Object
- type VM
- func (vm *VM) AddLibrary(libs ...string)
- func (vm *VM) CurrentFilePath() string
- func (vm *VM) ExecInstructions(sets []*bytecode.InstructionSet, fn string)
- func (vm *VM) GetBaseFrame() *CallFrame
- func (vm *VM) GetExecResult() Object
- func (vm *VM) GetREPLResult() string
- func (vm *VM) InitClass(name string) *RClass
- func (vm *VM) InitErrorObject(t *Thread, errorType string, format string, args ...interface{}) *Error
- func (vm *VM) InitForREPL()
- func (vm *VM) InitGoTypeFromObject(value Object) interface{}
- func (vm *VM) InitModule(name string) *RClass
- func (vm *VM) InitNoMethodError(t *Thread, methodName string, receiver Object) *Error
- func (vm *VM) InitObjectFromGoType(value interface{}) Object
- func (vm *VM) REPLExec(sets []*bytecode.InstructionSet)
- func (vm *VM) TopLevelClass(cn string) *RClass
- type WaitGroupObject
Constants ¶
const ( // TRUE is shared boolean object that represents true TRUE = BooleanObject(true) // FALSE is shared boolean object that represents false FALSE = BooleanObject(false) )
const FileExt = "lito"
FileExt stores the default extension
const Version = "0.2.1"
Version stores current Lito version
Variables ¶
var DefaultLibPath string
DefaultLibPath is used for overriding vm.libpath build-time.
var MachineConfigs = map[string]ConfigFunc{
"standard": standard,
"sandbox": sandbox,
}
MachineConfigs a list of different machine configurations
Functions ¶
func RegisterExternalClass ¶
func RegisterExternalClass(path string, c ...ClassLoader)
RegisterExternalClass will add the given class to the global registery of available classes
Types ¶
type ArrayObject ¶
ArrayObject represents an instance of Array class.
func InitArrayObject ¶
func InitArrayObject(elements []Object) *ArrayObject
InitArrayObject returns a new object with the given elemnts
func StringObjectSplit ¶
func StringObjectSplit(vm *VM, s string, sep string) *ArrayObject
StringObjectSplit returns an ArrayObject with the split strings
func (*ArrayObject) EqualTo ¶
func (a *ArrayObject) EqualTo(compared Object) bool
EqualTo returns if the ArrayObject is equal to another object
func (*ArrayObject) Inspect ¶
func (a *ArrayObject) Inspect(t *Thread) string
Inspect returns the inspection of the Array
func (*ArrayObject) Len ¶
func (a *ArrayObject) Len() int
Len returns the length of array's elements
func (*ArrayObject) Less ¶
func (a *ArrayObject) Less(i, j int) bool
Less is one of the required method to fulfill sortable interface
func (*ArrayObject) Swap ¶
func (a *ArrayObject) Swap(i, j int)
Swap is one of the required method to fulfill sortable interface
func (*ArrayObject) ToJSON ¶
func (a *ArrayObject) ToJSON(t *Thread) string
ToJSON returns the object's elements as the JSON string format
func (*ArrayObject) ToString ¶
func (a *ArrayObject) ToString(t *Thread) string
ToString returns the object's elements as the string format
func (*ArrayObject) Value ¶
func (a *ArrayObject) Value() interface{}
Value returns the elements from the object
type BaseObj ¶
type BaseObj struct {
// contains filtered or unexported fields
}
BaseObj ...
func BaseObject ¶
BaseObject returns a base obj with the given class
func (*BaseObj) FindLookup ¶
FindLookup ...
func (*BaseObj) FindMethod ¶
FindMethod returns the method with the corresponding name
func (*BaseObj) GetVariable ¶
GetVariable gets an instance variable from the object
func (*BaseObj) SetVariable ¶
SetVariable sets an instance variable on the object
func (*BaseObj) SetVariables ¶
func (b *BaseObj) SetVariables(e Environment)
SetVariables sets the variables in the supplied environment
func (*BaseObj) Variables ¶
func (b *BaseObj) Variables() Environment
Variables returns the current Environment for the object
type BlockObject ¶
type BlockObject struct { BaseObj // contains filtered or unexported fields }
BlockObject represents an instance of `Block` class.
func (*BlockObject) Inspect ¶
func (bo *BlockObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*BlockObject) ToJSON ¶
func (bo *BlockObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*BlockObject) ToString ¶
func (bo *BlockObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type BooleanObject ¶
type BooleanObject bool
BooleanObject represents boolean object in Lito. `Boolean` class is just a dummy to hold logical `true` and `false` representation and no other active usage.
func (BooleanObject) Class ¶
func (b BooleanObject) Class() *RClass
Class returns the built-in Boolean class
func (BooleanObject) EqualTo ¶
func (b BooleanObject) EqualTo(with Object) bool
EqualTo returns if the BooleanObject is equal to another object
func (BooleanObject) FindLookup ¶
func (b BooleanObject) FindLookup(searchAncestor bool) (method Object)
FindLookup ...
func (BooleanObject) FindMethod ¶
func (b BooleanObject) FindMethod(methodName string, super bool) Object
FindMethod ...
func (BooleanObject) GetVariable ¶
func (b BooleanObject) GetVariable(string) (Object, bool)
GetVariable does nothing as Booleans cannot have variables
func (BooleanObject) Inspect ¶
func (b BooleanObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (BooleanObject) IsTruthy ¶
func (b BooleanObject) IsTruthy() bool
IsTruthy returns the boolean value of the object
func (BooleanObject) SetVariable ¶
func (b BooleanObject) SetVariable(n string, o Object) Object
SetVariable does nothing as Booleans cannot have variables
func (BooleanObject) SetVariables ¶
func (b BooleanObject) SetVariables(Environment)
SetVariables ...
func (BooleanObject) ToJSON ¶
func (b BooleanObject) ToJSON(t *Thread) string
ToJSON just delegates to `ToString`
func (BooleanObject) ToString ¶
func (b BooleanObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type BuiltinMethodObject ¶
BuiltinMethodObject represents methods defined in go.
func ExternalBuiltinMethod ¶
func ExternalBuiltinMethod(name string, m Method) *BuiltinMethodObject
ExternalBuiltinMethod is a function that builds a BuiltinMethodObject from an external function
func (*BuiltinMethodObject) Inspect ¶
func (bim *BuiltinMethodObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*BuiltinMethodObject) ToJSON ¶
func (bim *BuiltinMethodObject) ToJSON(t *Thread) string
ToJSON just delegates to `ToString`
func (*BuiltinMethodObject) ToString ¶
func (bim *BuiltinMethodObject) ToString(t *Thread) string
ToString returns the object's name as the string format
func (*BuiltinMethodObject) Value ¶
func (bim *BuiltinMethodObject) Value() interface{}
Value returns builtin method object's function
type CallFrame ¶
CallFrame structure to hold a callframe
func (*CallFrame) BlockFrame ¶
func (cf *CallFrame) BlockFrame() *CallFrame
func (*CallFrame) SourceLine ¶
func (cf *CallFrame) SourceLine() int
type ChannelObject ¶
ChannelObject represents a Golang channel.
func (*ChannelObject) Inspect ¶
func (co *ChannelObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*ChannelObject) ToJSON ¶
func (co *ChannelObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*ChannelObject) ToString ¶
func (co *ChannelObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type ClassInitFunc ¶
ClassInitFunc initialises a class for the vm
type ClassLoader ¶
ClassLoader can be registered with a vm so that it can load this library at vm creation
func ExternalClass ¶
func ExternalClass(name, path string, classMethods, instanceMethods map[string]Method) ClassLoader
ExternalClass helps define external go classes
type ConfigFunc ¶
ConfigFunc can be registered with a vm so that it can load this library at vm creation
func LibraryPath ¶
func LibraryPath(path string) ConfigFunc
LibraryPath set the path to the libraries
type Environment ¶
Environment stores a set of Objects addressable by name
func (Environment) EqualTo ¶
func (e Environment) EqualTo(other Environment) bool
EqualTo returns if the Environment is equal to another Environment
type Error ¶
type Error struct { BaseObj Type string Ignore bool Raised bool // contains filtered or unexported fields }
Error class is a struct to hold internal error types with messages.
type FileObject ¶
FileObject is a special type that contains file pointer so we can keep track on target file. Using `File.open` with block is recommended because the instance (block variable) automatically closes.
func (*FileObject) Inspect ¶
func (f *FileObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*FileObject) ToJSON ¶
func (f *FileObject) ToJSON(t *Thread) string
ToJSON just delegates to `ToString`
func (*FileObject) ToString ¶
func (f *FileObject) ToString(t *Thread) string
ToString returns the object's name as the string format
func (*FileObject) Value ¶
func (f *FileObject) Value() interface{}
Value returns file object's string format
type FloatObject ¶
type FloatObject float64
FloatObject represents a real number
func (FloatObject) EqualTo ¶
func (f FloatObject) EqualTo(rightObject Object) bool
EqualTo apply an equality test, returning true if the objects are considered equal, and false otherwise.
func (FloatObject) FindLookup ¶
func (f FloatObject) FindLookup(searchAncestor bool) (method Object)
FindLookup ...
func (FloatObject) FindMethod ¶
func (f FloatObject) FindMethod(methodName string, super bool) (method Object)
FindMethod ...
func (FloatObject) GetVariable ¶
func (f FloatObject) GetVariable(string) (Object, bool)
GetVariable ...
func (FloatObject) Inspect ¶
func (f FloatObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (FloatObject) SetVariable ¶
func (f FloatObject) SetVariable(string, Object) Object
SetVariable ...
func (FloatObject) ToJSON ¶
func (f FloatObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString Converts NaN and Inf to null, as these are not supported in the JSON spec
func (FloatObject) ToString ¶
func (f FloatObject) ToString(t *Thread) string
ToString returns the object's value as the string format
type GoObject ¶
type GoObject struct { BaseObj // contains filtered or unexported fields }
GoObject is used to hold opaque Golang values that cannot be converted to Objects
type HashObject ¶
HashObject represents a map instance. TODO: Think about a new representation for this
func InitHashObject ¶
func InitHashObject(pairs map[string]Object) *HashObject
InitHashObject initialise the HashObject
func (*HashObject) EqualTo ¶
func (h *HashObject) EqualTo(with Object) bool
EqualTo returns true if the HashObject is equal to the given Object
func (*HashObject) Inspect ¶
func (h *HashObject) Inspect(t *Thread) string
Inspect returns the inspection of the object
func (*HashObject) ToJSON ¶
func (h *HashObject) ToJSON(t *Thread) string
ToJSON returns the object's name as the JSON string format
func (*HashObject) ToString ¶
func (h *HashObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type IntegerObject ¶
type IntegerObject int
IntegerObject represents number objects which can bring into mathematical calculations.
func (IntegerObject) EqualTo ¶
func (i IntegerObject) EqualTo(rightObject Object) bool
EqualTo apply an equality test, returning true if the objects are considered equal, and false otherwise.
func (IntegerObject) FindLookup ¶
func (i IntegerObject) FindLookup(searchAncestor bool) (method Object)
FindLookup ...
func (IntegerObject) FindMethod ¶
func (i IntegerObject) FindMethod(methodName string, super bool) Object
FindMethod ...
func (IntegerObject) GetVariable ¶
func (i IntegerObject) GetVariable(string) (Object, bool)
GetVariable ...
func (IntegerObject) Inspect ¶
func (i IntegerObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (IntegerObject) SetVariable ¶
func (i IntegerObject) SetVariable(n string, o Object) Object
SetVariable ...
func (IntegerObject) SetVariables ¶
func (i IntegerObject) SetVariables(Environment)
SetVariables ...
func (IntegerObject) ToJSON ¶
func (i IntegerObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (IntegerObject) ToString ¶
func (i IntegerObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type LockObject ¶
type LockObject struct { BaseObj // contains filtered or unexported fields }
LockObject is a Golang Lock.
func (*LockObject) Inspect ¶
func (lock *LockObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*LockObject) ToJSON ¶
func (lock *LockObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*LockObject) ToString ¶
func (lock *LockObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type Method ¶
Method is a callable function
func NoSuchMethod ¶
NoSuchMethod convenience function for when the method does not exist
type MethodObject ¶
MethodObject represents methods defined using Lito.
func (*MethodObject) Inspect ¶
func (m *MethodObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*MethodObject) ToJSON ¶
func (m *MethodObject) ToJSON(t *Thread) string
ToJSON returns the method as a JSON string
func (*MethodObject) ToString ¶
func (m *MethodObject) ToString(t *Thread) string
ToString returns a string representation of the method
func (*MethodObject) Value ¶
func (m *MethodObject) Value() interface{}
Value returns method object's string format
type NilObject ¶
type NilObject struct {
BaseObj
}
NilObject (`nil`) represents the nil value in Lito. `nil` is converted into `null` when exported to JSON format.
var ( // NIL represents Lito's nil object. This is a singleton value // and can be compared using ==. NIL *NilObject )
func (*NilObject) EqualTo ¶
EqualTo returns if the NilObject is equal to another object. This will only return true if the other object is NIL
type Numeric ¶
type Numeric interface {
// contains filtered or unexported methods
}
Numeric represents a class that support numeric conversion to float.
type Object ¶
type Object interface { Class() *RClass Value() interface{} FindMethod(string, bool) Object FindLookup(bool) Object ToString(t *Thread) string Inspect(t *Thread) string ToJSON(t *Thread) string GetVariable(string) (Object, bool) SetVariable(string, Object) Object Variables() Environment SetVariables(Environment) IsTruthy() bool EqualTo(Object) bool }
Object represents all objects in Lito, including Array, Integer or even Method and Error.
type Pointer ¶
type Pointer struct {
Target Object
}
Pointer is used to point to an object. Variables should hold pointer instead of holding a object directly.
type RClass ¶
type RClass struct { BaseObj // Name is the class's name Name string // Methods contains its instances' methods Methods Environment // contains filtered or unexported fields }
RClass represents normal (not built in) class object
func (*RClass) ClassMethods ¶
func (c *RClass) ClassMethods(methodList []*BuiltinMethodObject) *RClass
ClassMethods adds the class methods to the class's metaclass
func (*RClass) FindLookup ¶
FindLookup ...
func (*RClass) FindMethod ¶
FindMethod ...
func (*RClass) InstanceMethods ¶
func (c *RClass) InstanceMethods(methodList []*BuiltinMethodObject) *RClass
InstanceMethods adds the instance methods to the class
func (*RClass) SetClassConstant ¶
SetClassConstant adds a class to the class's constants. Name is take from the class name of the supplied parameter.
func (*RClass) SetConstant ¶
SetConstant adds the constant to the class's constants, with the given name.
func (*RClass) SetMetaClass ¶
SetMetaClass sets object's metaclass
type RObject ¶
type RObject struct {
BaseObj
}
RObject represents any non built-in class's instance.
type RangeObject ¶
RangeObject is the built in range class Range represents an interval: a set of values from the beginning to the end specified. Currently, only Integer objects or integer literal are supported.
func (*RangeObject) EqualTo ¶
func (ro *RangeObject) EqualTo(with Object) bool
EqualTo returns if the RangeObject is equal to another object
func (*RangeObject) Inspect ¶
func (ro *RangeObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*RangeObject) ToJSON ¶
func (ro *RangeObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*RangeObject) ToString ¶
func (ro *RangeObject) ToString(t *Thread) string
ToString returns the object's name as the string format
func (*RangeObject) Value ¶
func (ro *RangeObject) Value() interface{}
Value returns range object's string format
type RegexpObject ¶
type RegexpObject struct { BaseObj // contains filtered or unexported fields }
RegexpObject represents regexp instances, which of the type is actually string.
func (*RegexpObject) EqualTo ¶
func (r *RegexpObject) EqualTo(with Object) bool
EqualTo returns true if the RegexpObject is equal to the other object
func (*RegexpObject) Inspect ¶
func (r *RegexpObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*RegexpObject) ToJSON ¶
func (r *RegexpObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*RegexpObject) ToString ¶
func (r *RegexpObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is a basic stack implementation
type StringObject ¶
type StringObject string
StringObject represents string instances.
func (StringObject) EqualTo ¶
func (s StringObject) EqualTo(compared Object) bool
EqualTo returns if the StringObject is equal to another object
func (StringObject) FindLookup ¶
func (s StringObject) FindLookup(searchAncestor bool) (method Object)
FindLookup returns the lookup! method for a StringObject, if any
func (StringObject) FindMethod ¶
func (s StringObject) FindMethod(methodName string, super bool) (method Object)
FindMethod ...
func (StringObject) GetVariable ¶
func (s StringObject) GetVariable(string) (Object, bool)
GetVariable does nothing as Strings cannot have variables
func (StringObject) Inspect ¶
func (s StringObject) Inspect(t *Thread) string
Inspect wraps ToString with double quotes
func (StringObject) SetVariable ¶
func (s StringObject) SetVariable(n string, o Object) Object
SetVariable does nothing as Strings cannot have variables
func (StringObject) ToJSON ¶
func (s StringObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (StringObject) ToString ¶
func (s StringObject) ToString(t *Thread) string
ToString returns the object's name as the string format
type Thread ¶
type Thread struct { // data Stack Stack Stack // contains filtered or unexported fields }
Thread is the context needed for a single thread of execution
func (*Thread) BlockGiven ¶
BlockGiven returns whether or not we have a block frame below us in the stack
func (*Thread) FindAndExecute ¶
func (t *Thread) FindAndExecute(receiver Object, methodName string, super bool, receiverPr int, argPr int, argCount int, argSet *bytecode.ArgSet, blockFrame *CallFrame, fileName string)
FindAndExecute finds and executes a method
func (*Thread) GetSourceLine ¶
GetSourceLine returns the current source line
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM represents a stack based virtual machine.
func New ¶
func New(fileDir string, args []string, configs ...ConfigFunc) (vm *VM, err error)
New initialises a vm to initial state and returns it.
func (*VM) AddLibrary ¶
AddLibrary adds library files to be loaded by the VM
func (*VM) CurrentFilePath ¶
CurrentFilePath returns the current file name
func (*VM) ExecInstructions ¶
func (vm *VM) ExecInstructions(sets []*bytecode.InstructionSet, fn string)
ExecInstructions accepts a sequence of bytecodes and use vm to evaluate them. We also pass in the file name for use in stack traces
func (*VM) GetBaseFrame ¶
GetBaseFrame returns the bottom frame for use by the REPL
func (*VM) GetExecResult ¶
GetExecResult returns stack's top most value. Normally it's used in tests.
func (*VM) GetREPLResult ¶
GetREPLResult returns a string that should be shown after each evaluation.
func (*VM) InitClass ¶
InitClass is a common function for vm, which initialises and returns a class instance with given class name.
func (*VM) InitErrorObject ¶
func (vm *VM) InitErrorObject(t *Thread, errorType string, format string, args ...interface{}) *Error
InitErrorObject is to initialise and return an error object.
func (*VM) InitForREPL ¶
func (vm *VM) InitForREPL()
InitForREPL does following things: - Set vm to REPL mode - Create and push main object frame
func (*VM) InitGoTypeFromObject ¶
InitGoTypeFromObject returns an object that can be used from Lito
func (*VM) InitModule ¶
InitModule creates a new module with the given name
func (*VM) InitNoMethodError ¶
InitNoMethodError is to print unsupported method errors. This is exported for using from sub-packages.
func (*VM) InitObjectFromGoType ¶
InitObjectFromGoType returns an object that can be used from Lito
func (*VM) REPLExec ¶
func (vm *VM) REPLExec(sets []*bytecode.InstructionSet)
REPLExec executes instructions differently from normal program execution.
func (*VM) TopLevelClass ¶
TopLevelClass returns the class for a given name
type WaitGroupObject ¶
WaitGroupObject represents a Golang WaitGroup.
func (*WaitGroupObject) Inspect ¶
func (co *WaitGroupObject) Inspect(t *Thread) string
Inspect delegates to ToString
func (*WaitGroupObject) ToJSON ¶
func (co *WaitGroupObject) ToJSON(t *Thread) string
ToJSON just delegates to ToString
func (*WaitGroupObject) ToString ¶
func (co *WaitGroupObject) ToString(t *Thread) string
ToString returns the object's name as the string format
func (*WaitGroupObject) Value ¶
func (co *WaitGroupObject) Value() interface{}
Value returns the object
Source Files ¶
- array.go
- base_object.go
- block.go
- boolean.go
- call_frame.go
- call_object.go
- channel.go
- class.go
- conversion.go
- environment.go
- error.go
- file.go
- float.go
- go_object.go
- hash.go
- inspection_methods.go
- instance.go
- instruction.go
- integer.go
- json.go
- lock.go
- method_builtin.go
- method_object.go
- null.go
- numeric.go
- object.go
- pointer.go
- range.go
- regexp.go
- repl.go
- spec.go
- stack.go
- string.go
- system.go
- thread.go
- vm.go
- waitgroup.go