this repo has no description
0
fork

Configure Feed

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

cue: remove field type

All information is now present and directly
accessible in Vertex.

Issue #2305

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I76f6e0e11c8013bbae904a8d1d068f1ffe3a67a8
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/552168
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+17 -22
+17 -22
cue/types.go
··· 110 110 return o.v.idx.LabelStr(f), newChildValue(o, i) 111 111 } 112 112 113 - func (o *hiddenStructValue) at(i int) (v *adt.Vertex, isOpt bool) { 113 + func (o *hiddenStructValue) at(i int) *adt.Vertex { 114 114 f := o.features[i] 115 - arc := o.obj.Lookup(f) 116 - return arc, arc.IsConstraint() 115 + return o.obj.Lookup(f) 117 116 } 118 117 119 118 // Lookup reports the field for the given key. The returned Value is invalid ··· 215 214 val Value 216 215 idx *runtime.Runtime 217 216 ctx *adt.OpContext 218 - arcs []field 217 + arcs []*adt.Vertex 219 218 p int 220 219 cur Value 221 220 f adt.Feature ··· 224 223 225 224 type hiddenIterator = Iterator 226 225 227 - type field struct { 228 - arc *adt.Vertex 229 - isOptional bool 230 - } 231 - 232 226 // Next advances the iterator to the next value and reports whether there was 233 227 // any. It must be called before the first call to Value or Key. 234 228 func (i *Iterator) Next() bool { ··· 236 230 i.cur = Value{} 237 231 return false 238 232 } 239 - f := i.arcs[i.p] 240 - f.arc.Finalize(i.ctx) 241 - p := linkParent(i.val.parent_, i.val.v, f.arc) 242 - i.cur = makeValue(i.val.idx, f.arc, p) 243 - i.f = f.arc.Label 244 - i.isOpt = f.isOptional 233 + arc := i.arcs[i.p] 234 + arc.Finalize(i.ctx) 235 + p := linkParent(i.val.parent_, i.val.v, arc) 236 + i.cur = makeValue(i.val.idx, arc, p) 237 + i.f = arc.Label 238 + i.isOpt = arc.ArcType == adt.ArcOptional 245 239 i.p++ 246 240 return true 247 241 } ··· 630 624 } 631 625 632 626 func newChildValue(o *structValue, i int) Value { 633 - arc, _ := o.at(i) 627 + arc := o.at(i) 634 628 return makeValue(o.v.idx, arc, linkParent(o.v.parent_, o.v.v, arc)) 635 629 } 636 630 ··· 1284 1278 if err := v.checkKind(ctx, adt.ListKind); err != nil { 1285 1279 return Iterator{idx: v.idx, ctx: ctx}, v.toErr(err) 1286 1280 } 1287 - arcs := []field{} 1281 + arcs := []*adt.Vertex{} 1288 1282 for _, a := range v.v.Elems() { 1289 1283 if a.Label.IsInt() { 1290 - arcs = append(arcs, field{arc: a}) 1284 + arcs = append(arcs, a) 1291 1285 } 1292 1286 } 1293 1287 return Iterator{idx: v.idx, ctx: ctx, val: v, arcs: arcs}, nil ··· 1467 1461 1468 1462 // field reports information about the ith field, i < o.Len(). 1469 1463 func (s *hiddenStruct) Field(i int) FieldInfo { 1470 - a, opt := s.at(i) 1464 + a := s.at(i) 1465 + opt := a.ArcType == adt.ArcOptional 1471 1466 ctx := s.v.ctx() 1472 1467 1473 1468 v := makeChildValue(s.v, a) ··· 1506 1501 return &Iterator{idx: v.idx, ctx: ctx}, v.toErr(err) 1507 1502 } 1508 1503 1509 - arcs := []field{} 1504 + arcs := []*adt.Vertex{} 1510 1505 for i := range obj.features { 1511 - arc, isOpt := obj.at(i) 1512 - arcs = append(arcs, field{arc: arc, isOptional: isOpt}) 1506 + arc := obj.at(i) 1507 + arcs = append(arcs, arc) 1513 1508 } 1514 1509 return &Iterator{idx: v.idx, ctx: ctx, val: v, arcs: arcs}, nil 1515 1510 }