object

package
v0.0.0-...-fb456ee Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntegerObj     Type = "INTEGER"
	BooleanObj     Type = "BOOLEAN"
	NullObj        Type = "NULL"
	StringObj      Type = "STRING"
	ReturnValueObj Type = "RETURN_VALUE"
	ErrorObj            = "ERROR"
	FunctionObj         = "FUNCTION"
	BuildInObj          = "BUILDIN"
	ArrayObj            = "ARRAY"
	HashObj             = "HASHMAP"
)

Variables

View Source
var (
	NULL  = &Null{}
	TRUE  = &Boolean{Value: true}
	FALSE = &Boolean{Value: false}
)

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() Type

type Boolean

type Boolean struct {
	Value bool
}

Boolean represents boolean type.

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() Type

type BuildIn

type BuildIn struct {
	Fn BuildInFunction
}

BuildIn represents a wrapper around BuildInFunction that implements Object interface.

func (*BuildIn) Inspect

func (b *BuildIn) Inspect() string

func (*BuildIn) Type

func (b *BuildIn) Type() Type

type BuildInFunction

type BuildInFunction func(args ...Object) Object

BuildInFunction represents build-in function definition.

type Environment

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

Environment represents a local environment that keeps track of identifiers and their values within a session.

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment returns new instance of Environment which enclosing the new environment.

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment return new instance of Environment.

func (*Environment) Get

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

func (*Environment) Set

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

type Error

type Error struct {
	Message string
}

Error represents an error object.

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() Type

type Function

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

Function represents a function.

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() Type

type HashKey

type HashKey struct {
	Type  Type
	Value uint64
}

type HashMap

type HashMap struct {
	ObjType Type
	Pairs   map[HashKey]HashPair
}

HashMap represents hash map.

func (*HashMap) Inspect

func (h *HashMap) Inspect() string

func (*HashMap) Type

func (h *HashMap) Type() Type

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

HashPair represents <key>:<value> pair in the hash.

type Hashable

type Hashable interface {
	HashKey() HashKey
}

Hashable describes an object that can be used as a key in hash map.

type Integer

type Integer struct {
	Value int64
}

Integer represents integer type.

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) Type

func (i *Integer) Type() Type

type Null

type Null struct{}

Null represents null type.

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() Type

type Object

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

Object represents an entity being evaluated.

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue represents return statement value.

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() Type

type String

type String struct {
	Value string
}

String represents string type.

func (*String) HashKey

func (s *String) HashKey() HashKey

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Type

func (s *String) Type() Type

type Type

type Type string

Type represents object's type.

Jump to

Keyboard shortcuts

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