Documentation
¶
Index ¶
- func Args(e Executor, call *script.CallFunc) ([]interface{}, error)
- func Register(name string, f Function)
- func RegisterFloat1(name string, f func(float64) float64)
- func RegisterFloat2(name string, f func(float64, float64) float64)
- type CreateCloser
- type Executor
- type ExpressionExecutor
- type Function
- func (f Function) Do(e Executor, call *script.CallFunc) error
- func (f Function) RequireArgs(n int) Function
- func (f Function) RequireArgsRange(min, max int) Function
- func (f Function) RequireMaxArgs(n int) Function
- func (f Function) RequireMinArgs(n int) Function
- func (f Function) Then(b Function) Function
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register a Function against a name. This will panic if name has already been registered
func RegisterFloat1 ¶
RegisterFloat1 registers a function that accepts a float64 as its argument and returns a float64. This is common for mathematical functions
Types ¶
type CreateCloser ¶
type CreateCloser interface { io.Closer // Create is called when the resource is referenced before the statement is executed Create() error }
CreateCloser interface implemented by types that can be used as resources
type Executor ¶
type Executor interface { ExpressionExecutor Run() error // ProcessParameters will call each parameter in a CallFunc returning the true values ProcessParameters(*script.CallFunc) ([]interface{}, error) // ArgsToValues will take a slice of arguments and convert to reflect.Value. // This will handle if CallFunc.Variadic is set ArgsToValues(cf *script.CallFunc, tf reflect.Type, args []interface{}) ([]reflect.Value, error) CallReflectFuncImpl(*script.CallFunc, reflect.Value, []interface{}) (interface{}, error) }
type ExpressionExecutor ¶
type ExpressionExecutor interface { Calculator() calculator.Calculator GlobalScope() state.Variables Expression(op *script.Expression) error Statement(statements *script.Statement) error Statements(statements *script.Statements) error }
func NewExpressionExecutor ¶
func NewExpressionExecutor() ExpressionExecutor
NewExpressionExecutor returns an Executor that can evaluate Expressions. All packages are available, but no functions can be defined.
type Function ¶
func FuncDelegate ¶
func (Function) RequireArgs ¶
RequireArgs enforces a function to be called with n arguments
func (Function) RequireArgsRange ¶
RequireArgsRange enforces a function to be called with a range of arguments
func (Function) RequireMaxArgs ¶
RequireMaxArgs enforces a function to be called with a maximum of n arguments
func (Function) RequireMinArgs ¶
RequireMinArgs enforces a function to be called with at least n arguments