object

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

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

Go to latest
Published: Nov 7, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Builtins = []struct {
	Name    string
	Builtin *Builtin
}{
	{"len", &Builtin{Fn: builtin_len}},
	{"puts", &Builtin{Fn: builtin_puts}},
	{"first", &Builtin{Fn: builtin_first}},
	{"last", &Builtin{Fn: builtin_last}},
	{"rest", &Builtin{Fn: builtin_rest}},
	{"push", &Builtin{Fn: builtin_push}},
}

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

type Boolean

type Boolean struct {
	Value bool
}

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

func GetBuiltinByName

func GetBuiltinByName(name string) *Builtin

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

type Closure

type Closure struct {
	Fn   *CompiledFunction
	Free []Object
}

func (*Closure) Inspect

func (c *Closure) Inspect() string

func (*Closure) Type

func (c *Closure) Type() ObjectType

type CompiledFunction

type CompiledFunction struct {
	Instructions code.Instructions
	NumLocals    int
	NumParams    int
}

func (*CompiledFunction) Inspect

func (cf *CompiledFunction) Inspect() string

func (*CompiledFunction) Type

func (cf *CompiledFunction) Type() ObjectType

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, obj Object) Object

type Error

type Error struct {
	Message string
	Line    int
}

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

type Function

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

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjectType

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) Type

func (h *Hash) Type() ObjectType

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type Null

type Null struct{}

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() ObjectType

type Number

type Number struct {
	Value float64
}

func (*Number) HashKey

func (n *Number) HashKey() HashKey

func (*Number) Inspect

func (n *Number) Inspect() string

func (*Number) Type

func (n *Number) Type() ObjectType

type Object

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

type ObjectType

type ObjectType string
const (
	NumberObj           ObjectType = "NUMBER"
	BooleanObj          ObjectType = "BOOLEAN"
	NullObj             ObjectType = "NULL"
	StringObj           ObjectType = "STRING"
	ArrayObj            ObjectType = "ARRAY"
	HashObj             ObjectType = "HASH"
	FunctionObj         ObjectType = "FUNCTION"
	ReturnObj           ObjectType = "RETURN_VALUE"
	ErrorObj            ObjectType = "ERROR"
	BuiltinObj          ObjectType = "BUILTIN"
	CompiledFunctionObj ObjectType = "COMPILED_FUNCTION"
	ClosureObj          ObjectType = "CLOSURE"
)

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) HashKey

func (s *String) HashKey() HashKey

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Type

func (s *String) Type() ObjectType

Jump to

Keyboard shortcuts

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