eval

package
v0.3.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package eval contains the high level CUE evaluation strategy.

CUE allows for a significant amount of freedom in order of evaluation due to the commutativity of the unification operation. This package implements one of the possible strategies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(ctx *adt.OpContext, v, w adt.Value) bool

func Evaluate

func Evaluate(r adt.Runtime, v *adt.Vertex)

func NewContext

func NewContext(r adt.Runtime, v *adt.Vertex) *adt.OpContext

Types

type CloseDef

type CloseDef struct {
	Src   adt.Node // for error reporting
	ID    uint32
	IsAnd bool
	List  []*CloseDef
}

CloseDef defines how individual FieldSets (corresponding to conjuncts) combine to determine whether a field is contained in a closed set.

Nodes with a non-empty List and IsAnd is false represent embeddings. The ID is the node that contained the embedding in that case.

Nodes with a non-empty List and IsAnd is true represent conjunctions of definitions. In this case, a field must be contained in each definition.

If a node has both conjunctions of definitions and embeddings, only the former are maintained. Conjunctions of definitions define an upper bound of the set of allowed fields in that case and the embeddings will not add any value.

type Evaluator

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

func New

func New(r adt.Runtime) *Evaluator

func (*Evaluator) Eval

func (e *Evaluator) Eval(v *adt.Vertex) errors.Error

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(c *adt.OpContext, v *adt.Vertex) adt.Value

Evaluate is used to evaluate a sub expression while evaluating a Vertex with Unify. It may or may not return the original Vertex. It may also terminate evaluation early if it has enough evidence that a certain value can be the only value in a valid configuration. This means that an error may go undetected at this point, as long as it is caught later.

func (*Evaluator) NewContext

func (e *Evaluator) NewContext(v *adt.Vertex) *adt.OpContext

func (*Evaluator) Stats

func (e *Evaluator) Stats() *Stats

func (*Evaluator) Unify

func (e *Evaluator) Unify(c *adt.OpContext, v *adt.Vertex, state adt.VertexStatus)

Unify implements adt.Unifier.

May not evaluate the entire value, but just enough to be able to compute.

Phase one: record everything concrete Phase two: record incomplete Phase three: record cycle.

func (*Evaluator) UnifyAccept

func (e *Evaluator) UnifyAccept(c *adt.OpContext, v *adt.Vertex, state adt.VertexStatus, accept adt.Acceptor)

UnifyAccept is like Unify, but takes an extra argument to override the accepted set of fields.

Instead of deriving the allowed set of fields, it verifies this set by consulting the given Acceptor. This can be useful when splitting an existing values into individual conjuncts and then unifying some of its components back into a new value. Under normal circumstances, this may not always succeed as the missing context may result in stricter closedness rules.

type Stats

type Stats struct {
	DisjunctCount int
	UnifyCount    int
}

func (*Stats) String

func (s *Stats) String() string

Jump to

Keyboard shortcuts

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