object

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BOOLEAN_OBJ      = "BOOLEAN"
	BUILTIN_OBJ      = "BUILTIN"
	ERROR_OBJ        = "ERROR"
	FUNCTION_OBJ     = "FUNCTION"
	LIST_OBJ         = "LIST"
	MAP_OBJ          = "MAP"
	NULL_OBJ         = "NULL"
	NUMBER_OBJ       = "NUMBER"
	RETURN_VALUE_OBJ = "RETURN_VALUE"
	STRING_OBJ       = "STRING"
	MODULE_OBJ       = "MODULE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	Value bool
}

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) MapKey

func (b *Boolean) MapKey() MapKey

func (*Boolean) Set

func (b *Boolean) Set(obj Object)

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Name string
	Fn   BuiltinFunction
}

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type BuiltinFunction

type BuiltinFunction func(env *Environment, args ...Object) Object

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment is an object that holds a mapping of names to bound objects

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment constructs a new Environment object to hold bindings of identifiers to their names

func (*Environment) All

func (e *Environment) All() map[string]Object

All returns all stored identifiers.

func (*Environment) Exported

func (e *Environment) Exported() *Map

func (*Environment) Get

func (e *Environment) Get(name string) (Object, bool)

Get returns the object bound by name

func (*Environment) Set

func (e *Environment) Set(name string, value Object) Object

Set stores the object with the given name

type Error

type Error struct {
	Message string
}

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Set

func (e *Error) Set(obj Object)

func (*Error) Type

func (e *Error) Type() ObjectType

type Function

type Function struct {
	Parameters []*ast.Identifier
	Body       *ast.BlockStatement
	Defaults   map[string]ast.Expression
	Env        *Environment
}

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjectType

type List

type List struct {
	Elements []Object
}

func (*List) Inspect

func (ao *List) Inspect() string

func (*List) Set

func (ao *List) Set(obj Object)

func (*List) Type

func (ao *List) Type() ObjectType

type Map

type Map struct {
	Pairs map[MapKey]MapPair
}

func (*Map) Inspect

func (m *Map) Inspect() string

func (*Map) Type

func (m *Map) Type() ObjectType

type MapKey

type MapKey struct {
	Type  ObjectType
	Value uint64
}

type MapPair

type MapPair struct {
	Key   Object
	Value Object
}

type Mappable

type Mappable interface {
	MapKey() MapKey
}

type Module

type Module struct {
	Name       string
	Attributes Object
}

func (*Module) Inspect

func (m *Module) Inspect() string

func (*Module) Type

func (m *Module) Type() ObjectType

type Mutable

type Mutable interface {
	Set(obj Object)
}

type Null

type Null struct{}

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() ObjectType

type Number

type Number struct {
	Value decimal.Decimal
}

func (*Number) Inspect

func (n *Number) Inspect() string

func (*Number) MapKey

func (n *Number) MapKey() MapKey

func (*Number) Set

func (n *Number) Set(obj Object)

func (*Number) Type

func (n *Number) Type() ObjectType

type Object

type Object interface {
	Type() ObjectType
	Inspect() string
}

type ObjectType

type ObjectType string

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) Inspect

func (s *String) Inspect() string

func (*String) MapKey

func (s *String) MapKey() MapKey

MapKey defines the key for maps that can be comparable and unique.

Note: There is a _very_ small chance that the following will result in the same hash being generated for different string values (hash collisions). Research "separate chaining" and "open addressing" techniques to work around the problem.

func (*String) Set

func (s *String) Set(obj Object)

func (*String) Type

func (s *String) Type() ObjectType

Jump to

Keyboard shortcuts

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