| 42 | } |
| 43 | |
| 44 | func TypeLength(typ super.Type) int { |
| 45 | switch typ := typ.(type) { |
| 46 | case *super.TypeNamed: |
| 47 | return TypeLength(typ.Type) |
| 48 | case *super.TypeRecord: |
| 49 | return len(typ.Fields) |
| 50 | case *super.TypeUnion: |
| 51 | return len(typ.Types) |
| 52 | case *super.TypeSet: |
| 53 | return TypeLength(typ.Type) |
| 54 | case *super.TypeArray: |
| 55 | return TypeLength(typ.Type) |
| 56 | case *super.TypeEnum: |
| 57 | return len(typ.Symbols) |
| 58 | case *super.TypeMap: |
| 59 | return TypeLength(typ.ValType) |
| 60 | case *super.TypeError: |
| 61 | return TypeLength(typ.Type) |
| 62 | default: |
| 63 | // Primitive type |
| 64 | return 1 |
| 65 | } |
| 66 | } |