object

package
v0.0.0-...-2dc9ae7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package object implements the objects system for the language.

Index

Constants

View Source
const (
	BooleanT     = "BOOLEAN"
	IntegerT     = "INTEGER"
	FloatT       = "FLOAT"
	NullT        = "NULL"
	ReturnValueT = "RETURN_VALUE"
	ErrorT       = "ERROR"
	FunctionT    = "FUNCTION"
	StringT      = "STRING"
	BuiltinT     = "BUILTIN"
	ArrayT       = "ARRAY"
	HashT        = "HASH"

	// CSG
	CubePrimitiveT            = "CUBE"
	CylinderPrimitiveT        = "CYLINDER"
	GroupBlockPrimitiveT      = "GROUP"
	MultmatrixBlockPrimitiveT = "MULTMATRIX"
	NamedArgumentT            = "NAMED_ARGUMENT"
	PolygonPrimitiveT         = "POLYGON"
	SpherePrimitiveT          = "SPHERE"
	SquarePrimitiveT          = "SQUARE"
	UnionBlockPrimitiveT      = "UNION"
)

Object types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

Array represents an object of that type.

func (*Array) Inspect

func (a *Array) Inspect() string

Inspect returns a representation of the object value.

func (*Array) Type

func (a *Array) Type() T

Type returns the type of the object.

type Boolean

type Boolean struct {
	Value bool
}

Boolean represents an object of that type.

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey returns a HashKey for that type.

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect returns a representation of the object value.

func (*Boolean) Type

func (b *Boolean) Type() T

Type returns the type of the object.

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

Builtin represents an object of that type.

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

Inspect returns a representation of the object value.

func (*Builtin) Type

func (b *Builtin) Type() T

Type returns the type of the object.

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

BuiltinFunction represents a builtin function.

type CubePrimitive

type CubePrimitive struct {
	Arguments []Object
}

CubePrimitive represents an object of that type.

func (*CubePrimitive) Inspect

func (c *CubePrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*CubePrimitive) Type

func (c *CubePrimitive) Type() T

Type returns the type of the object.

type CylinderPrimitive

type CylinderPrimitive struct {
	Arguments []Object
}

CylinderPrimitive represents an object of that type.

func (*CylinderPrimitive) Inspect

func (c *CylinderPrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*CylinderPrimitive) Type

func (c *CylinderPrimitive) Type() T

Type returns the type of the object.

type Environment

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

Environment represents a programming language environment.

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment returns an enclosed environment.

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment returns a new environment.

func (*Environment) Get

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

Get returns a named object from the environment.

func (*Environment) Set

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

Set sets a named object in the environment.

type Error

type Error struct {
	Message string
}

Error represents an object of that type.

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect returns a representation of the object value.

func (*Error) Type

func (e *Error) Type() T

Type returns the type of the object.

type Float

type Float struct {
	Value float64
}

Float represents an object of that type.

func (*Float) Inspect

func (i *Float) Inspect() string

Inspect returns a representation of the object value.

func (*Float) Type

func (i *Float) Type() T

Type returns the type of the object.

type Function

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

Function represents an object of that type.

func (*Function) Inspect

func (f *Function) Inspect() string

Inspect returns a representation of the object value.

func (*Function) Type

func (f *Function) Type() T

Type returns the type of the object.

type GroupBlockPrimitive

type GroupBlockPrimitive struct {
	Body Object
}

GroupBlockPrimitive represents an object of that type.

func (*GroupBlockPrimitive) Inspect

func (g *GroupBlockPrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*GroupBlockPrimitive) Type

func (g *GroupBlockPrimitive) Type() T

Type returns the type of the object.

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

Hash represents a hash map.

func (*Hash) Inspect

func (h *Hash) Inspect() string

Inspect returns a representation of the object value.

func (*Hash) Type

func (h *Hash) Type() T

Type returns the type of the object.

type HashKey

type HashKey struct {
	Type  T
	Value uint64
}

HashKey represents an object of that type.

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

HashPair represents a key/value pair.

type Hashable

type Hashable interface {
	HashKey() HashKey
}

Hashable represents objects that can be used as keys in hash maps.

type Integer

type Integer struct {
	Value int64
}

Integer represents an object of that type.

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey returns a HashKey for that type.

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect returns a representation of the object value.

func (*Integer) Type

func (i *Integer) Type() T

Type returns the type of the object.

type MultmatrixBlockPrimitive

type MultmatrixBlockPrimitive struct {
	Arguments []Object
	Body      Object
}

MultmatrixBlockPrimitive represents an object of that type.

func (*MultmatrixBlockPrimitive) Inspect

func (m *MultmatrixBlockPrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*MultmatrixBlockPrimitive) Type

func (m *MultmatrixBlockPrimitive) Type() T

Type returns the type of the object.

type NamedArgument

type NamedArgument struct {
	Name  string
	Value Object
}

NamedArgument represents an object of that type.

func (*NamedArgument) Inspect

func (n *NamedArgument) Inspect() string

Inspect returns a representation of the object value.

func (*NamedArgument) Type

func (n *NamedArgument) Type() T

Type returns the type of the object.

type Null

type Null struct{}

Null represents an object of that type.

func (*Null) Inspect

func (n *Null) Inspect() string

Inspect returns a representation of the object value.

func (*Null) Type

func (n *Null) Type() T

Type returns the type of the object.

type Object

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

Object represents an object or value type within the language.

type PolygonPrimitive

type PolygonPrimitive struct {
	Arguments []Object
}

PolygonPrimitive represents an object of that type.

func (*PolygonPrimitive) Inspect

func (c *PolygonPrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*PolygonPrimitive) Type

func (c *PolygonPrimitive) Type() T

Type returns the type of the object.

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue represents an object of that type.

func (*ReturnValue) Inspect

func (r *ReturnValue) Inspect() string

Inspect returns a representation of the object value.

func (*ReturnValue) Type

func (r *ReturnValue) Type() T

Type returns the type of the object.

type SpherePrimitive

type SpherePrimitive struct {
	Arguments []Object
}

SpherePrimitive represents an object of that type.

func (*SpherePrimitive) Inspect

func (c *SpherePrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*SpherePrimitive) Type

func (c *SpherePrimitive) Type() T

Type returns the type of the object.

type SquarePrimitive

type SquarePrimitive struct {
	Arguments []Object
}

SquarePrimitive represents an object of that type.

func (*SquarePrimitive) Inspect

func (c *SquarePrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*SquarePrimitive) Type

func (c *SquarePrimitive) Type() T

Type returns the type of the object.

type String

type String struct {
	Value string
}

String represents an object of that type.

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey returns a HashKey for that type.

func (*String) Inspect

func (s *String) Inspect() string

Inspect returns a representation of the object value.

func (*String) Type

func (s *String) Type() T

Type returns the type of the object.

type T

type T string

T represents the type of the object.

type UnionBlockPrimitive

type UnionBlockPrimitive struct {
	Body Object
}

UnionBlockPrimitive represents an object of that type.

func (*UnionBlockPrimitive) Inspect

func (g *UnionBlockPrimitive) Inspect() string

Inspect returns a representation of the object value.

func (*UnionBlockPrimitive) Type

func (g *UnionBlockPrimitive) Type() T

Type returns the type of the object.

Jump to

Keyboard shortcuts

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