object

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// INTEGER object type
	INTEGER = "INTEGER"
	// BOOLEAN object type
	BOOLEAN = "BOOLEAN"
	// STRING object type
	STRING = "STRING"
	// NULL object type
	NULL = "NULL"
	// VOID object type
	VOID = "VOID"
	// RETURN object wrapper type
	RETURN = "RETURN"
	// ERROR object type
	ERROR = "ERROR"
	// FUNCTION object type
	FUNCTION = "FUNCTION"
	// BUILTIN object type
	BUILTIN = "BUILTIN"
	// ARRAY object type
	ARRAY = "ARRAY"
	// HASH object type
	HASH = "HASH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

Array represents slice of objects

func (*Array) Inspect

func (a *Array) Inspect() string

Inspect returns stringified array

func (*Array) Type

func (a *Array) Type() Type

Type returns array type

type Boolean

type Boolean struct {
	Value bool
}

Boolean object.

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey returns HashKey created from a Boolean.

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect returns value of a boolean.

func (*Boolean) Type

func (b *Boolean) Type() Type

Type returns the boolean type.

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

Builtin is a wrapper over built-in function.

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

Inspect returns the builtin function representation

func (*Builtin) Type

func (b *Builtin) Type() Type

Type returns the built-ins' type

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

BuiltinFunction is a built-in function type.

type Environment

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

Environment is a map of known objects.

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment returns new Environment instance

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment returns new Environment instance

func (*Environment) Get

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

Get returns value of given key from Enviroment's map. If not found, looks for value in Environment's ancestor.

func (*Environment) Set

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

Set puts the value of given key in Enviroment's map.

func (*Environment) ShallowGet

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

ShallowGet returns value of given key from Enviroment's map.

type Error

type Error struct {
	Message string
}

Error object.

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect returns error message.

func (*Error) Type

func (e *Error) Type() Type

Type returns the Error object type.

type Function

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

Function object.

func (*Function) Inspect

func (f *Function) Inspect() string

Inspect returns the Function object image.

func (*Function) Type

func (f *Function) Type() Type

Type returns the Function object type.

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

Hash represents the Hash Object Type.

func (*Hash) Inspect

func (h *Hash) Inspect() string

Inspect returns stringified Hash object.

func (*Hash) Type

func (h *Hash) Type() Type

Type returns the Hash object type.

type HashKey

type HashKey struct {
	Type  Type
	Value uint64
}

HashKey is key in Hash.

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

HashPair represents

type Hashable

type Hashable interface {
	HashKey() HashKey
}

Hashable interface represents types that can be keys in hash object.

type Integer

type Integer struct {
	Value int64
}

Integer object.

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey returns HashKey created from a Integer.

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect returns value of an integer.

func (*Integer) Type

func (i *Integer) Type() Type

Type returns the integer type.

type Null

type Null struct{}

Null object.

func (*Null) Inspect

func (n *Null) Inspect() string

Inspect returns null.

func (*Null) Type

func (n *Null) Type() Type

Type returns the null object type.

type Object

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

Object interface is implemented by the objects.

type Return

type Return struct {
	Value Object
}

Return object is a wrapper to a object that gets returned.

func (*Return) Inspect

func (rv *Return) Inspect() string

Inspect returns the value of object to be returned.

func (*Return) Type

func (rv *Return) Type() Type

Type returns the Return object type.

type String

type String struct {
	Value string
}

String object.

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey returns HashKey created from a String.

func (*String) Inspect

func (s *String) Inspect() string

Inspect returns value of a string.

func (*String) Type

func (s *String) Type() Type

Type returns the string type.

type Type

type Type string

Type represents different object types.

type Void

type Void struct{}

Void object.

func (*Void) Inspect

func (v *Void) Inspect() string

Inspect returns void.

func (*Void) Type

func (v *Void) Type() Type

Type returns the void object type.

Jump to

Keyboard shortcuts

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