object

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INT_OBJ        = "INTEGER"
	FLOAT_OBJ      = "FLOAT"
	BOOL_OBJ       = "BOOLEAN"
	RETURN_VAL_OBJ = "RETURN_VAL"
	NULL_OBJ       = "NIL"
	ERR_OBJ        = "ERROR"
	FUNC_OBJ       = "FUNCTION"
	STRING_OBJ     = "STRING"
	BUILTIN_OBJ    = "BUILTIN"
	ARRAY_OBJ      = "ARRAY"
	HASH_OBJ       = "HASH"
	NUM_OBJ        = "NUM"
	INCLUDE_OBJ    = "INCLUDE"
	SHOW_OBJ       = "SHOW"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elms  []Obj
	Token token.Token
}

func (*Array) GetToken

func (a *Array) GetToken() token.Token

func (*Array) Inspect

func (a *Array) Inspect() string

func (*Array) Type

func (a *Array) Type() ObjType

type Boolean

type Boolean struct {
	Value bool
	Token token.Token
}

Booleans true,false

func (*Boolean) GetToken

func (b *Boolean) GetToken() token.Token

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() ObjType

type BuiltInFunc

type BuiltInFunc func(args ...Obj) Obj

type Builtin

type Builtin struct {
	Fn    BuiltInFunc
	Token token.Token
}

func (*Builtin) GetToken

func (b *Builtin) GetToken() token.Token

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() ObjType

type Env

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

func NewEnclosedEnv

func NewEnclosedEnv(outer *Env) *Env

func NewEnv

func NewEnv() *Env

func (*Env) Get

func (e *Env) Get(n string) (Obj, bool)

func (*Env) Set

func (e *Env) Set(n string, v Obj) Obj

type Error

type Error struct {
	Msg string
}

func (*Error) GetToken

func (e *Error) GetToken() token.Token

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjType

type Function

type Function struct {
	Params []*ast.Identifier
	Body   *ast.BlockStmt
	Env    *Env
	Token  token.Token
}

func (*Function) GetToken

func (f *Function) GetToken() token.Token

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjType

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
	Token token.Token
}

func (*Hash) GetToken

func (h *Hash) GetToken() token.Token

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) Type

func (h *Hash) Type() ObjType

type HashKey

type HashKey struct {
	Type  ObjType
	Value uint64
	Token token.Token
}

type HashPair

type HashPair struct {
	Key   Obj
	Value Obj
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type IncludeObj

type IncludeObj struct {
	Filename string
	Token    token.Token
}

func (*IncludeObj) GetToken

func (ib *IncludeObj) GetToken() token.Token

func (*IncludeObj) Inspect

func (ib *IncludeObj) Inspect() string

func (*IncludeObj) Type

func (ib *IncludeObj) Type() ObjType

type Null

type Null struct{}

NULL_OBJ

func (*Null) GetToken

func (n *Null) GetToken() token.Token

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() ObjType

type Number

type Number struct {
	Value number.Number
	IsInt bool
	Token token.Token
}

func (*Number) GetToken

func (num *Number) GetToken() token.Token

func (*Number) HashKey

func (n *Number) HashKey() HashKey

func (*Number) Inspect

func (num *Number) Inspect() string

func (*Number) Type

func (num *Number) Type() ObjType

type Obj

type Obj interface {
	Type() ObjType
	Inspect() string
	GetToken() token.Token
}

func MakeIntNumber

func MakeIntNumber(i int64) Obj

type ObjType

type ObjType string

type ReturnValue

type ReturnValue struct {
	Value Obj
	Token token.Token
}

func (*ReturnValue) GetToken

func (r *ReturnValue) GetToken() token.Token

func (*ReturnValue) Inspect

func (r *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (r *ReturnValue) Type() ObjType

type ShowObj

type ShowObj struct {
	Value []string
	Token token.Token
}

func (*ShowObj) GetToken

func (so *ShowObj) GetToken() token.Token

func (*ShowObj) Inspect

func (so *ShowObj) Inspect() string

func (*ShowObj) Print

func (so *ShowObj) Print(b bytes.Buffer)

func (*ShowObj) Type

func (so *ShowObj) Type() ObjType

type String

type String struct {
	Value string
	Token token.Token
}

Strings "I am a string"

func (*String) GetToken

func (s *String) GetToken() token.Token

func (*String) HashKey

func (s *String) HashKey() HashKey

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Type

func (s *String) Type() ObjType

Jump to

Keyboard shortcuts

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