Skip to content

Commit

Permalink
internal/core/adt: change slice type of notify
Browse files Browse the repository at this point in the history
This is to accomodate the new closedness algorithm.
Doing this now makes upcoming diffs smaller.

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I786318a39635dfeb7dd1dd1fc854521e474ffe03
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1167912
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Aug 25, 2023
1 parent 0b96e3b commit 3165a5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion internal/core/adt/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ func (n *nodeContext) addConjunctDynamic(c Conjunct) {
}

func (n *nodeContext) notifyConjunct(c Conjunct) {
for _, arc := range n.notify {
for _, rec := range n.notify {
arc := rec.v
if !arc.hasConjunct(c) {
if arc.state == nil {
// TODO: continuing here is likely to result in a faulty
Expand Down
19 changes: 13 additions & 6 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (c *OpContext) evaluate(v *Vertex, r Resolver, state vertexStatus) Value {
// relax this again once we have proper tests to prevent regressions of
// that issue.
if !v.state.done() || v.state.errs != nil {
v.state.addNotify(c.vertex)
v.state.addNotify(c.vertex, nil)
}
}

Expand Down Expand Up @@ -444,7 +444,8 @@ func (n *nodeContext) doNotify() {
if n.errs == nil || len(n.notify) == 0 {
return
}
for _, v := range n.notify {
for _, rec := range n.notify {
v := rec.v
if v.state == nil {
if b, ok := v.BaseValue.(*Bottom); ok {
v.BaseValue = CombineErrors(nil, b, n.errs)
Expand Down Expand Up @@ -974,7 +975,7 @@ type nodeContext struct {

// notify is used to communicate errors in cyclic dependencies.
// TODO: also use this to communicate increasingly more concrete values.
notify []*Vertex
notify []receiver

// Conjuncts holds a reference to the Vertex Arcs that still need
// processing. It does NOT need to be copied.
Expand Down Expand Up @@ -1062,6 +1063,12 @@ type nodeContextState struct {
conjunctsPartialPos int
}

// A receiver receives notifications.
type receiver struct {
v *Vertex
cc *closeContext
}

// Logf substitutes args in format. Arguments of type Feature, Value, and Expr
// are printed in human-friendly formats. The printed string is prefixed and
// indented with the path associated with the current nodeContext.
Expand All @@ -1080,9 +1087,9 @@ type defaultInfo struct {
origMode defaultMode
}

func (n *nodeContext) addNotify(v *Vertex) {
func (n *nodeContext) addNotify(v *Vertex, cc *closeContext) {
if v != nil && !n.node.hasAllConjuncts {
n.notify = append(n.notify, v)
n.notify = append(n.notify, receiver{v, cc})
}
}

Expand Down Expand Up @@ -1693,7 +1700,7 @@ func (n *nodeContext) addVertexConjuncts(c Conjunct, arc *Vertex, inline bool) {
}

if arc.state != nil {
arc.state.addNotify(n.node)
arc.state.addNotify(n.node, nil)
}

for _, c := range arc.Conjuncts {
Expand Down

0 comments on commit 3165a5e

Please sign in to comment.