object

package
v0.0.0-...-342ae8e Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTEGER_OBJ  = "INTEGER"
	BOOLEAN_OBJ  = "BOOLEAN"
	NULL_OBJ     = "NULL"
	RETURN_OBJ   = "RETURN"
	ERROR_OBJ    = "ERROR"
	FUNC_OBJ     = "FUNCTION"
	BUILT_IN_OBJ = "BUILT_IN"
	STRING_OBJ   = "STRING"
	ARRAY_OBJ    = "ARRAY"
	HASH_MAP_OBJ = "HASH_MAP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) Inspect

func (a *Array) Inspect() string

func (*Array) Type

func (a *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 BuiltInFunction

type BuiltInFunction struct {
	Fn func(args ...Object) Object
}

func (*BuiltInFunction) Inspect

func (fn *BuiltInFunction) Inspect() string

func (*BuiltInFunction) Type

func (fn *BuiltInFunction) Type() ObjectType

type Environment

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

func NewEnclosedEnv

func NewEnclosedEnv(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) Get

func (env *Environment) Get(ident string) (Object, bool)

func (*Environment) Put

func (env *Environment) Put(ident string, val Object) 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 (fn *Function) Inspect() string

func (*Function) Type

func (fn *Function) Type() ObjectType

type HashKey

type HashKey struct {
	Type  ObjectType
	Value int64
}

type HashMap

type HashMap struct {
	// HashPair is used as value to keep track of non-hash representation of keys
	Pairs map[HashKey]HashPair
}

func (*HashMap) Inspect

func (hm *HashMap) Inspect() string

func (*HashMap) Type

func (hm *HashMap) Type() ObjectType

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

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 ReturnWrapper

type ReturnWrapper struct {
	Value Object
}

func (*ReturnWrapper) Inspect

func (rw *ReturnWrapper) Inspect() string

func (*ReturnWrapper) Type

func (rw *ReturnWrapper) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) HashKey

func (s *String) HashKey() HashKey

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