Skip to content

Commit

Permalink
internal/core: add runtime hooks
Browse files Browse the repository at this point in the history
These hooks are temporary and are there to facilitate
the port of the old API on top of the new evaluator.

Eventually some of these hooks can go away.

Change-Id: I54b79194546d26e27dda1c0939e467951bf5e4a2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6517
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
  • Loading branch information
mpvl committed Jul 19, 2020
1 parent e986a8f commit 6a495ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/core/adt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ type OpContext struct {
tentative int // set during comprehension evaluation
}

// Impl is for internal use only. This will go.
func (c *OpContext) Impl() Runtime {
return c.config.Runtime
}

// If IsTentative is set, evaluation of an arc should not finalize
// to non-concrete values.
func (c *OpContext) IsTentative() bool {
Expand Down
3 changes: 3 additions & 0 deletions internal/core/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
// A Runtime maintains data structures for indexing and resuse for evaluation.
type Runtime struct {
index *Index

// Data holds the legacy index strut. It is for transitional purposes only.
Data interface{}
}

// New creates a new Runtime.
Expand Down
8 changes: 8 additions & 0 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ var UnifyBuiltin func(v interface{}, kind string) interface{}
// GetRuntime reports the runtime for an Instance or Value.
var GetRuntime func(instance interface{}) interface{}

// GetRuntime reports the runtime for an Instance or Value.
var GetRuntimeNew func(instance interface{}) interface{}

// MakeInstance makes a new instance from a value.
var MakeInstance func(value interface{}) (instance interface{})

Expand All @@ -82,6 +85,11 @@ var MakeInstance func(value interface{}) (instance interface{})
// keys.
var CheckAndForkRuntime func(runtime, value interface{}) interface{}

// CheckAndForkRuntime checks that value is created using runtime, panicking
// if it does not, and returns a forked runtime that will discard additional
// keys.
var CheckAndForkRuntimeNew func(runtime, value interface{}) interface{}

// BaseContext is used as CUEs default context for arbitrary-precision decimals
var BaseContext = apd.BaseContext.WithPrecision(24)

Expand Down

0 comments on commit 6a495ae

Please sign in to comment.