Skip to content

Commit

Permalink
internal/core/adt: remove special "tentative" mode
Browse files Browse the repository at this point in the history
The new AllArcs state is sufficient to indicate the
partial evaluation needed for processing comprehensions.
The old special-casing through the tentative mode is thus
no longer needed.

Change-Id: I851b063cf886f053e7f71a0407471f53ceadada9
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8162
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jan 15, 2021
1 parent 34a91b9 commit 9eee235
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
14 changes: 0 additions & 14 deletions internal/core/adt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ type OpContext struct {
// structural cycle errors.
vertex *Vertex

// TODO: remove use of tentative. Should be possible if incomplete
// handling is done better.
tentative int // set during comprehension evaluation

// These fields are used associate scratch fields for computing closedness
// of a Vertex. These fields could have been included in StructInfo (like
// Tomabechi's unification algorithm), but we opted for an indirection to
Expand All @@ -188,12 +184,6 @@ func (c *OpContext) Impl() Runtime {
return c.Runtime
}

// If IsTentative is set, evaluation of an arc should not finalize
// to non-concrete values.
func (c *OpContext) IsTentative() bool {
return c.tentative > 0
}

func (c *OpContext) Pos() token.Pos {
if c.src == nil {
return token.NoPos
Expand Down Expand Up @@ -431,12 +421,8 @@ func (c *OpContext) Validate(check Validator, value Value) *Bottom {
func (c *OpContext) Yield(env *Environment, y Yielder, f YieldFunc) *Bottom {
s := c.PushState(env, y.Source())

c.tentative++

y.yield(c, f)

c.tentative--

return c.PopState(s)

}
Expand Down
20 changes: 1 addition & 19 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,6 @@ func (e *Unifier) evaluate(c *OpContext, v *Vertex, state VertexStatus) Value {
switch x := v.BaseValue.(type) {
case *Bottom:
return x
case *Disjunction:
if x.NumDefaults == 1 {
if c.IsTentative() && isStruct(v) {
// TODO(perf): do something more efficient perhaps? This discards
// the computed arcs so far. Instead, we could have a separate
// marker to accumulate results. As this only happens within
// comprehensions, the effect is likely minimal, though.
arcs := v.Arcs
w := &Vertex{
Parent: v.Parent,
BaseValue: &StructMarker{},
Arcs: arcs,
Conjuncts: v.Conjuncts,
}
w.UpdateStatus(v.Status())
v = w
}
}

case nil:
if v.state != nil {
Expand Down Expand Up @@ -433,7 +415,7 @@ func (n *nodeContext) postDisjunct(state VertexStatus) {

default:
if n.node.BaseValue == cycle {
if !n.done() { // && !ctx.IsTentative() {
if !n.done() {
// collect incomplete errors.
var err *Bottom // n.incomplete
for _, d := range n.dynamicFields {
Expand Down

0 comments on commit 9eee235

Please sign in to comment.