Skip to content

Commit

Permalink
internal/core/adt: show # only on original defintion node
Browse files Browse the repository at this point in the history
isDef is marked as # in the graphical debugger. As isDef
is propagated up, all ancestor nodes are propagated.
For debugging purpososes, this makes it hard to see where
the isDef originated, which is generally more in line what
we are interested in.

This change now only shows # on nodes where it was
originally set.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Iae2cbf287621d4b70b80fe3595ee43a42d236860
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1199269
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
mpvl committed Aug 12, 2024
1 parent a093c9b commit 6cc01b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/core/adt/conjunct.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ loop2:
// Can be added unconditionally to patterns.
ci.cc.isDef = false
ci.cc.isClosed = false
ci.cc.isDefOrig = false

case *DynamicField:
if x.ArcType == ArcMember {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func (m *mermaidContext) pstr(cc *closeContext) string {
flags.WriteByte(flag)
}
}
addFlag(cc.isDef, '#')
addFlag(cc.isDefOrig, '#')
addFlag(cc.isEmbed, 'E')
addFlag(cc.isClosed, 'c')
addFlag(cc.isClosedOnce, 'C')
Expand Down
10 changes: 8 additions & 2 deletions internal/core/adt/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,14 @@ type closeContext struct {

arcType ArcType

// isDef indicates whether the closeContext is created as part of a
// definition.
// isDef is true when isDefOrig is true or when isDef is true for any of its
// child nodes, recursively.
isDef bool

// isDefOrig indicates whether the closeContext is created as part of a
// definition. This value propagates to itself and parents through isDef.
isDefOrig bool

// hasEllipsis indicates whether the node contains an ellipsis.
hasEllipsis bool

Expand Down Expand Up @@ -393,6 +397,7 @@ func (cc *closeContext) getKeyedCC(ctx *OpContext, key *closeContext, c CycleInf
group: group,

isDef: cc.isDef,
isDefOrig: cc.isDefOrig,
isEmbed: cc.isEmbed,
needsCloseInSchedule: cc,
}
Expand Down Expand Up @@ -484,6 +489,7 @@ func (c CloseInfo) spawnCloseContext(ctx *OpContext, t closeNodeType) (CloseInfo
switch t {
case closeDef:
c.cc.isDef = true
c.cc.isDefOrig = true
case closeEmbed:
c.cc.isEmbed = true
}
Expand Down
1 change: 1 addition & 0 deletions internal/core/adt/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func (ctx *overlayContext) initCloneCC(x *closeContext) {
o.conjunctCount = x.conjunctCount
o.disjunctCount = x.disjunctCount
o.isDef = x.isDef
o.isDefOrig = x.isDefOrig
o.hasEllipsis = x.hasEllipsis
o.hasTop = x.hasTop
o.hasNonTop = x.hasNonTop
Expand Down

0 comments on commit 6cc01b0

Please sign in to comment.