Documentation ¶
Index ¶
- Variables
- func ArrayToStringSlice(a *Array) []string
- func InstanceOf(class string, i *Instance) bool
- func InstanceOfAny(instance Object, classes ...string) bool
- func IsConstErr(e error) bool
- func ObjectIs(o Object, t ...ObjectType) bool
- func ObjectsAre(t ObjectType, o ...Object) bool
- type Array
- type Boolean
- type Builtin
- type BuiltinFunction
- type BuiltinMethod
- type BuiltinMethodFunction
- type Class
- type ClassMethod
- type Environment
- func (e *Environment) Clone() *Environment
- func (e *Environment) Create(name string, val Object) (Object, error)
- func (e *Environment) CreateConst(name string, val Object) (Object, error)
- func (e *Environment) Get(name string) (Object, bool)
- func (e *Environment) GetLocal(name string) (Object, bool)
- func (e *Environment) IsConst(name string) bool
- func (e *Environment) IsConstLocal(name string) bool
- func (e *Environment) Parent() *Environment
- func (e *Environment) Print(indent string)
- func (e *Environment) Set(name string, val Object) (Object, error)
- func (e *Environment) SetForce(name string, val Object, readonly bool)
- func (e *Environment) SetLocal(name string, val Object) (Object, error)
- func (e *Environment) SetParent(env *Environment)
- func (e *Environment) Unset(name string)
- func (e *Environment) UnsetLocal(name string)
- type Error
- type Exception
- type Float
- type Function
- type Hash
- type HashKey
- type HashPair
- type Hashable
- type IfaceMethodDef
- type Instance
- type Integer
- type Interface
- type Interpreter
- type LoopControl
- type Module
- type Null
- type Object
- type ObjectType
- type ReturnValue
- type Stack
- type String
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NullConst = &Null{} TrueConst = &Boolean{Value: true} FalseConst = &Boolean{Value: false} )
These are all constants in the language that can be represented with a single instance
Functions ¶
func ArrayToStringSlice ¶
func InstanceOf ¶
func InstanceOfAny ¶
func IsConstErr ¶
func ObjectIs ¶
func ObjectIs(o Object, t ...ObjectType) bool
func ObjectsAre ¶
func ObjectsAre(t ObjectType, o ...Object) bool
Types ¶
type Array ¶
type Array struct {
Elements []Object
}
func MakeStringArray ¶
func (*Array) Type ¶
func (a *Array) Type() ObjectType
type Boolean ¶
type Boolean struct {
Value bool
}
func NativeBoolToBooleanObj ¶
func (*Boolean) Type ¶
func (b *Boolean) Type() ObjectType
type Builtin ¶
type Builtin struct {
Fn BuiltinFunction
}
func (*Builtin) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
type BuiltinFunction func(i Interpreter, env *Environment, args ...Object) Object
type BuiltinMethod ¶
type BuiltinMethod struct { Fn BuiltinMethodFunction Instance *Instance }
func MakeBuiltinMethod ¶
func MakeBuiltinMethod(fn BuiltinMethodFunction) *BuiltinMethod
func (*BuiltinMethod) ClassMethod ¶
func (b *BuiltinMethod) ClassMethod()
func (*BuiltinMethod) Dup ¶
func (b *BuiltinMethod) Dup() Object
func (*BuiltinMethod) Inspect ¶
func (b *BuiltinMethod) Inspect() string
func (*BuiltinMethod) Type ¶
func (b *BuiltinMethod) Type() ObjectType
type BuiltinMethodFunction ¶
type BuiltinMethodFunction func(i Interpreter, self *Instance, env *Environment, args ...Object) Object
type Class ¶
type Class struct { Name string Parent *Class Fields []*ast.DefStatement Methods map[string]ClassMethod }
func (*Class) GetMethod ¶
func (c *Class) GetMethod(name string) ClassMethod
func (*Class) Type ¶
func (c *Class) Type() ObjectType
type ClassMethod ¶
type ClassMethod interface { Object ClassMethod() }
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func NewEnclosedEnv ¶
func NewEnclosedEnv(outer *Environment) *Environment
func NewEnvironment ¶
func NewEnvironment() *Environment
func NewSizedEnclosedEnv ¶
func NewSizedEnclosedEnv(outer *Environment, size int) *Environment
func NewSizedEnvironment ¶
func NewSizedEnvironment(size int) *Environment
func (*Environment) Clone ¶
func (e *Environment) Clone() *Environment
func (*Environment) CreateConst ¶
func (e *Environment) CreateConst(name string, val Object) (Object, error)
func (*Environment) IsConst ¶
func (e *Environment) IsConst(name string) bool
func (*Environment) IsConstLocal ¶
func (e *Environment) IsConstLocal(name string) bool
func (*Environment) Parent ¶
func (e *Environment) Parent() *Environment
func (*Environment) Print ¶
func (e *Environment) Print(indent string)
func (*Environment) SetForce ¶
func (e *Environment) SetForce(name string, val Object, readonly bool)
func (*Environment) SetLocal ¶
func (e *Environment) SetLocal(name string, val Object) (Object, error)
func (*Environment) SetParent ¶
func (e *Environment) SetParent(env *Environment)
func (*Environment) Unset ¶
func (e *Environment) Unset(name string)
func (*Environment) UnsetLocal ¶
func (e *Environment) UnsetLocal(name string)
type Error ¶
type Error struct {
Message string
}
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type Exception ¶
TODO: Expand with line/column numbers and stack trace
func NewException ¶
func (*Exception) Type ¶
func (e *Exception) Type() ObjectType
type Float ¶
type Float struct {
Value float64
}
func MakeFloatObj ¶
func (*Float) Type ¶
func (f *Float) Type() ObjectType
type Function ¶
type Function struct { Name string Parameters []*ast.Identifier Body *ast.BlockStatement Env *Environment Instance *Instance }
func (*Function) ClassMethod ¶
func (f *Function) ClassMethod()
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type Hash ¶
func MakeEmptyHash ¶
func MakeEmptyHash() *Hash
func StringMapToHash ¶
func (*Hash) Type ¶
func (h *Hash) Type() ObjectType
type HashKey ¶
type HashKey struct { Type ObjectType Value uint64 }
type IfaceMethodDef ¶
func (*IfaceMethodDef) Inspect ¶
func (i *IfaceMethodDef) Inspect() string
type Instance ¶
type Instance struct { Class *Class Fields *Environment }
func GetSelf ¶
func GetSelf(env *Environment) *Instance
func (*Instance) GetMethod ¶
func (i *Instance) GetMethod(name string) ClassMethod
func (*Instance) Type ¶
func (i *Instance) Type() ObjectType
type Integer ¶
type Integer struct {
Value int64
}
func MakeIntObj ¶
func (*Integer) Type ¶
func (i *Integer) Type() ObjectType
type Interface ¶
type Interface struct { Name string Methods map[string]*IfaceMethodDef }
func (*Interface) GetMethod ¶
func (i *Interface) GetMethod(name string) *IfaceMethodDef
func (*Interface) Type ¶
func (i *Interface) Type() ObjectType
type Interpreter ¶
type LoopControl ¶
type LoopControl struct {
Continue bool
}
func (*LoopControl) Dup ¶
func (lc *LoopControl) Dup() Object
func (*LoopControl) Inspect ¶
func (lc *LoopControl) Inspect() string
func (*LoopControl) Type ¶
func (lc *LoopControl) Type() ObjectType
type Module ¶
type Module struct { Name string Methods map[string]BuiltinFunction Vars map[string]Object }
func (*Module) Type ¶
func (m *Module) Type() ObjectType
type Object ¶
type Object interface { Type() ObjectType Inspect() string // Returns the value the object represents Dup() Object // Returns a duplicate of the object }
type ObjectType ¶
type ObjectType int
const ( IntergerObj ObjectType = iota FloatObj BooleanObj NullObj ReturnObj ExceptionObj ErrorObj FunctionObj StringObj BuiltinObj ArrayObj HashObj LoopControlObj // ResourceObj can be used by modules to denote a generic resource. The implementation may be module specific. ResourceObj ModuleObj ClassObj InterfaceObj InstanceObj BuiltinMethodObj BoundMethodObj )
These are all the internal object types used in the interpreter
func (ObjectType) String ¶
func (o ObjectType) String() string
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
func (*ReturnValue) Dup ¶
func (r *ReturnValue) Dup() Object
func (*ReturnValue) Inspect ¶
func (r *ReturnValue) Inspect() string
func (*ReturnValue) Type ¶
func (r *ReturnValue) Type() ObjectType
type String ¶
type String struct {
Value []rune
}
func MakeStringObj ¶
func MakeStringObjRunes ¶
func (*String) Type ¶
func (s *String) Type() ObjectType
Click to show internal directories.
Click to hide internal directories.