object

package
v0.0.0-...-5957b22 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOOL     = "BOOL"
	INTEGER  = "INTEGER"
	FUNCTION = "FUNCTION"
	STRUCT   = "STRUCT"
	RETURN   = "RETURN"
	STRING   = "STRING"
	BUILTIN  = "BULITIN" // builtin functions from the host language
	LIST     = "LIST"
	HASHMAP  = "HASHMAP"
)

Types

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	Value bool
}

Boolean type

func (*Bool) FormattedString

func (b *Bool) FormattedString() string

func (*Bool) Hash

func (b *Bool) Hash() HashKey

func (*Bool) RawType

func (b *Bool) RawType() string

func (*Bool) String

func (b *Bool) String() string

func (*Bool) Type

func (b *Bool) Type() string

type BuiltinFunction

type BuiltinFunction struct {
	Name string
	Fn   func(args ...Object) Object
}

func (*BuiltinFunction) FormattedString

func (bf *BuiltinFunction) FormattedString() string

func (*BuiltinFunction) RawType

func (bf *BuiltinFunction) RawType() string

func (*BuiltinFunction) String

func (bf *BuiltinFunction) String() string

func (*BuiltinFunction) Type

func (bf *BuiltinFunction) Type() string

type Callable

type Callable interface {
	Call() Object
}

All the call-able objects will implement this interface i.e. functions

type Function

type Function struct {
	FunctionStatement ast.FunctionStatement
}

Function type, it is an Object as well as a Callable

func (*Function) Call

func (f *Function) Call()

The call functions should return an object in the case of something like var x = function(...)

func (*Function) FormattedString

func (f *Function) FormattedString() string

func (*Function) RawType

func (f *Function) RawType() string

func (*Function) String

func (f *Function) String() string

func (*Function) Type

func (f *Function) Type() string

type HashKey

type HashKey struct {
	Type  string
	Value int
}

TODO : Type can either be an `object` or a `string` But for now I think string will work just fine? Objects will implement RawType() which can then be used to supply this value.

type HashMap

type HashMap struct {
	Value map[HashKey]HashValue
}

Hashmap container type Note : Hashmaps maps object.Object to object.Object

func (*HashMap) FormattedString

func (hm *HashMap) FormattedString() string

func (*HashMap) RawType

func (hm *HashMap) RawType() string

func (*HashMap) String

func (hm *HashMap) String() string

func (*HashMap) Type

func (hm *HashMap) Type() string

type HashValue

type HashValue struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	Hash() HashKey
}

All hashable objects will implement this interface i.e. anything that can be used as a hashmap key

type Integer

type Integer struct {
	Value int64
}

Integer type

func (*Integer) FormattedString

func (i *Integer) FormattedString() string

func (*Integer) Hash

func (i *Integer) Hash() HashKey

func (*Integer) RawType

func (i *Integer) RawType() string

func (*Integer) String

func (i *Integer) String() string

func (*Integer) Type

func (i *Integer) Type() string

type List

type List struct {
	Value []Object
}

Container types - Lists/Hashmaps List container type

func (*List) FormattedString

func (l *List) FormattedString() string

func (*List) RawType

func (l *List) RawType() string

func (*List) String

func (l *List) String() string

func (*List) Type

func (l *List) Type() string

type Object

type Object interface {
	RawType() string
	Type() string
	String() string
	// This is for something like the String type; where it adds '"' with it
	// Otherwise, this will return the same as String() for most types.
	FormattedString() string
}

All types implement this interface

type Return

type Return struct {
	Value Object
}

Return type, this is only for the interpreter and is not for use normally.

func (*Return) FormattedString

func (r *Return) FormattedString() string

func (*Return) RawType

func (r *Return) RawType() string

func (*Return) String

func (r *Return) String() string

func (*Return) Type

func (r *Return) Type() string

type String

type String struct {
	Value string
}

String type

func (*String) FormattedString

func (s *String) FormattedString() string

func (*String) Hash

func (s *String) Hash() HashKey

func (*String) RawType

func (s *String) RawType() string

func (*String) String

func (s *String) String() string

func (*String) Type

func (s *String) Type() string

type Struct

type Struct struct {
	Name       string
	HasInit    bool
	Attributes map[string]Object
	Methods    map[string]Object
}

func (*Struct) FormattedString

func (s *Struct) FormattedString() string

func (*Struct) RawType

func (s *Struct) RawType() string

func (*Struct) String

func (s *Struct) String() string

func (*Struct) Type

func (s *Struct) Type() string

Jump to

Keyboard shortcuts

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