(typ Type, body scode.Bytes, visit Visitor)
| 18 | var SkipContainer = errors.New("skip this container") |
| 19 | |
| 20 | func Walk(typ Type, body scode.Bytes, visit Visitor) error { |
| 21 | if err := visit(typ, body); err != nil { |
| 22 | if err == SkipContainer { |
| 23 | return nil |
| 24 | } |
| 25 | return err |
| 26 | } |
| 27 | switch typ := typ.(type) { |
| 28 | case *TypeNamed: |
| 29 | return Walk(typ.Type, body, visit) |
| 30 | case *TypeRecord: |
| 31 | return walkRecord(typ, body, visit) |
| 32 | case *TypeArray: |
| 33 | return walkArray(typ, body, visit) |
| 34 | case *TypeSet: |
| 35 | return walkSet(typ, body, visit) |
| 36 | case *TypeUnion: |
| 37 | return walkUnion(typ, body, visit) |
| 38 | case *TypeMap: |
| 39 | return walkMap(typ, body, visit) |
| 40 | case *TypeError: |
| 41 | return Walk(typ.Type, body, visit) |
| 42 | } |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | func walkRecord(typ *TypeRecord, body scode.Bytes, visit Visitor) error { |
| 47 | it := scode.NewRecordIter(body, typ.Opts) |
no test coverage detected