| 72 | } |
| 73 | |
| 74 | func walkUnion(typ *TypeUnion, body scode.Bytes, visit Visitor) error { |
| 75 | if len(body) == 0 { |
| 76 | return errors.New("union has empty body") |
| 77 | } |
| 78 | it := body.Iter() |
| 79 | tag := DecodeUint(it.Next()) |
| 80 | inner, err := typ.Type(int(tag)) |
| 81 | if err != nil { |
| 82 | return err |
| 83 | } |
| 84 | body = it.Next() |
| 85 | if !it.Done() { |
| 86 | return errors.New("union value container has more than two items") |
| 87 | } |
| 88 | return Walk(inner, body, visit) |
| 89 | } |
| 90 | |
| 91 | func walkSet(typ *TypeSet, body scode.Bytes, visit Visitor) error { |
| 92 | inner := TypeUnder(InnerType(typ)) |