Skip to content

Commit 3165a5e

Browse files
committed
internal/core/adt: change slice type of notify
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]>
1 parent 0b96e3b commit 3165a5e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

internal/core/adt/composite.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,8 @@ func (n *nodeContext) addConjunctDynamic(c Conjunct) {
999999
}
10001000

10011001
func (n *nodeContext) notifyConjunct(c Conjunct) {
1002-
for _, arc := range n.notify {
1002+
for _, rec := range n.notify {
1003+
arc := rec.v
10031004
if !arc.hasConjunct(c) {
10041005
if arc.state == nil {
10051006
// TODO: continuing here is likely to result in a faulty

internal/core/adt/eval.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (c *OpContext) evaluate(v *Vertex, r Resolver, state vertexStatus) Value {
138138
// relax this again once we have proper tests to prevent regressions of
139139
// that issue.
140140
if !v.state.done() || v.state.errs != nil {
141-
v.state.addNotify(c.vertex)
141+
v.state.addNotify(c.vertex, nil)
142142
}
143143
}
144144

@@ -444,7 +444,8 @@ func (n *nodeContext) doNotify() {
444444
if n.errs == nil || len(n.notify) == 0 {
445445
return
446446
}
447-
for _, v := range n.notify {
447+
for _, rec := range n.notify {
448+
v := rec.v
448449
if v.state == nil {
449450
if b, ok := v.BaseValue.(*Bottom); ok {
450451
v.BaseValue = CombineErrors(nil, b, n.errs)
@@ -974,7 +975,7 @@ type nodeContext struct {
974975

975976
// notify is used to communicate errors in cyclic dependencies.
976977
// TODO: also use this to communicate increasingly more concrete values.
977-
notify []*Vertex
978+
notify []receiver
978979

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

1066+
// A receiver receives notifications.
1067+
type receiver struct {
1068+
v *Vertex
1069+
cc *closeContext
1070+
}
1071+
10651072
// Logf substitutes args in format. Arguments of type Feature, Value, and Expr
10661073
// are printed in human-friendly formats. The printed string is prefixed and
10671074
// indented with the path associated with the current nodeContext.
@@ -1080,9 +1087,9 @@ type defaultInfo struct {
10801087
origMode defaultMode
10811088
}
10821089

1083-
func (n *nodeContext) addNotify(v *Vertex) {
1090+
func (n *nodeContext) addNotify(v *Vertex, cc *closeContext) {
10841091
if v != nil && !n.node.hasAllConjuncts {
1085-
n.notify = append(n.notify, v)
1092+
n.notify = append(n.notify, receiver{v, cc})
10861093
}
10871094
}
10881095

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

16951702
if arc.state != nil {
1696-
arc.state.addNotify(n.node)
1703+
arc.state.addNotify(n.node, nil)
16971704
}
16981705

16991706
for _, c := range arc.Conjuncts {

0 commit comments

Comments
 (0)