object

package
v0.0.0-...-9edbcb8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INTEGER_OBJ      = "INTEGER"
	FLOAT_OBJ        = "FLOAT"
	BOOLEAN_OBJ      = "BOOLEAN"
	STRING_OBJ       = "STRING"
	ARRAY_OBJ        = "ARRAY"
	HASHMAP_OBJ      = "HASHMAP"
	FUNCTION_OBJ     = "FUNCTION"
	BUILTIN_OBJ      = "BUILTIN"
	PACKAGE_OBJ      = "PACKAGE"
	NULL_OBJ         = "NULL"
	RETURN_VALUE_OBJ = "RETURN_VALUE"
	BREAK_OBJ        = "BREAK"
	ERROR_OBJ        = "ERROR"
)

Variables

View Source
var ArrayMemberFunc func(name string) MemberFunc
View Source
var BooleanMemberFunc func(string) MemberFunc
View Source
var FloatMemberFunc func(string) MemberFunc
View Source
var HashMapMemberFunc func(name string) MemberFunc
View Source
var IntegerMemberFunc func(string) MemberFunc
View Source
var StringMemberFunc func(string) MemberFunc

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) Inspect

func (ao *Array) Inspect() string

func (*Array) Member

func (ao *Array) Member(name string) MemberFunc

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) Member

func (b *Boolean) Member(name string) MemberFunc

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type Break

type Break struct {
}

func (*Break) Inspect

func (br *Break) Inspect() string

func (*Break) Member

func (br *Break) Member(name string) MemberFunc

func (*Break) Type

func (br *Break) Type() ObjectType

type Builtin

type Builtin struct {
	Func FunctionFunc
}

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Member

func (b *Builtin) Member(name string) MemberFunc

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type Environment

type Environment struct {
	Stdout       io.Writer
	TimeProvider func() time.Time
	// contains filtered or unexported fields
}

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) Builtin

func (e *Environment) Builtin(name string) *Builtin

func (*Environment) Get

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

func (*Environment) Import

func (e *Environment) Import(name string) (Package, bool)

func (*Environment) RegisterPackages

func (e *Environment) RegisterPackages(pkgs ...Package)

func (*Environment) Set

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

func (*Environment) Type

func (e *Environment) Type(pkgName string, name string, initial Object) Object

type Error

type Error struct {
	Message string
}

func Errorf

func Errorf(format string, args ...any) *Error

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Member

func (e *Error) Member(name string) MemberFunc

func (*Error) Type

func (e *Error) Type() ObjectType

type Float

type Float struct {
	Value float64
}

func (*Float) HashKey

func (f *Float) HashKey() HashKey

func (*Float) Inspect

func (f *Float) Inspect() string

func (*Float) Member

func (f *Float) Member(name string) MemberFunc

func (*Float) Type

func (f *Float) 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) Member

func (br *Function) Member(name string) MemberFunc

func (*Function) Type

func (f *Function) Type() ObjectType

type FunctionFunc

type FunctionFunc func(args ...Object) Object

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashMap

type HashMap struct {
	Pairs map[HashKey]HashPair
}

func (*HashMap) Inspect

func (h *HashMap) Inspect() string

func (*HashMap) Member

func (h *HashMap) Member(name string) MemberFunc

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) Inspect

func (i *Integer) Inspect() string

func (*Integer) Member

func (i *Integer) Member(name string) MemberFunc

func (*Integer) Type

func (i *Integer) Type() ObjectType

type MemberFunc

type MemberFunc func(receiver Object, args ...Object) Object

type Null

type Null struct{}

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Member

func (n *Null) Member(name string) MemberFunc

func (*Null) Type

func (n *Null) Type() ObjectType

type Object

type Object interface {
	Type() ObjectType
	Member(name string) MemberFunc
	Inspect() string
}

type ObjectType

type ObjectType string

type Package

type Package interface {
	Object
	Name() string
	Member(name string) MemberFunc
	OnLoad(*Environment)
}

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Member

func (rv *ReturnValue) Member(name string) MemberFunc

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) Member

func (b *String) Member(name string) MemberFunc

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