eval

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgCount

type ArgCount byte

ArgCount is the number of arguments passed to a function to be evaluated.

const (
	ArgCountOne ArgCount = iota
	ArgCountTwo
)

func (ArgCount) String

func (c ArgCount) String() string

String returns a string representation of the ArgCount

type Config

type Config struct {
	Ctx *Context
}

Config holds configuration for evaluating expressions on QFrames. It should be considered a private implementation detail and should never be referenced or used directly outside of the QFrame code. To manipulate it use the functions returning ConfigFunc below.

func NewConfig

func NewConfig(ff []ConfigFunc) Config

NewConfig creates a new Config object. This function should never be called from outside QFrame.

type ConfigFunc

type ConfigFunc func(*Config)

ConfigFunc is a function that operates on a Config object.

func EvalContext

func EvalContext(ctx *Context) ConfigFunc

EvalContext sets the evaluation context to use.

type Context

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

Context describes the context in which an expression is executed. It maps function names to actual functions.

func NewDefaultCtx

func NewDefaultCtx() *Context

NewDefaultCtx creates a default context containing a base set of functions. It can be used as is or enhanced with other/more functions. See the source code for the current set of functions.

func (*Context) GetFunc

func (ctx *Context) GetFunc(typ types.FunctionType, ac ArgCount, name string) (interface{}, bool)

GetFunc returns a reference to a function matching the given function type, argument count and name. If no matching function is found in the context the second return value is set to false.

func (*Context) SetFunc

func (ctx *Context) SetFunc(name string, fn interface{}) error

SetFunc inserts a function into the context under the given name.

func (*Context) String

func (ctx *Context) String() string

Jump to

Keyboard shortcuts

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