goeval

package
v0.0.0-...-06b88cf Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Builtins = map[string]interface{}{
		"nil":    nil,
		"true":   true,
		"false":  false,
		"append": Append,
		"make":   Make,
		"len":    Len,
	}
)

Functions

func Append

func Append(arr interface{}, elems ...interface{}) (interface{}, error)

Append is a runtime replacement for the append function

func ComputeBinaryOp

func ComputeBinaryOp(xI, yI interface{}, op token.Token) (interface{}, error)

ComputeBinaryOp executes the corresponding binary operation (+, -, etc) on two interfaces.

func ComputeUnaryOp

func ComputeUnaryOp(xI interface{}, op token.Token) (interface{}, error)

ComputeUnaryOp computes the corresponding unary (+x, -x) operation on an interface.

func Len

func Len(t interface{}) (interface{}, error)

Len is a runtime replacement for the len function

func Make

func Make(t interface{}, args ...interface{}) (interface{}, error)

Make is a runtime replacement for the make function

func NewActivity

func NewActivity(metadata *activity.Metadata) activity.Activity

NewActivity TCI Wi Activity

func StringToType

func StringToType(str string) (reflect.Type, error)

StringToType returns the reflect.Type corresponding to the type string provided. Ex: StringToType("int")

func ValuesToInterfaces

func ValuesToInterfaces(vals []reflect.Value) []interface{}

ValuesToInterfaces converts a slice of []reflect.Value to []interface{}

Types

type Scope

type Scope struct {
	Vals   map[string]interface{} // all variables in current scope
	Parent *Scope
}

variable scope, recursive definition

func NewScope

func NewScope() *Scope

create a new variable scope

func (*Scope) Eval

func (s *Scope) Eval(str string) (interface{}, error)

Eval evaluates a string

func (*Scope) Get

func (scope *Scope) Get(name string) (val interface{})

search variable from inner-most scope

func (*Scope) Interpret

func (scope *Scope) Interpret(expr ast.Node) (interface{}, error)

Interpret interprets an ast.Node and returns the value.

func (*Scope) Keys

func (scope *Scope) Keys() (keys []string)

Keys returns all keys in scope

func (*Scope) NewChild

func (scope *Scope) NewChild() *Scope

NewChild creates a scope under the existing scope.

func (*Scope) Set

func (scope *Scope) Set(name string, val interface{})

Set walks the scope and sets a value in a parent scope if it exists, else current.

Jump to

Keyboard shortcuts

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