object

package
v0.0.0-...-89ea315 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTEGER_OBJ    = "INTEGER"
	BOOLEAN_OBJ    = "BOOLEAN"
	STRING_OBJ     = "STRING"
	NULL_OBJ       = "NULL"
	RETURN_VAL_OBJ = "RETURN_VAL"
	FUNCTION_OBJ   = "FUNCTION"
	BUILTIN_OBJ    = "BUILTIN"
	ERROR_OBJ      = "ERROR"
	ARRAY_OBJ      = "ARRAY"
	HASH_OBJ       = "HASH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) Inspect

func (ao *Array) Inspect() string

func (*Array) Type

func (ao *Array) Type() ObjectType

type Boolean

type Boolean struct {
	Value bool
}

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type BuiltIn

type BuiltIn struct {
	Func BuiltInFunction
}

func (*BuiltIn) Inspect

func (b *BuiltIn) Inspect() string

func (*BuiltIn) Type

func (b *BuiltIn) Type() ObjectType

type BuiltInFunction

type BuiltInFunction func(args ...Object) Object

type Environment

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

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) Get

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

Return object reference from Environment

func (*Environment) Set

func (e *Environment) Set(id string, obj Object, deepCopy bool) (Object, bool)

Set object in the environment with given ID Reference flag serves as indication to either deep or shallow copy the object

type Error

type Error struct {
	Message string
}

func (*Error) Inspect

func (err *Error) Inspect() string

func (*Error) Type

func (err *Error) Type() ObjectType

type Function

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

func (*Function) Inspect

func (fun *Function) Inspect() string

func (*Function) Type

func (fun *Function) Type() ObjectType

type Hash

type Hash struct {
	Pairs map[HashKey]HashEntry
}

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) Type

func (h *Hash) Type() ObjectType

type HashEntry

type HashEntry struct {
	Key   Object
	Value Object
}

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

TODO: Cache Hash Values for all implementations

type Integer

type Integer struct {
	Value int64
}

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) Type

func (i *Integer) Type() ObjectType

type Null

type Null struct{}

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *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 (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) HashKey

func (s *String) HashKey() HashKey

TODO: Handle hash collision(open addressing or seperate chaining)

func (*String) Inspect

func (s *String) Inspect() string

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