this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: continue transition away from adt.Vertex.VisitLeafConjuncts

Leaving the main internal/core/... packages for a separate commit.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I6c84ef4247bc51e65a431faba2d884fcec12ea50
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1224263
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+17 -33
+4 -9
cmd/cue/cmd/custom.go
··· 31 31 "cuelang.org/go/cue" 32 32 "cuelang.org/go/cue/errors" 33 33 "cuelang.org/go/cue/token" 34 - "cuelang.org/go/internal/core/adt" 35 34 "cuelang.org/go/internal/cueexperiment" 36 35 itask "cuelang.org/go/internal/task" 37 36 "cuelang.org/go/internal/value" ··· 99 98 // TODO: remove this block to allow commands to be defined in any file. 100 99 _, w := value.ToInternal(cmds) 101 100 hasToolFile := false 102 - w.VisitLeafConjuncts(func(c adt.Conjunct) bool { 101 + for c := range w.LeafConjuncts() { 103 102 src := c.Source() 104 - if src == nil { 105 - return true 106 - } 107 - if strings.HasSuffix(src.Pos().Filename(), "_tool.cue") { 103 + if src != nil && strings.HasSuffix(src.Pos().Filename(), "_tool.cue") { 108 104 hasToolFile = true 109 - return false 105 + break 110 106 } 111 - return true 112 - }) 107 + } 113 108 if !hasToolFile { 114 109 // Note that earlier versions of this code checked cmds.Err in this scenario, 115 110 // but it isn't clear why that was done, and we had no tests covering it.
+2 -3
internal/core/runtime/extern.go
··· 74 74 d.errs = errors.Append(d.errs, d.addFile(f)) 75 75 } 76 76 77 - v.VisitLeafConjuncts(func(c adt.Conjunct) bool { 77 + for c := range v.LeafConjuncts() { 78 78 d.decorateConjunct(c.Elem(), v) 79 - return true 80 - }) 79 + } 81 80 82 81 return d.errs 83 82 }
+8 -12
internal/core/toposort/vertex.go
··· 258 258 // uncover the position of the earliest reference. 259 259 for _, arc := range v.Arcs { 260 260 builder.EnsureNode(arc.Label) 261 - arc.VisitLeafConjuncts(func(c adt.Conjunct) bool { 261 + for c := range arc.LeafConjuncts() { 262 262 field := c.Field() 263 263 debug("self arc conjunct field %p :: %T, expr %p :: %T (%v)\n", 264 264 field, field, c.Expr(), c.Expr(), c.Expr().Source()) 265 265 sMetas, found := nodeToStructMetas[field] 266 266 if !found { 267 - return true 267 + continue 268 268 } 269 269 if src := field.Source(); src != nil { 270 270 for sMeta := range sMetas { ··· 273 273 } 274 274 refs := c.CloseInfo.CycleInfo.Refs 275 275 if refs == nil { 276 - return true 276 + continue 277 277 } 278 278 debug(" ref %p :: %T (%v)\n", 279 279 refs.Ref, refs.Ref, refs.Ref.Source().Pos()) ··· 288 288 sMeta.pos = pos 289 289 } 290 290 } 291 - 292 - return true 293 - }) 291 + } 294 292 } 295 293 296 294 // Explore our own conjuncts, and the decls from our StructList, to 297 295 // find explicit unifications, and mark structMetas accordingly. 298 296 var worklist []adt.Expr 299 - v.VisitLeafConjuncts(func(c adt.Conjunct) bool { 297 + for c := range v.LeafConjuncts() { 300 298 debug("self conjunct field %p :: %T, expr %p :: %T\n", 301 299 c.Field(), c.Field(), c.Expr(), c.Expr()) 302 300 worklist = append(worklist, c.Expr()) 303 - return true 304 - }) 301 + } 305 302 for _, si := range structInfos { 306 303 for _, decl := range si.StructLit.Decls { 307 304 if expr, ok := decl.(adt.Expr); ok { ··· 335 332 func dynamicFieldsFeatures(v *adt.Vertex) map[*adt.DynamicField][]adt.Feature { 336 333 var m map[*adt.DynamicField][]adt.Feature 337 334 for _, arc := range v.Arcs { 338 - arc.VisitLeafConjuncts(func(c adt.Conjunct) bool { 335 + for c := range arc.LeafConjuncts() { 339 336 if dynField, ok := c.Field().(*adt.DynamicField); ok { 340 337 if m == nil { 341 338 m = make(map[*adt.DynamicField][]adt.Feature) 342 339 } 343 340 m[dynField] = append(m[dynField], arc.Label) 344 341 } 345 - return true 346 - }) 342 + } 347 343 } 348 344 return m 349 345 }
+2 -4
internal/task/task.go
··· 24 24 "cuelang.org/go/cue" 25 25 "cuelang.org/go/cue/errors" 26 26 "cuelang.org/go/cue/token" 27 - "cuelang.org/go/internal/core/adt" 28 27 "cuelang.org/go/internal/value" 29 28 "cuelang.org/go/tools/flow" 30 29 ) ··· 187 186 func (t *taskError) InputPositions() (a []token.Pos) { 188 187 _, nx := value.ToInternal(t.v) 189 188 190 - nx.VisitLeafConjuncts(func(x adt.Conjunct) bool { 189 + for x := range nx.LeafConjuncts() { 191 190 if src := x.Source(); src != nil { 192 191 a = append(a, src.Pos()) 193 192 } 194 - return true 195 - }) 193 + } 196 194 return a 197 195 } 198 196
+1 -5
tools/flow/run.go
··· 41 41 _, root := value.ToInternal(c.inst) 42 42 43 43 // Copy the initial conjuncts. 44 - var rootConjuncts []adt.Conjunct 45 - root.VisitLeafConjuncts(func(c adt.Conjunct) bool { 46 - rootConjuncts = append(rootConjuncts, c) 47 - return true 48 - }) 44 + rootConjuncts := slices.Collect(root.LeafConjuncts()) 49 45 n := len(rootConjuncts) 50 46 c.conjuncts = make([]adt.Conjunct, n, n+len(c.tasks)) 51 47 copy(c.conjuncts, rootConjuncts)