| 51 | } |
| 52 | |
| 53 | func (parent *valueNode) PushStep(ps PathStep) (child *valueNode) { |
| 54 | vx, vy := ps.Values() |
| 55 | child = &valueNode{parent: parent, Type: ps.Type(), ValueX: vx, ValueY: vy} |
| 56 | switch s := ps.(type) { |
| 57 | case StructField: |
| 58 | assert(parent.Value == nil) |
| 59 | parent.Records = append(parent.Records, reportRecord{Key: reflect.ValueOf(s.Name()), Value: child}) |
| 60 | case SliceIndex: |
| 61 | assert(parent.Value == nil) |
| 62 | parent.Records = append(parent.Records, reportRecord{Value: child}) |
| 63 | case MapIndex: |
| 64 | assert(parent.Value == nil) |
| 65 | parent.Records = append(parent.Records, reportRecord{Key: s.Key(), Value: child}) |
| 66 | case Indirect: |
| 67 | assert(parent.Value == nil && parent.Records == nil) |
| 68 | parent.Value = child |
| 69 | case TypeAssertion: |
| 70 | assert(parent.Value == nil && parent.Records == nil) |
| 71 | parent.Value = child |
| 72 | case Transform: |
| 73 | assert(parent.Value == nil && parent.Records == nil) |
| 74 | parent.Value = child |
| 75 | parent.TransformerName = s.Name() |
| 76 | parent.NumTransformed++ |
| 77 | default: |
| 78 | assert(parent == nil) // Must be the root step |
| 79 | } |
| 80 | return child |
| 81 | } |
| 82 | |
| 83 | func (r *valueNode) Report(rs Result) { |
| 84 | assert(r.MaxDepth == 0) // May only be called on leaf nodes |