object

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NULL_OBJ = "NULL"

	RETURN_VALUE_OBJ = "RETURN_VALUE"
	ERROR_OBJ        = "ERROR"
	FUNCTION_OBJ     = "FUNCTION"
	BUILTIN_OBJ      = "BUILTIN"

	INTEGER_OBJ = "INTEGER"
	BOOLEAN_OBJ = "BOOLEAN"
	STRING_OBJ  = "STRING"

	LIST_OBJ = "LIST"
	MAP_OBJ  = "MAP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	// Represents the value of the Boolean
	Value bool
}

A structure that represents a Boolean object

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

A method of Boolean that returns the HashKey of the object

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

A method of Boolean that returns the string value of the Boolean

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

A method of Boolean that returns the Boolean value type

type Builtin

type Builtin struct {
	// Represents the built-in function
	Fn BuiltinFunction
}

A structure that represents a Builtin Function

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

A method of Builtin that returns the string value of the Builtin function object

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

A method of Builtin that returns the Builtin function value type

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

A type alias for built in function objects

type Environment

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

A structure that represents an execution environment

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

A constructor function that generates and returns an enclosed Environment given the outer environment

func NewEnvironment

func NewEnvironment() *Environment

A constructor function that generates and returns a new Environment

func (*Environment) Get

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

A method of Environment to retrieve a value from the store

func (*Environment) Set

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

A method of Environment to add a value to store

type Error

type Error struct {
	// Represents the error message
	Message string
}

A structure that represents an Error object

func NewError

func NewError(format string, a ...interface{}) *Error

A constructor function that generates and returns a new Error for a given message and some variadic interface

func (*Error) Inspect

func (e *Error) Inspect() string

A method of Error that returns the string value of the Error object

func (*Error) Type

func (e *Error) Type() ObjectType

A method of Error that returns the Error value type

type Function

type Function struct {
	// Represents the function parameters
	Parameters []*syntaxtree.Identifier
	// Represents the function body
	Body *syntaxtree.BlockStatement
	// Represents the function execution environment (scope)
	Env *Environment
}

A structure that represents a Function object

func (*Function) Inspect

func (f *Function) Inspect() string

A method of Function that returns the string value of the Function object

func (*Function) Type

func (f *Function) Type() ObjectType

A method of Function that returns the Function value type

type HashKey

type HashKey struct {
	// Represents the hash key type
	Type ObjectType

	// Represents the hash key value
	Value uint64
}

A structure that represents a HashKey object

type Hashable

type Hashable interface {
	HashKey() HashKey
}

An interface implemented by objects that can be hashed

type Integer

type Integer struct {
	// Represents the value of the Integer
	Value int64
}

A structure that represents an Integer object

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

A method of Integer that return the HashKey of the object

func (*Integer) Inspect

func (i *Integer) Inspect() string

A method of Integer that returns the string value of the Integer

func (*Integer) Type

func (i *Integer) Type() ObjectType

A method of Integer that returns the Integer value type

type List

type List struct {
	// Represents the elements of the list
	Elements []Object
}

A structure that represents a List object

func (*List) Inspect

func (l *List) Inspect() string

A method of List that returns the string value of the List

func (*List) Type

func (l *List) Type() ObjectType

A method of List that returns the List value type

type Map

type Map struct {
	// Represents the key-value pairs of the map
	Pairs map[HashKey]MapPair
}

A structure that represents a Map object

func (*Map) Inspect

func (h *Map) Inspect() string

A method of Map that returns the string value of the Map

func (*Map) Type

func (h *Map) Type() ObjectType

A method of Map that returns the Map value type

type MapPair

type MapPair struct {
	// Represents the key of the key-value pair
	Key Object
	// Represents the value of the key-value pair
	Value Object
}

A structure that represents a Map key-value pair

type Null

type Null struct{}

A structure that represents a Null object

func (*Null) Inspect

func (n *Null) Inspect() string

A method of Null that returns the string value of the Null

func (*Null) Type

func (n *Null) Type() ObjectType

A method of Null that returns the Null value type

type Object

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

A structure that represents an evaluated object

type ObjectType

type ObjectType string

A type alias that represents the type of an object

type ReturnValue

type ReturnValue struct {
	// Represents the returned object
	Value Object
}

A structure that represents a Returned object

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

A method of ReturnValue that returns the string value of the Returned object

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

A method of ReturnValue that returns the Return value type

type String

type String struct {
	// Represents the value of the String
	Value string
}

A structure that represents a String object

func (*String) HashKey

func (s *String) HashKey() HashKey

A method of String that returns the HashKey of the object

func (*String) Inspect

func (s *String) Inspect() string

A method of String that returns the string value of the String

func (*String) Type

func (s *String) Type() ObjectType

A method of String that returns the String value type

Jump to

Keyboard shortcuts

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