object

package
v0.0.0-...-defdebb Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package object : Object definitions used to evaluate program AST nodes

Index

Constants

View Source
const (
	INTEGER_OBJ      = "INTEGER"
	FLOAT_OBJ        = "FLOAT"
	BOOLEAN_OBJ      = "BOOLEAN"
	NULL_OBJ         = "NULL"
	RETURN_VALUE_OBJ = "RETURN_VALUE"
	ERROR_OBJ        = "ERROR"
	FUNCTION_OBJ     = "FUNCTION"
	STRING_OBJ       = "STRING"
	BUILTIN_OBJ      = "BUILTIN"
	ARRAY_OBJ        = "ARRAY"
	HASH_OBJ         = "HASH"
	CHAR_OBJ         = "CHAR"
)

ObjectTypes

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

Array : Object representing an array of elements

func (*Array) Inspect

func (ao *Array) Inspect() string

Inspect : Returns string representation of Object's value

func (*Array) Type

func (ao *Array) Type() ObjectType

Type : Returns Object's type

type Boolean

type Boolean struct {
	Value bool
}

Boolean : Object representing a boolean

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey : Generates a HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect : Returns string representation of Object's value

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

Type : Returns Object's type

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

Builtin : Object representing a built in function

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

Inspect : Returns string declaring Object is a builtin function

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

Type : Returns Object's type

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

BuiltinFunction : A predefined function included in the interpreter

type Character

type Character struct {
	Value byte
}

Character : Object representing an character

func (*Character) HashKey

func (c *Character) HashKey() HashKey

HashKey : Generates a HashKey

func (*Character) Inspect

func (c *Character) Inspect() string

Inspect : Returns string representation of Object's value

func (*Character) Type

func (c *Character) Type() ObjectType

Type : Returns Object's type

type Environment

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

Environment : Contains information about values that have mapped to a declared identifier so they can be accessed throughout the lifetime of a program

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment : Creates a new Environment nested inside a higher level Environment for use in functions

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment : Creates a new Environment at the highest level with no identifier mappings

func (*Environment) Get

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

Get : Attempts to retrieve an identifier's value if it exists

func (*Environment) Set

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

Set : Sets an identifier's value

type Error

type Error struct {
	Message string
}

Error : Object representing an error during evaluation

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect : Returns string representation of the error message

func (*Error) Type

func (e *Error) Type() ObjectType

Type : Returns Object's type

type Float

type Float struct {
	Value float64
}

Float : Object representing a float

func (*Float) Inspect

func (f *Float) Inspect() string

Inspect : Returns string representation of Object's value

func (*Float) Type

func (f *Float) Type() ObjectType

Type : Returns Object's type

type Function

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

Function : Object representing a function including its parameters and body statements

func (*Function) Inspect

func (f *Function) Inspect() string

Inspect : Returns string representation of function's parameters and body

func (*Function) Type

func (f *Function) Type() ObjectType

Type : Returns Object's type

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

Hash : Object representing a map of key-value pairs

func (*Hash) Inspect

func (h *Hash) Inspect() string

Inspect : Returns string representation of Object's value

func (*Hash) Type

func (h *Hash) Type() ObjectType

Type : Returns Object's type

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

HashKey : Definitions for how to determine the keys for a hash for each type of object

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

HashPair : Represents a key-value pair used in the Hash object

type Hashable

type Hashable interface {
	HashKey() HashKey
}

Hashable : Defines Objects that are usable as keys in a Hash

type Integer

type Integer struct {
	Value int64
}

Integer : Object representing an integer

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey : Generates a HashKey

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect : Returns string representation of Object's value

func (*Integer) Type

func (i *Integer) Type() ObjectType

Type : Returns Object's type

type Null

type Null struct{}

Null : Object representing a null value

func (*Null) Inspect

func (n *Null) Inspect() string

Inspect : Returns string representation of a null value

func (*Null) Type

func (n *Null) Type() ObjectType

Type : Returns Object's type

type Number

type Number interface {
	// contains filtered or unexported methods
}

Number : Generic number type

type Object

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

Object : Generic object

type ObjectType

type ObjectType string

ObjectType : String representation of each type of Object

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue : Object representing a return value

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

Inspect : Returns string representation of the wrapped Object's value

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

Type : Returns Object's type

type String

type String struct {
	Value string
}

String : Object representing a string

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey : Generates a HashKey

func (*String) Inspect

func (s *String) Inspect() string

Inspect : Returns string representation of Object's value

func (*String) Type

func (s *String) Type() ObjectType

Type : Returns Object's type

Jump to

Keyboard shortcuts

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