object

package
v0.0.0-...-5abede8 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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
}

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey is used when we are using Boolean objects as keys for Hash Objects

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() Type

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() Type

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

type Environment

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

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *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
}

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() Type

type Function

type Function struct {
	Parameters []*syntaxtree.Identifier
	Body       *syntaxtree.BlockStmt
	Env        *Environment
}

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() Type

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) Type

func (h *Hash) Type() Type

type HashKey

type HashKey struct {
	Type  Type
	Value uint64
}

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type Integer

type Integer struct {
	Value int
}

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey is used when we are using Boolean objects as keys for Hash Objects

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) Type

func (i *Integer) Type() Type

type Null

type Null struct{}

Null references were introduced to the ALGOL W language in 1965 Tony Hoare was the person behind this and later on he called this a “billion-dollar mistake”

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 // String repr
}

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue is used as a wrapper around the to-be returned Value Object. This is strictly done to skip doing ugly go to statements.

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() Type

type String

type String struct {
	Value string
}

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey is used when we are using String objects as keys for Hash Objects

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Type

func (s *String) Type() Type

type Type

type Type string
const (
	IntegerObject     Type = "Integer"
	BooleanObject     Type = "Boolean"
	NullObject        Type = "Null"
	ReturnValueObject Type = "ReturnValue"
	ErrorObject       Type = "Error"
	FunctionObject    Type = "Function"
	StringObject      Type = "String"
	BuiltinObject     Type = "Builtin"
	ArrayObject       Type = "Array"
	HashObject        Type = "Hash"
)

Jump to

Keyboard shortcuts

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