object

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package object contains our core-definitions for objects.

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"
	STRING_OBJ       = "STRING"
)

pre-defined constant Type

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	// Value holds the boolean value we wrap.
	Value bool
}

Boolean wraps bool and implements the Object interface.

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect returns a string-representation of the given object.

func (*Boolean) Type

func (b *Boolean) Type() Type

Type returns the type of this object.

type Environment

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

Environment stores our functions, variables, constants, etc.

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment create new environment by outer parameter

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment creates new environment

func (*Environment) Get

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

Get returns the value of a given variable, by name.

func (*Environment) Set

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

Set stores the value of a variable, by name.

type Error

type Error struct {
	// Message contains the error-message we're wrapping
	Message string
}

Error wraps string and implements Object interface.

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect returns a string-representation of the given object.

func (*Error) Type

func (e *Error) Type() Type

Type returns the type of this object.

type Float

type Float struct {
	// Value holds the float-value this object wraps.
	Value float64
}

Float wraps float64 and implements the Object interface.

func (*Float) Inspect

func (f *Float) Inspect() string

Inspect returns a string-representation of the given object.

func (*Float) Type

func (f *Float) Type() Type

Type returns the type of this object.

type Integer

type Integer struct {
	// Value holds the integer value this object wraps
	Value int64
}

Integer wraps int64 and implements the Object interface.

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect returns a string-representation of the given object.

func (*Integer) Type

func (i *Integer) Type() Type

Type returns the type of this object.

type Null

type Null struct{}

Null wraps nothing and implements our Object interface.

func (*Null) Inspect

func (n *Null) Inspect() string

Inspect returns a string-representation of the given object.

func (*Null) Type

func (n *Null) Type() Type

Type returns the type of this object.

type Object

type Object interface {

	// Type returns the type of this object.
	Type() Type

	// Inspect returns a string-representation of the given object.
	Inspect() string
}

Object is the interface that all of our various object-types must implmenet.

type ReturnValue

type ReturnValue struct {
	// Value is the object that is to be returned
	Value Object
}

ReturnValue wraps Object and implements the Object interface.

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

Inspect returns a string-representation of the given object.

func (*ReturnValue) Type

func (rv *ReturnValue) Type() Type

Type returns the type of this object.

type String

type String struct {
	// Value holds the string value this object wraps.
	Value string
}

String wraps string and implements the Object interface.

func (*String) Inspect

func (s *String) Inspect() string

Inspect returns a string-representation of the given object.

func (*String) Type

func (s *String) Type() Type

Type returns the type of this object.

type Type

type Type string

Type describes the type of an object.

Jump to

Keyboard shortcuts

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