object

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeError   RuntimeErrorType = "Type Error"
	KeyError    RuntimeErrorType = "Key Error"
	HexError                     = "Hex Error"
	ElfError                     = "Elf Error"
	BytesError                   = "Bytes Error"
	FileError                    = "File Error"
	CustomError                  = "Runtime Error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []Object
}

func (*Array) Inspect

func (arr *Array) Inspect() string

func (*Array) Type

func (arr *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) Type

func (b *Boolean) Type() ObjectType

type Builtin

type Builtin struct {
	Name     string
	ArgTypes []ObjectType
	Function BuiltinFunction
}

func (*Builtin) Call added in v0.4.0

func (b *Builtin) Call(args ...Object) Object

func (*Builtin) GetBuiltinArgTypes added in v0.4.0

func (b *Builtin) GetBuiltinArgTypes() []ObjectType

func (*Builtin) GetBuiltinName added in v0.4.0

func (b *Builtin) GetBuiltinName() string

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

type BytesFile added in v0.3.0

type BytesFile struct {
	Bytes *bytes.File
	// contains filtered or unexported fields
}

func NewBytesFile added in v0.3.0

func NewBytesFile(name string, perms uint32, size int64, bytesFile *bytes.File) *BytesFile

func (*BytesFile) AsBytes added in v0.3.0

func (bf *BytesFile) AsBytes() []byte

func (*BytesFile) Inspect added in v0.3.0

func (bf *BytesFile) Inspect() string

func (*BytesFile) Name added in v0.3.0

func (bf *BytesFile) Name() string

func (*BytesFile) Perms added in v0.3.0

func (bf *BytesFile) Perms() uint32

func (*BytesFile) Type added in v0.3.0

func (bf *BytesFile) Type() ObjectType

type CallableBuiltin added in v0.4.0

type CallableBuiltin interface {
	GetBuiltinName() string
	GetBuiltinArgTypes() []ObjectType
	Call(args ...Object) Object
}

type ElfFile added in v0.3.0

type ElfFile struct {
	File *elf.File
	// contains filtered or unexported fields
}

func NewElfFile added in v0.3.0

func NewElfFile(name string, perms uint32, elffile *elf.File) *ElfFile

func (*ElfFile) AsBytes added in v0.3.0

func (ef *ElfFile) AsBytes() []byte

func (*ElfFile) Inspect added in v0.3.0

func (ef *ElfFile) Inspect() string

func (*ElfFile) Name added in v0.3.0

func (ef *ElfFile) Name() string

func (*ElfFile) Perms added in v0.3.0

func (ef *ElfFile) Perms() uint32

func (*ElfFile) Type added in v0.3.0

func (ef *ElfFile) Type() ObjectType

type Environment

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

func NewEnvironment

func NewEnvironment() *Environment

func WrappedEnvironment

func WrappedEnvironment(outerEnv *Environment) *Environment

func (*Environment) Get

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

func (*Environment) IsNestedBlock

func (env *Environment) IsNestedBlock() bool

func (*Environment) Set

func (env *Environment) Set(name string, obj Object) Object

type Error

type Error struct {
	Message string
}

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

type File added in v0.3.0

type File interface {
	Name() string
	Perms() uint32
	AsBytes() []byte
}

type Function

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

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjectType

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type HexFile added in v0.2.0

type HexFile struct {
	File *hex.File
	// contains filtered or unexported fields
}

func NewHexFile added in v0.3.0

func NewHexFile(name string, perms uint32, hexfile *hex.File) *HexFile

func (*HexFile) AsBytes added in v0.3.0

func (hf *HexFile) AsBytes() []byte

func (*HexFile) Inspect added in v0.2.0

func (hf *HexFile) Inspect() string

func (*HexFile) Name added in v0.2.0

func (hf *HexFile) Name() string

func (*HexFile) Perms added in v0.3.0

func (hf *HexFile) Perms() uint32

func (*HexFile) Type added in v0.2.0

func (hf *HexFile) Type() ObjectType

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 Map

type Map struct {
	Mappings map[HashKey]HashPair
}

func (*Map) Inspect

func (h *Map) Inspect() string

func (*Map) Type

func (h *Map) Type() ObjectType

type Method

type Method struct {
	Name       string
	ArgTypes   []ObjectType
	MethodFunc MethodFunction
}

func (*Method) Call added in v0.4.0

func (m *Method) Call(args ...Object) Object

func (*Method) GetBuiltinArgTypes added in v0.4.0

func (m *Method) GetBuiltinArgTypes() []ObjectType

func (*Method) GetBuiltinName added in v0.4.0

func (m *Method) GetBuiltinName() string

func (*Method) Inspect

func (m *Method) Inspect() string

func (*Method) Type

func (m *Method) Type() ObjectType

type MethodFunction

type MethodFunction func(this Object, args ...Object) Object

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
const (
	AnyObj      ObjectType = "Any"
	AnyVarargs  ObjectType = "Any Varargs"
	AnyOptional ObjectType = "Any optional"

	NullObj         ObjectType = "Null"
	TypeObj         ObjectType = "Type"
	SetObj          ObjectType = "Set"
	MapObj          ObjectType = "Map"
	HexObj          ObjectType = "Hex File"
	ElfObj          ObjectType = "Elf File"
	BytesObj        ObjectType = "Bytes File"
	ErrorObj        ObjectType = "Error"
	ArrayObj        ObjectType = "Array"
	StringObj       ObjectType = "String"
	MethodObj       ObjectType = "Method"
	IntegerObj      ObjectType = "Int"
	BooleanObj      ObjectType = "Bool"
	BuiltinObj      ObjectType = "Builtin Function"
	FunctionObj     ObjectType = "Function"
	RuntimeErrorObj ObjectType = "Runtime Error"
	ReturnValueObj  ObjectType = "Return value"
)

func OrType added in v0.4.0

func OrType(baseTypes ...ObjectType) ObjectType

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

type RuntimeError added in v0.5.0

type RuntimeError struct {
	Kind    RuntimeErrorType
	Message string
}

func (*RuntimeError) Inspect added in v0.5.0

func (ee *RuntimeError) Inspect() string

func (*RuntimeError) Type added in v0.5.0

func (ee *RuntimeError) Type() ObjectType

type RuntimeErrorType added in v0.5.0

type RuntimeErrorType string

type Set added in v0.2.0

type Set struct {
	Elements map[HashKey]Object
}

func (*Set) Inspect added in v0.2.0

func (s *Set) Inspect() string

func (*Set) Type added in v0.2.0

func (s *Set) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) HashKey

func (str *String) HashKey() HashKey

func (*String) Inspect

func (str *String) Inspect() string

func (*String) Type

func (str *String) Type() ObjectType

type Type

type Type struct {
	Value ObjectType
}

func (*Type) Inspect

func (t *Type) Inspect() string

func (*Type) Type

func (t *Type) Type() ObjectType

Jump to

Keyboard shortcuts

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