(typ *super.TypeRecord, inner super.Type, base field.Path, b scode.Bytes)
| 70 | } |
| 71 | |
| 72 | func (n *Flatten) encode(typ *super.TypeRecord, inner super.Type, base field.Path, b scode.Bytes) { |
| 73 | it := scode.NewRecordIter(b, typ.Opts) |
| 74 | for _, f := range typ.Fields { |
| 75 | val, none := it.Next(f.Opt) |
| 76 | if none { |
| 77 | continue |
| 78 | } |
| 79 | key := append(base, f.Name) |
| 80 | if typ := super.TypeRecordOf(f.Type); typ != nil { |
| 81 | n.encode(typ, inner, key, val) |
| 82 | continue |
| 83 | } |
| 84 | typ := n.entryTypes[f.Type] |
| 85 | union, ok := inner.(*super.TypeUnion) |
| 86 | if ok { |
| 87 | super.BeginUnion(&n.Builder, union.TagOf(typ)) |
| 88 | } |
| 89 | n.BeginContainer() |
| 90 | n.encodeKey(key) |
| 91 | n.Append(val) |
| 92 | n.EndContainer() |
| 93 | if ok { |
| 94 | n.EndContainer() |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func (n *Flatten) encodeKey(key field.Path) { |
| 100 | n.BeginContainer() |
no test coverage detected