(b *scode.Builder, typ super.Type, bytes scode.Bytes, outType super.Type, dropMap fieldsMap)
| 28 | } |
| 29 | |
| 30 | func (d *Dropper) recode(b *scode.Builder, typ super.Type, bytes scode.Bytes, outType super.Type, dropMap fieldsMap) { |
| 31 | recType := super.TypeRecordOf(typ) |
| 32 | if recType == nil { |
| 33 | b.Append(bytes) |
| 34 | return |
| 35 | } |
| 36 | outRecType := super.TypeUnder(outType).(*super.TypeRecord) |
| 37 | var outOff int |
| 38 | b.BeginContainer() |
| 39 | it := scode.NewRecordIter(bytes, recType.Opts) |
| 40 | var optOff int |
| 41 | var nones []int |
| 42 | for _, f := range recType.Fields { |
| 43 | elem, none := it.Next(f.Opt) |
| 44 | dropMapChild, ok := dropMap[f.Name] |
| 45 | if ok { |
| 46 | if dropMapChild == nil { |
| 47 | continue |
| 48 | } |
| 49 | if none { |
| 50 | nones = append(nones, optOff) |
| 51 | optOff++ |
| 52 | continue |
| 53 | } |
| 54 | d.recode(b, f.Type, elem, outRecType.Fields[outOff].Type, dropMapChild) |
| 55 | } else if none { |
| 56 | nones = append(nones, optOff) |
| 57 | } else { |
| 58 | b.Append(elem) |
| 59 | } |
| 60 | if f.Opt { |
| 61 | optOff++ |
| 62 | } |
| 63 | outOff++ |
| 64 | } |
| 65 | b.EndContainerWithNones(outRecType.Opts, nones) |
| 66 | } |
| 67 | |
| 68 | func (d *Dropper) Eval(in super.Value) super.Value { |
| 69 | typ := in.Type() |
no test coverage detected