object

package
v0.0.0-...-56748ea Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTEGER_OBJ  = "INTEGER"
	FLOAT_OBJ    = "FLOAT"
	STRING_OBJ   = "STRING"
	BOOLEAN_OBJ  = "BOOLEAN"
	ARRAY_OBJ    = "ARRAY"
	HASH_OBJ     = "HASH"
	NULL_OBJ     = "NULL"
	RETURN_OBJ   = "RETURN_VALUE"
	FUNCTION_OBJ = "FUNCTION"
	ERROR_OBJ    = "ERROR"
	BUILTIN_OBJ  = "BUILTIN"
	JUMP_OBJ     = "JUMP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) Inspect

func (array *Array) Inspect() string

func (*Array) Iter

func (array *Array) Iter() Array

func (*Array) Type

func (array *Array) Type() ObjectType

type Boolean

type Boolean struct {
	Value bool
}

func (*Boolean) HashKey

func (boolean *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (boolean *Boolean) Inspect() string

func (*Boolean) Type

func (boolean *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Fn builtinFunction
}

func (*Builtin) Inspect

func (builtin *Builtin) Inspect() string

func (*Builtin) Type

func (builtin *Builtin) Type() ObjectType

type Environment

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

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

Constructor function for local environment *outer points to the outer environment thereby creating the scope chain

func NewEnvironment

func NewEnvironment() *Environment

Constructor function for global environment *outer points to null as this is the outermost environment

func (*Environment) Get

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

Retrieves value of supplied identifier from environment If identifier is not present in current environment, look up in outer environment (Scope chain)

func (*Environment) Set

func (environment *Environment) Set(name string, object Object) Object

Adds value to supplied identifier in the environment

func (*Environment) Update

func (environment *Environment) Update(name string, object Object) Object

Updates value of supplied identifier in the environment in which it was declared

type Error

type Error struct {
	Message string
}

func (*Error) Inspect

func (err *Error) Inspect() string

func (*Error) Type

func (err *Error) Type() ObjectType

type Float

type Float struct {
	Value float64
}

func (*Float) HashKey

func (float *Float) HashKey() HashKey

func (*Float) Inspect

func (float *Float) Inspect() string

func (*Float) Type

func (float *Float) Type() ObjectType

type Function

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

func (*Function) Inspect

func (function *Function) Inspect() string

func (*Function) Type

func (function *Function) Type() ObjectType

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

func (*Hash) Inspect

func (hash *Hash) Inspect() string

func (*Hash) Iter

func (hash *Hash) Iter() Array

func (*Hash) Type

func (hash *Hash) Type() ObjectType

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type Integer

type Integer struct {
	Value int
}

func (*Integer) HashKey

func (integer *Integer) HashKey() HashKey

func (*Integer) Inspect

func (integer *Integer) Inspect() string

func (*Integer) Type

func (integer *Integer) Type() ObjectType

type Iterable

type Iterable interface {
	Iter() Array
}

type Jump

type Jump struct {
	Signal string
}

func (*Jump) Inspect

func (jump *Jump) Inspect() string

func (*Jump) Type

func (jump *Jump) Type() ObjectType

type Null

type Null struct{}

func (*Null) Inspect

func (null *Null) Inspect() string

func (*Null) Type

func (null *Null) 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 (returnValue *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (returnValue *ReturnValue) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) HashKey

func (str *String) HashKey() HashKey

func (*String) Inspect

func (str *String) Inspect() string

func (*String) Iter

func (str *String) Iter() Array

func (*String) Type

func (str *String) Type() ObjectType

Jump to

Keyboard shortcuts

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