Documentation ¶
Overview ¶
Package interpreter provides the implementation of the Flux interpreter.
Index ¶
- func DoFunctionCall(f func(args Arguments) (values.Value, error), argsObj values.Object) (values.Value, error)
- func ToFloatArray(a values.Array) ([]float64, error)
- func ToStringArray(a values.Array) ([]string, error)
- type Arguments
- type Importer
- type Interpreter
- type Package
- func (p *Package) Array() values.Array
- func (p *Package) Bool() bool
- func (p *Package) Bytes() []byte
- func (p *Package) Copy() *Package
- func (p *Package) Duration() values.Duration
- func (p *Package) Equal(rhs values.Value) bool
- func (p *Package) Float() float64
- func (p *Package) Function() values.Function
- func (p *Package) Get(name string) (values.Value, bool)
- func (p *Package) Int() int64
- func (p *Package) IsNull() bool
- func (p *Package) Len() int
- func (p *Package) Name() string
- func (p *Package) Object() values.Object
- func (p *Package) PolyType() semantic.PolyType
- func (p *Package) Range(f func(name string, v values.Value))
- func (p *Package) Regexp() *regexp.Regexp
- func (p *Package) Set(name string, v values.Value)
- func (p *Package) SideEffects() []SideEffect
- func (p *Package) Str() string
- func (p *Package) String() string
- func (p *Package) Time() values.Time
- func (p *Package) Type() semantic.Type
- func (p *Package) UInt() uint64
- type ResolvedFunction
- type Resolver
- type SideEffect
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoFunctionCall ¶
Types ¶
type Arguments ¶
type Arguments interface { GetAll() []string Get(name string) (values.Value, bool) GetRequired(name string) (values.Value, error) GetString(name string) (string, bool, error) GetInt(name string) (int64, bool, error) GetFloat(name string) (float64, bool, error) GetBool(name string) (bool, bool, error) GetFunction(name string) (values.Function, bool, error) GetArray(name string, t semantic.Nature) (values.Array, bool, error) GetObject(name string) (values.Object, bool, error) GetRequiredString(name string) (string, error) GetRequiredInt(name string) (int64, error) GetRequiredFloat(name string) (float64, error) GetRequiredBool(name string) (bool, error) GetRequiredFunction(name string) (values.Function, error) GetRequiredArray(name string, t semantic.Nature) (values.Array, error) GetRequiredObject(name string) (values.Object, error) // contains filtered or unexported methods }
Arguments provides access to the keyword arguments passed to a function. semantic.The Get{Type} methods return three values: the typed value of the arg, whether the argument was specified and any errors about the argument type. semantic.The GetRequired{Type} methods return only two values, the typed value of the arg and any errors, a missing argument is considered an error in this case.
func NewArguments ¶
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter() *Interpreter
func (*Interpreter) Eval ¶
func (itrp *Interpreter) Eval(node semantic.Node, scope values.Scope, importer Importer) ([]SideEffect, error)
Eval evaluates the expressions composing a Flux package and returns any side effects that occurred during this evaluation.
type Package ¶ added in v0.10.0
type Package struct {
// contains filtered or unexported fields
}
func NewPackage ¶ added in v0.14.0
func NewPackageWithValues ¶ added in v0.14.0
func (*Package) SideEffects ¶ added in v0.10.0
func (p *Package) SideEffects() []SideEffect
type ResolvedFunction ¶ added in v0.40.0
type ResolvedFunction struct { Fn *semantic.FunctionExpression `json:"fn"` Scope values.Scope `json:"-"` }
ResolvedFunction represents a function that can be passed down to the compiler. Both the function expression and scope are captured. The scope cannot be serialized, which is no longer a problem in the current design with excpetion of the REPL which will not be able to correct pass through the scope.
func ResolveFunction ¶
func ResolveFunction(f values.Function) (ResolvedFunction, error)
ResolveFunction produces a function that can execute externally.
func (ResolvedFunction) Copy ¶ added in v0.40.0
func (r ResolvedFunction) Copy() ResolvedFunction
type Resolver ¶
Resolver represents a value that can resolve itself. Resolving is the action of capturing the scope at function declaration and replacing any identifiers with static values from the scope where possible. TODO(nathanielc): Improve implementations of scope to only preserve values in the scope that are referrenced.
type SideEffect ¶ added in v0.29.0
SideEffect contains its value, and the semantic node that generated it.
type Value ¶
type Value interface { // Type reports the type of value Type() semantic.Type // Value returns the actual value represented. Value() interface{} // Property returns a new value which is a property of this value. Property(name string) (values.Value, error) }
Value represents any value that can be the result of evaluating any expression.