interpreter_env

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayVal

type ArrayVal struct {
	Type     ValueType
	Elements []RuntimeValue
}

func (ArrayVal) GetElements

func (a ArrayVal) GetElements() []any

func (ArrayVal) GetType

func (a ArrayVal) GetType() ValueType

func (ArrayVal) GetValue

func (a ArrayVal) GetValue() any

type BooleanVal

type BooleanVal struct {
	Type  ValueType
	Value bool
}

func (BooleanVal) GetType

func (b BooleanVal) GetType() ValueType

func (BooleanVal) GetValue

func (b BooleanVal) GetValue() any

type Environment

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

func New

func New(parentENV *Environment) Environment

func (*Environment) AssignVar

func (e *Environment) AssignVar(varName string, value RuntimeValue) (RuntimeValue, error)

func (*Environment) DeclareVar

func (e *Environment) DeclareVar(varName string, value RuntimeValue, constant bool) (RuntimeValue, error)

func (*Environment) LookupVar

func (e *Environment) LookupVar(varName string) (RuntimeValue, error)

func (*Environment) Resolve

func (e *Environment) Resolve(varName string) (Environment, error)

Returns the environment that contains the variable

type FunctionCall

type FunctionCall = func(args []RuntimeValue, env Environment) RuntimeValue

type FunctionVal

type FunctionVal struct {
	Type           ValueType
	Name           *string
	Params         []ast.Identifier
	DeclarationEnv *Environment
	Body           []ast.Stmt
}

func (FunctionVal) GetType

func (f FunctionVal) GetType() ValueType

func (FunctionVal) GetValue

func (f FunctionVal) GetValue() any

type NaNVal

type NaNVal struct {
	Type  ValueType
	Value string
}

func (NaNVal) GetType

func (n NaNVal) GetType() ValueType

func (NaNVal) GetValue

func (n NaNVal) GetValue() any

type NullVal

type NullVal struct {
	Type  ValueType
	Value any // nil
}

func (NullVal) GetType

func (n NullVal) GetType() ValueType

func (NullVal) GetValue

func (n NullVal) GetValue() any

type NumberVal

type NumberVal struct {
	Type  ValueType
	Value float64
}

func (NumberVal) GetType

func (n NumberVal) GetType() ValueType

func (NumberVal) GetValue

func (n NumberVal) GetValue() any

type ObjectVal

type ObjectVal struct {
	Type       ValueType
	Properties map[string]RuntimeValue
}

func (ObjectVal) GetType

func (o ObjectVal) GetType() ValueType

func (ObjectVal) GetValue

func (o ObjectVal) GetValue() any

type RuntimeValue

type RuntimeValue interface {
	GetType() ValueType
	GetValue() any
}

type StringVal

type StringVal struct {
	Type  ValueType
	Value string
}

func (StringVal) GetType

func (s StringVal) GetType() ValueType

func (StringVal) GetValue

func (s StringVal) GetValue() any

type ValueType

type ValueType string
const (
	Null          ValueType = "null"
	Number        ValueType = "number"
	String        ValueType = "string"
	Boolean       ValueType = "boolean"
	Object        ValueType = "object"
	Function      ValueType = "function"
	ArrowFunction ValueType = "arrow_function"
	Array         ValueType = "array"
)

Value types

Jump to

Keyboard shortcuts

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