Documentation ¶
Index ¶
- Constants
- type Array
- func (ar *Array) Append(obj Object)
- func (ar *Array) Bool() bool
- func (ar *Array) Compare(other Object) int
- func (ar *Array) Copy() *Array
- func (ar *Array) Inspect() string
- func (ar *Array) Len() int
- func (ar *Array) Less(i, j int) bool
- func (ar *Array) PopLeft() Object
- func (ar *Array) PopRight() Object
- func (ar *Array) Prepend(obj Object)
- func (ar *Array) Reverse()
- func (ar *Array) String() string
- func (ar *Array) Swap(i, j int)
- func (ar *Array) ToInterface() interface{}
- func (ar *Array) Type() Type
- type Boolean
- type Builtin
- type BuiltinFunction
- type Comparable
- type Environment
- func (e *Environment) Clone() *Environment
- func (e *Environment) Get(name string) (Object, bool)
- func (e *Environment) GraphicContext() gg.GraphicContext
- func (e *Environment) Set(name string, val Object) (Object, bool)
- func (e *Environment) SetGraphicContext(ctx gg.GraphicContext)
- func (e *Environment) SnapshotFilename() string
- func (e *Environment) SnapshotFolder() string
- type EnvironmentOption
- type Error
- type Float
- type Function
- type Image
- type Immutable
- type Integer
- type Null
- type Object
- type Return
- type Sizeable
- type String
- type Type
Constants ¶
const ( // INTEGER is the Integer object type INTEGER = "int" // FLOAT is the Float object type FLOAT = "float" // STRING is the String object type STRING = "str" // BOOLEAN is the Boolean object type BOOLEAN = "bool" // NULL is the Null object type NULL = "null" // RETURN is the Return object type RETURN = "return" // ERROR is the Error object type ERROR = "error" // FUNCTION is the Function object type FUNCTION = "fn" // BUILTIN is the Builtin object type BUILTIN = "builtin" // ARRAY is the Array object type ARRAY = "array" // IMAGE is the Image object type IMAGE = "image" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
Elements []Object
}
Array is the array literal type that holds a slice of Object(s)
func (*Array) ToInterface ¶
func (ar *Array) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Boolean ¶
type Boolean struct {
Value bool
}
Boolean is the boolean type and used to represent boolean literals and holds an interval bool value
func (*Boolean) ToInterface ¶
func (b *Boolean) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Builtin ¶
type Builtin struct { Name string Fn BuiltinFunction Env *Environment }
Builtin is the builtin object type that simply holds a reference to a BuiltinFunction type that takes zero or more objects as arguments and returns an object.
func (*Builtin) ToInterface ¶
func (b *Builtin) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type BuiltinFunction ¶
type BuiltinFunction func(env *Environment, args ...Object) Object
BuiltinFunction represents the builtin function type
type Comparable ¶
Comparable is the interface for comparing two Object and their underlying values. It is the responsibility of the caller (left) to check for types. Returns `true` iif the types and values are identical, `false` otherwise.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is an object that holds a mapping of names to bound objets
func NewEnvironment ¶
func NewEnvironment(ctx gg.GraphicContext, opts ...EnvironmentOption) *Environment
NewEnvironment constructs a new Environment object to hold bindings of identifiers to their names
func (*Environment) Clone ¶
func (e *Environment) Clone() *Environment
Clone returns a new Environment with the parent set to the current environment (enclosing environment)
func (*Environment) Get ¶
func (e *Environment) Get(name string) (Object, bool)
Get returns the object bound by name
func (*Environment) GraphicContext ¶ added in v0.5.0
func (e *Environment) GraphicContext() gg.GraphicContext
GraphicContext returns the graphics context
func (*Environment) Set ¶
func (e *Environment) Set(name string, val Object) (Object, bool)
Set stores the object with the given name
func (*Environment) SetGraphicContext ¶ added in v0.5.0
func (e *Environment) SetGraphicContext(ctx gg.GraphicContext)
SetGraphicContext sets the graphics context
func (*Environment) SnapshotFilename ¶ added in v0.5.0
func (e *Environment) SnapshotFilename() string
SnapshotFilename returns the snapshot filename
func (*Environment) SnapshotFolder ¶ added in v0.5.0
func (e *Environment) SnapshotFolder() string
SnapshotFolder returns the snapshot output folder
type EnvironmentOption ¶ added in v0.5.0
type EnvironmentOption func(*Environment)
EnvironmentOption defines a functional option for the environment creation
func WithOutputDir ¶ added in v0.5.0
func WithOutputDir(dir string) EnvironmentOption
WithOutputDir sets the snapshot output directory
func WithSnapshotPrefix ¶ added in v0.5.0
func WithSnapshotPrefix(prefix string) EnvironmentOption
WithSnapshotPrefix sets the snapshot filename prefix
type Error ¶
type Error struct {
Message string
}
Error is the error type and used to hold a message denoting the details of error encountered. This object is trakced through the evaluator and when encountered stops evaulation of the program or body of a function.
func NewError ¶ added in v0.4.1
NewError builds an error with a custom message Helper function used in all builtins.
func (*Error) ToInterface ¶
func (e *Error) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Float ¶
type Float struct {
Value float64
}
Float is the float type used to represent float literals and holds an internal float64 value
func (*Float) ToInterface ¶
func (f *Float) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Function ¶
type Function struct { Parameters []*ast.Identifier Body *ast.BlockStatement Env *Environment }
Function is the function type that holds the function's formal parameters, body and an environment to support closures.
func (*Function) ToInterface ¶
func (f *Function) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Image ¶ added in v0.4.1
Image represents an image object
func (*Image) Inspect ¶ added in v0.4.1
Inspect returns a stringified version of the object for debugging
func (*Image) ToInterface ¶ added in v0.4.1
func (im *Image) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Immutable ¶
type Immutable interface {
Clone() Object
}
Immutable is the interface for all immutable objects which must implement the Clone() method used by binding names to values.
type Integer ¶
type Integer struct {
Value int64
}
Integer is the integer type used to represent integer literals and holds an internal int64 value
func (*Integer) ToInterface ¶
func (i *Integer) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Null ¶
type Null struct{}
Null is the null type and used to represent the absence of a value
func (*Null) ToInterface ¶
func (n *Null) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Object ¶
type Object interface { fmt.Stringer Type() Type Bool() bool Inspect() string ToInterface() interface{} }
Object represents a value and implementations are expected to implement `Type()` and `Inspect()` functions
type Return ¶
type Return struct {
Value Object
}
Return is the return type and used to hold the value of another object. This is used for `return` statements and this object is tracked through the evalulator and when encountered stops evaluation of the program, or body of a function.
func (*Return) ToInterface ¶
func (rv *Return) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.
type Sizeable ¶
type Sizeable interface {
Len() int
}
Sizeable is the interface for returning the size of an Object. Object(s) that have a valid size must implement this interface and the Len() method.
type String ¶
type String struct {
Value string
}
String is the string type used to represent string literals and holds an internal string value
func (*String) ToInterface ¶
func (s *String) ToInterface() interface{}
ToInterface converts this object to a go-interface, which will allow it to be used naturally in our sprintf/printf primitives.
It might also be helpful for embedded users.