object

package
v0.0.0-...-c195416 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// IntegerObj name
	IntegerObj = "INTEGER"
	// BooleanObj name
	BooleanObj = "BOOLEAN"
	// NullObj name
	NullObj = "NULL"
	// ReturnValueObj name
	ReturnValueObj = "RETURN_VALUE"
	// ErrorObj name
	ErrorObj = "ERROR"
	// FunctionObj name
	FunctionObj = "FUNCTION"
	//StringObj name
	StringObj = "STRING"
	//BuiltinObj name
	BuiltinObj = "BUILTIN"
	// ArrayObj name
	ArrayObj = "ARRAY"
	// HashObj name
	HashObj = "HASH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

Array Obj

func (*Array) Inspect

func (ao *Array) Inspect() string

Inspect returns the array value

func (*Array) Type

func (ao *Array) Type() Type

Type of array object

type Boolean

type Boolean struct {
	Value bool
}

Boolean data type

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey generator for a boolean key

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect returns the Boolean value string format

func (*Boolean) Type

func (b *Boolean) Type() Type

Type returns the Boolean object name

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

Builtin object

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

Inspect returns the string value

func (*Builtin) Type

func (b *Builtin) Type() Type

Type returns the String Object name

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

BuiltinFunction defines an inbuilt function

type Environment

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

Environment holds the values in global

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment creates a new Enclosed env

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment creates a new Environment with a map

func (*Environment) Get

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

Get fetches an object by name

func (*Environment) Set

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

Set creates a new Object in environment

type Error

type Error struct {
	Message string
}

Error data type

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect returns the Return value string format

func (*Error) Type

func (e *Error) Type() Type

Type returns the Return object name

type Function

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

Function data type

func (*Function) Inspect

func (f *Function) Inspect() string

Inspect returns the Return value string format

func (*Function) Type

func (f *Function) Type() Type

Type returns the Return object name

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

Hash ...

func (*Hash) Inspect

func (h *Hash) Inspect() string

Inspect returns the Hash representation

func (*Hash) Type

func (h *Hash) Type() Type

Type returns the Hash type

type HashKey

type HashKey struct {
	Type  Type
	Value uint64
}

HashKey ...

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

HashPair is K:V

type Hashable

type Hashable interface {
	HashKey() HashKey
}

Hashable defines methods for elements that can be used as HashKeys

type Integer

type Integer struct {
	Value int64
}

Integer data type

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey generator for an integer key

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect returns the integer value string format

func (*Integer) Type

func (i *Integer) Type() Type

Type returns the integer object name

type Null

type Null struct{}

Null data type

func (*Null) Inspect

func (b *Null) Inspect() string

Inspect returns the Null value string format

func (*Null) Type

func (b *Null) Type() Type

Type returns the Null object name

type Object

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

Object interface

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue data type

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

Inspect returns the Return value string format

func (*ReturnValue) Type

func (rv *ReturnValue) Type() Type

Type returns the Return object name

type String

type String struct {
	Value string
}

String object

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey generator for a string key

func (*String) Inspect

func (s *String) Inspect() string

Inspect returns the string value

func (*String) Type

func (s *String) Type() Type

Type returns the String Object name

type Type

type Type string

Type represents every value during AST evaluation

Jump to

Keyboard shortcuts

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