object

package
v0.0.0-...-8278936 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_OBJ = "ERROR"
	NULL_OBJ  = "NULL"

	RETURN_VALUE_OBJ = "RETURN_VALUE"

	INTEGER_OBJ  = "INTEGER"
	BOOLEAN_OBJ  = "BOOLEAN"
	STRING_OBJ   = "STRING"
	ARRAY_OBJ    = "ARRAY"
	HASH_MAP_OBJ = "HASH_MAP"

	FUNCTION_OBJ = "FUNCTION"
	BUILTIN_OBJ  = "BUILTIN"
)

Variables

This section is empty.

Functions

func ExtractRawValueFromObject

func ExtractRawValueFromObject(obj Object) (any, bool)

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) ToString

func (a *Array) ToString() 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) ToString

func (b *Boolean) ToString() string

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

func (*Builtin) ToString

func (b *Builtin) ToString() string

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

type Env

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

func ConvertContextToEnv

func ConvertContextToEnv(ctx *context.Context, env *Env, vars *[]string) (*Env, error)

func NewEnclosedEnv

func NewEnclosedEnv(outer *Env) *Env

func NewEnv

func NewEnv() *Env

func (*Env) Get

func (e *Env) Get(key string) (Object, bool)

func (*Env) Set

func (e *Env) Set(key string, val Object) Object

type Error

type Error struct {
	Message string
}

func (*Error) ToString

func (e *Error) ToString() string

func (*Error) Type

func (e *Error) Type() ObjectType

type Function

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

func (*Function) ToString

func (f *Function) ToString() string

func (*Function) Type

func (f *Function) Type() ObjectType

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashMap

type HashMap struct {
	Pairs map[HashKey]HashPair
}

func (*HashMap) ToString

func (h *HashMap) ToString() string

func (*HashMap) Type

func (h *HashMap) Type() ObjectType

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type Integer

type Integer struct {
	Value int64
}

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

func (*Integer) ToString

func (i *Integer) ToString() string

func (*Integer) Type

func (i *Integer) Type() ObjectType

type Null

type Null struct{}

func (*Null) ToString

func (n *Null) ToString() string

func (*Null) Type

func (n *Null) Type() ObjectType

type Object

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

type ObjectType

type ObjectType string

type Return

type Return struct {
	Value Object
}

func (*Return) ToString

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

func (s *String) ToString() 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