Documentation
¶
Overview ¶
The compiler package provides a compiler and Go runtime for a subset of the Flux language. Only pure functions are supported by the compiler. A function is compiled and then may be called repeatedly with different arguments. The function must be pure meaning it has no side effects. Other language features are not supported.
This runtime is not portable by design. The runtime consists of Go types that have been constructed based on the Flux function being compiled. Those types are not serializable and cannot be transported to other systems or environments. This design is intended to limit the scope under which compilation must be supported.
Index ¶
- type CompilationCache
- type Evaluator
- type Func
- type Scope
- func (s Scope) Copy() Scope
- func (s Scope) GetArray(name string) values.Array
- func (s Scope) GetBool(name string) bool
- func (s Scope) GetDuration(name string) values.Duration
- func (s Scope) GetFloat(name string) float64
- func (s Scope) GetFunction(name string) values.Function
- func (s Scope) GetInt(name string) int64
- func (s Scope) GetObject(name string) values.Object
- func (s Scope) GetRegexp(name string) *regexp.Regexp
- func (s Scope) GetString(name string) string
- func (s Scope) GetTime(name string) values.Time
- func (s Scope) GetUInt(name string) uint64
- func (s Scope) Set(name string, v values.Value)
- func (s Scope) Type(name string) semantic.Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompilationCache ¶
type CompilationCache struct {
// contains filtered or unexported fields
}
CompilationCache caches compilation results based on the types of the input parameters.
func NewCompilationCache ¶
func NewCompilationCache(fn *semantic.FunctionExpression, scope Scope, decls semantic.DeclarationScope) *CompilationCache
type Evaluator ¶
type Evaluator interface {
Type() semantic.Type
EvalString(scope Scope) string
EvalInt(scope Scope) int64
EvalUInt(scope Scope) uint64
EvalFloat(scope Scope) float64
EvalBool(scope Scope) bool
EvalTime(scope Scope) values.Time
EvalDuration(scope Scope) values.Duration
EvalRegexp(scope Scope) *regexp.Regexp
EvalArray(scope Scope) values.Array
EvalObject(scope Scope) values.Object
EvalFunction(scope Scope) values.Function
}
type Func ¶
type Func interface {
Type() semantic.Type
EvalString(scope Scope) (string, error)
Eval(scope Scope) (values.Value, error)
EvalInt(scope Scope) (int64, error)
EvalUInt(scope Scope) (uint64, error)
EvalFloat(scope Scope) (float64, error)
EvalBool(scope Scope) (bool, error)
EvalTime(scope Scope) (values.Time, error)
EvalDuration(scope Scope) (values.Duration, error)
EvalRegexp(scope Scope) (*regexp.Regexp, error)
EvalArray(scope Scope) (values.Array, error)
EvalObject(scope Scope) (values.Object, error)
EvalFunction(scope Scope) (values.Function, error)
}