Skip to content

Commit

Permalink
internal/core/adt: pass Conjunct to addVertexConjuncts
Browse files Browse the repository at this point in the history
Change-Id: I1e2e691eb815a8c7586f2056124b6b554832d9f0
Signed-off-by: Marcel van Lohuizen <[email protected]>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/532949
Unity-Result: CUEcueckoo <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
  • Loading branch information
mpvl committed Feb 17, 2022
1 parent 975f57c commit e499dae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ func (n *nodeContext) addExprConjunct(v Conjunct) {
if x.IsData() {
n.addValueConjunct(env, x, id)
} else {
n.addVertexConjuncts(env, id, x, x, true)
n.addVertexConjuncts(v, x, true)
}

case Value:
Expand Down Expand Up @@ -1297,7 +1297,7 @@ func (n *nodeContext) evalExpr(v Conjunct) {
break
}

n.addVertexConjuncts(v.Env, v.CloseInfo, v.Expr(), arc, false)
n.addVertexConjuncts(v, arc, false)

case Evaluator:
// Interpolation, UnaryExpr, BinaryExpr, CallExpr
Expand Down Expand Up @@ -1340,7 +1340,8 @@ func (n *nodeContext) evalExpr(v Conjunct) {
}
}

func (n *nodeContext) addVertexConjuncts(env *Environment, closeInfo CloseInfo, x Expr, arc *Vertex, inline bool) {
func (n *nodeContext) addVertexConjuncts(c Conjunct, arc *Vertex, inline bool) {
closeInfo := c.CloseInfo

// We need to ensure that each arc is only unified once (or at least) a
// bounded time, witch each conjunct. Comprehensions, for instance, may
Expand Down Expand Up @@ -1368,6 +1369,7 @@ func (n *nodeContext) addVertexConjuncts(env *Environment, closeInfo CloseInfo,
}
n.arcMap = append(n.arcMap, key)

env := c.Env
// Pass detection of structural cycles from parent to children.
cyclic := false
if env != nil {
Expand Down Expand Up @@ -1427,6 +1429,7 @@ func (n *nodeContext) addVertexConjuncts(env *Environment, closeInfo CloseInfo,
// resulting form APIs. These tend to be fairly uninteresting.
// At the same time, this optimization may prevent considerable slowdown
// in case an API does many calls to Unify.
x := c.Expr()
if !inline || arc.IsClosedStruct() || arc.IsClosedList() {
closeInfo = closeInfo.SpawnRef(arc, IsDef(x), x)
}
Expand Down Expand Up @@ -1542,7 +1545,7 @@ func (n *nodeContext) addValueConjunct(env *Environment, v Value, id CloseInfo)
// TODO: this really shouldn't happen anymore.
if isComplexStruct(ctx, x) {
// This really shouldn't happen, but just in case.
n.addVertexConjuncts(env, id, x, x, true)
n.addVertexConjuncts(MakeConjunct(env, x, id), x, true)
return
}

Expand Down

0 comments on commit e499dae

Please sign in to comment.