object

package
v0.0.0-...-005afaa Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTEGER_OBJ      = "INTEGER"
	BOOLEAN_OBJ      = "BOOLEAN"
	STRING_OBJ       = "STRING"
	NULL_OBJ         = "NULL"
	RETURN_VALUE_OBJ = "RETURN_VALUE"
	ERROR_VALUE_OBJ  = "ERROR_VALUE"
	FUNCTION_OBJ     = "FUNCTION"
	BUILTIN_OBJ      = "BUILTIN"
	ARRAY_OBJ        = "ARRAY"
	VAR_ARGS_OBJ     = "VAR_ARGS"
	MAP_OBJ          = "MAP"
)
View Source
const RED = "\x1b[31m"
View Source
const RESET_COLOR = "\x1b[0m"
View Source
const UNDERLINE = "\x1b[4m"
View Source
const UNDERLINE_RESET = "\x1b[24m"

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elems []Object
}

func (*Array) Inspect

func (a *Array) Inspect() string

func (*Array) Type

func (a *Array) Type() ObjectType

type Boolean

type Boolean struct {
	Value bool
}

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (i *Boolean) Inspect() string

func (*Boolean) Type

func (i *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Function       BuiltinFunction
	NumArgs        int // -1 for any
	SupportedTypes []ObjectType
}

func (*Builtin) Inspect

func (f *Builtin) Inspect() string

func (*Builtin) Type

func (f *Builtin) Type() ObjectType

type BuiltinFunction

type BuiltinFunction func(span token.Span, objects ...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) Copy

func (e *Environment) Copy() *Environment

func (*Environment) Get

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

func (*Environment) GetVarArgs

func (e *Environment) GetVarArgs() ([]Object, bool)

func (*Environment) Set

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

func (*Environment) SetVarArgs

func (e *Environment) SetVarArgs(varArgs []Object)

type Error

type Error struct {
	Message string
	Span    token.Span
}

func (*Error) ContextualError

func (e *Error) ContextualError() string

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

type Function

type Function struct {
	Args    []*ast.IdentifierExpr
	VarArgs bool
	Body    *ast.BlockStatement
	Env     *Environment
}

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjectType

type HashEntry

type HashEntry struct {
	Key   Object
	Value Object
}

type HashKey

type HashKey struct {
	Type string
	Hash uint64
}

type HashMap

type HashMap struct {
	Elems map[HashKey]HashEntry
}

func (*HashMap) Inspect

func (a *HashMap) Inspect() string

func (*HashMap) Type

func (a *HashMap) Type() ObjectType

type Hashable

type Hashable interface {
	Object
	HashKey() HashKey
}

type Integer

type Integer struct {
	Value int64
}

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) Type

func (i *Integer) Type() ObjectType

type Null

type Null struct{}

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() ObjectType

type Object

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

type ObjectType

type ObjectType string

type Return

type Return struct {
	Value Object
}

func (*Return) Inspect

func (r *Return) Inspect() string

func (*Return) Type

func (r *Return) 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

type VarArgs

type VarArgs struct {
	Elems []Object
}

func (*VarArgs) Inspect

func (a *VarArgs) Inspect() string

func (*VarArgs) Type

func (a *VarArgs) Type() ObjectType

Jump to

Keyboard shortcuts

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