compiler

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: MIT Imports: 11 Imported by: 2

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

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 type of the function.

func NewCompilationCache

func NewCompilationCache(fn *semantic.FunctionExpression, scope Scope) *CompilationCache

func (*CompilationCache) Compile

func (c *CompilationCache) Compile(in semantic.Type) (Func, error)

Compile returns a compiled function based on the provided type. The result will be cached for subsequent calls.

type Evaluator

type Evaluator interface {
	Type() semantic.Type
	Eval(ctx context.Context, scope Scope) (values.Value, error)
}

type Func

type Func interface {
	FunctionSignature() semantic.FunctionSignature
	Type() semantic.Type
	Eval(ctx context.Context, input values.Object) (values.Value, error)
}

func Compile

func Compile(scope Scope, f *semantic.FunctionExpression, in semantic.Type) (Func, error)

func CompileFnParam

func CompileFnParam(fn *semantic.FunctionExpression, scope Scope, paramType, returnType semantic.Type) (Func, string, error)

CompileFnParam is a utility function for compiling an `fn` parameter for rename or drop/keep. In addition to the function expression, it takes two types to verify the result against: a single argument type, and a single return type.

type Scope

type Scope interface {
	values.Scope
	Get(name string) values.Value
}

func NewScope added in v0.40.0

func NewScope() Scope

func ToScope added in v0.40.0

func ToScope(s values.Scope) Scope

Jump to

Keyboard shortcuts

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