Documentation ¶
Index ¶
- Constants
- Variables
- func IsTruthy(o Object) bool
- type Boolean
- func (b *Boolean) Equals(other Object) bool
- func (b *Boolean) Infix(op string, right Object) (Object, bool)
- func (d *Boolean) Items() ([]Object, bool)
- func (d *Boolean) Iter() (Iterable, bool)
- func (b *Boolean) Numeric() (float64, bool)
- func (b *Boolean) Prefix(op string) (Object, bool)
- func (d *Boolean) SetSubscript(Object, Object) bool
- func (b *Boolean) String() string
- func (d *Boolean) Subscript(Object) (Object, bool)
- func (b *Boolean) Type() Type
- type Builtin
- func (b *Builtin) Equals(other Object) bool
- func (b *Builtin) Infix(op string, right Object) (Object, bool)
- func (d *Builtin) Items() ([]Object, bool)
- func (d *Builtin) Iter() (Iterable, bool)
- func (d *Builtin) Numeric() (float64, bool)
- func (b *Builtin) Prefix(op string) (Object, bool)
- func (d *Builtin) SetSubscript(Object, Object) bool
- func (b *Builtin) String() string
- func (d *Builtin) Subscript(Object) (Object, bool)
- func (b *Builtin) Type() Type
- type Function
- func (f *Function) Equals(other Object) bool
- func (f *Function) Infix(op string, right Object) (Object, bool)
- func (f *Function) IsMethod() bool
- func (d *Function) Items() ([]Object, bool)
- func (d *Function) Iter() (Iterable, bool)
- func (d *Function) Numeric() (float64, bool)
- func (f *Function) Prefix(op string) (Object, bool)
- func (d *Function) SetSubscript(Object, Object) bool
- func (f *Function) String() string
- func (d *Function) Subscript(Object) (Object, bool)
- func (f *Function) Type() Type
- type Iterable
- type List
- func (l *List) Equals(other Object) bool
- func (l *List) Infix(op string, right Object) (Object, bool)
- func (l *List) Items() ([]Object, bool)
- func (l *List) Iter() (Iterable, bool)
- func (d *List) Numeric() (float64, bool)
- func (l *List) Prefix(op string) (Object, bool)
- func (l *List) SetSubscript(index Object, to Object) bool
- func (l *List) String() string
- func (d *List) Subscript(Object) (Object, bool)
- func (l *List) Type() Type
- type ListIterable
- func (i *ListIterable) Equals(_ Object) bool
- func (d *ListIterable) Infix(string, Object) (Object, bool)
- func (d *ListIterable) Items() ([]Object, bool)
- func (i *ListIterable) Iter() (Iterable, bool)
- func (i *ListIterable) Next() (Object, bool)
- func (d *ListIterable) Numeric() (float64, bool)
- func (d *ListIterable) Prefix(string) (Object, bool)
- func (d *ListIterable) SetSubscript(Object, Object) bool
- func (i *ListIterable) String() string
- func (d *ListIterable) Subscript(Object) (Object, bool)
- func (i *ListIterable) Type() Type
- type Map
- func (m *Map) Equals(o Object) bool
- func (m *Map) Infix(op string, right Object) (Object, bool)
- func (m *Map) Items() ([]Object, bool)
- func (d *Map) Iter() (Iterable, bool)
- func (d *Map) Numeric() (float64, bool)
- func (m *Map) Prefix(op string) (Object, bool)
- func (m *Map) SetSubscript(key Object, val Object) bool
- func (m *Map) String() string
- func (m *Map) Subscript(key Object) (Object, bool)
- func (m *Map) Type() Type
- type Nil
- func (n *Nil) Equals(other Object) bool
- func (n *Nil) Infix(op string, right Object) (Object, bool)
- func (d *Nil) Items() ([]Object, bool)
- func (d *Nil) Iter() (Iterable, bool)
- func (n *Nil) Numeric() (float64, bool)
- func (n *Nil) Prefix(op string) (Object, bool)
- func (d *Nil) SetSubscript(Object, Object) bool
- func (n *Nil) String() string
- func (d *Nil) Subscript(Object) (Object, bool)
- func (n *Nil) Type() Type
- type Number
- func (n *Number) Equals(other Object) bool
- func (n *Number) Infix(op string, right Object) (Object, bool)
- func (d *Number) Items() ([]Object, bool)
- func (d *Number) Iter() (Iterable, bool)
- func (n *Number) Numeric() (float64, bool)
- func (n *Number) Prefix(op string) (Object, bool)
- func (d *Number) SetSubscript(Object, Object) bool
- func (n *Number) String() string
- func (d *Number) Subscript(Object) (Object, bool)
- func (n *Number) Type() Type
- type Object
- type String
- func (s *String) Equals(other Object) bool
- func (s *String) Infix(op string, right Object) (Object, bool)
- func (s *String) Items() ([]Object, bool)
- func (s *String) Iter() (Iterable, bool)
- func (d *String) Numeric() (float64, bool)
- func (s *String) Prefix(op string) (Object, bool)
- func (s *String) SetSubscript(index Object, to Object) bool
- func (s *String) String() string
- func (d *String) Subscript(Object) (Object, bool)
- func (s *String) Type() Type
- type Tuple
- func (t *Tuple) Equals(other Object) bool
- func (t *Tuple) Infix(op string, right Object) (Object, bool)
- func (t *Tuple) Items() ([]Object, bool)
- func (d *Tuple) Iter() (Iterable, bool)
- func (d *Tuple) Numeric() (float64, bool)
- func (t *Tuple) Prefix(op string) (Object, bool)
- func (t *Tuple) SetSubscript(index Object, to Object) bool
- func (t *Tuple) String() string
- func (d *Tuple) Subscript(Object) (Object, bool)
- func (t *Tuple) Type() Type
- type Type
Constants ¶
const ( NumberType = "number" BooleanType = "boolean" StringType = "string" ListType = "list" TupleType = "tuple" MapType = "map" NilType = "nil" FunctionType = "function" MethodType = "method" BuiltinType = "builtin" ModelType = "model" IterType = "iter" )
The set of available types in Radon.
Variables ¶
var Builtins = make(map[string]*Builtin)
Builtins contains every builtin.
Functions ¶
Types ¶
type Boolean ¶
type Boolean struct { Value bool // contains filtered or unexported fields }
A Boolean is either true or false.
func (*Boolean) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Boolean) Numeric ¶
Numeric returns the numeric value of an object, or false if it can't be a number.
func (*Boolean) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Boolean) SetSubscript ¶
type Builtin ¶
type Builtin struct { Name string Fn func(args ...Object) (result Object, errorType string, errorMessage string) // contains filtered or unexported fields }
A Builtin is a function which has been written in Go but is callable from a Radon program.
func (*Builtin) Equals ¶
Equals checks if two builtins are equal to each-other. Two builtins are equal if their names are the same.
func (*Builtin) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Builtin) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Builtin) SetSubscript ¶
type Function ¶
type Function struct { Parameters []string Code bytecode.Code Constants []Object Names []string Jumps []int Self *Map // contains filtered or unexported fields }
A Function is a piece of code which can be called from somewhere else, pushing a frame to the VM's frame stack. A Function is usually referred to as a Method if .Self != nil.
func (*Function) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Function) IsMethod ¶
IsMethod checks whether on not a function is a method - i.e., a function is a method if Self != nil.
func (*Function) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Function) SetSubscript ¶
type Iterable ¶
An Iterable object can be iterated and looped over in for-loops. It is a superset of the Object interface.
type List ¶
type List struct { Value []Object // contains filtered or unexported fields }
A List is a dynamic mutable linked list.
func (*List) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*List) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*List) SetSubscript ¶
SetSubscript sets the value of a subscript of an Object, e.g. foo[bar] = baz. Returns false if it can't be done.
type ListIterable ¶
A ListIterable is an iterable which operates over each element in a list.
func (*ListIterable) Equals ¶
func (i *ListIterable) Equals(_ Object) bool
Equals checks whether or not two objects are equal to each other.
func (*ListIterable) Iter ¶
func (i *ListIterable) Iter() (Iterable, bool)
Iter turns an object into an iterable.
func (*ListIterable) Next ¶
func (i *ListIterable) Next() (Object, bool)
Next returns the next object from the iterable. If false is returned as the second return value, the iterable has finished.
func (*ListIterable) SetSubscript ¶
func (*ListIterable) String ¶
func (i *ListIterable) String() string
type Map ¶
type Map struct { Keys map[string]Object Values map[string]Object // contains filtered or unexported fields }
A Map maps keys to values, where keys and values can be any type.
Keys maps the hashes to the keys they were hashed from, and Values maps the hashes to the keys' corresponding values.
func (*Map) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Map) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Map) SetSubscript ¶
SetSubscript sets the value of a subscript of an Object, e.g. foo[bar] = baz. Returns false if it can't be done.
type Nil ¶
type Nil struct {
// contains filtered or unexported fields
}
Nil represents the absence of any useful value.
func (*Nil) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Nil) Numeric ¶
Numeric returns the numeric value of an object, or false if it can't be a number.
func (*Nil) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Nil) SetSubscript ¶
type Number ¶
type Number struct { Value float64 // contains filtered or unexported fields }
A Number is a 64-bit floating point decimal.
func (*Number) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Number) Numeric ¶
Numeric returns the numeric value of an object, or false if it can't be a number.
func (*Number) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Number) SetSubscript ¶
type Object ¶
type Object interface { String() string Equals(Object) bool Type() Type // Prefix performs a prefix operation on an Object. // operator can be one of: // + - ! , // If the 2nd return value is false, an error is raised. Prefix(operator string) (Object, bool) // Infix performs an infix operation on an Object. // operator can be one of: // + - * / == != < > || && | & ^ // % <= >= . , // If the 2nd return value is false, an error is raised. Infix(operator string, right Object) (Object, bool) // Numeric returns the numeric value of an Object. // If the 2nd return value is false, an error is raised. Numeric() (float64, bool) // Items returns a slice of Objects representing an Object. // If the 2nd return value is false, an error is raised. Items() ([]Object, bool) // Subscript implements the [] operator, e.g. list[5] Subscript(Object) (Object, bool) // SetSubscript implements assigning to the [] operator, e.g. list[5] = "foo" SetSubscript(index Object, to Object) bool // Iter makes an iterable from the object if possible Iter() (Iterable, bool) }
An Object is the interface which every Radon object implements.
type String ¶
type String struct { Value string // contains filtered or unexported fields }
A String is a UTF-8 encoded Unicode string.
func (*String) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*String) Items ¶
Items returns a slice containing all objects in an Object, or false otherwise.
func (*String) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*String) SetSubscript ¶
SetSubscript sets the value of a subscript of an Object, e.g. foo[bar] = baz. Returns false if it can't be done.
type Tuple ¶
type Tuple struct { Value []Object // contains filtered or unexported fields }
A Tuple is an statically-sized collection of items.
func (*Tuple) Infix ¶
Infix applies a infix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Tuple) Items ¶
Items returns a slice containing all objects in an Object, or false otherwise.
func (*Tuple) Prefix ¶
Prefix applies a prefix operator to an object, returning the result. If the operation cannot be performed, (nil, false) is returned.
func (*Tuple) SetSubscript ¶
SetSubscript sets the value of a subscript of an Object, e.g. foo[bar] = baz. Returns false if it can't be done.