| 78 | } |
| 79 | |
| 80 | func (c *Context) LookupType(id int) (Type, error) { |
| 81 | if id < 0 { |
| 82 | return nil, fmt.Errorf("type id (%d) cannot be negative", id) |
| 83 | } |
| 84 | if id < IDTypeComplex { |
| 85 | return LookupPrimitiveByID(id) |
| 86 | } |
| 87 | c.mu.RLock() |
| 88 | defer c.mu.RUnlock() |
| 89 | if id >= len(c.byID) { |
| 90 | return nil, fmt.Errorf("type id (%d) not in type context (size %d)", id, len(c.byID)) |
| 91 | } |
| 92 | if typ := c.byID[id]; typ != nil { |
| 93 | return typ, nil |
| 94 | } |
| 95 | return nil, fmt.Errorf("no type found for type id %d", id) |
| 96 | } |
| 97 | |
| 98 | var keyPool = sync.Pool{ |
| 99 | New: func() any { |