Encode takes a type from outside this context and constructs a type from inside this context and emits BSUP typedefs for any type needed to construct the new type into the buffer provided.
(external super.Type)
| 52 | // inside this context and emits BSUP typedefs for any type needed to construct |
| 53 | // the new type into the buffer provided. |
| 54 | func (e *Encoder) Encode(external super.Type) (super.Type, error) { |
| 55 | if typ, ok := e.encoded[external]; ok { |
| 56 | return typ, nil |
| 57 | } |
| 58 | internal, err := e.encode(external) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | e.encoded[external] = internal |
| 63 | return internal, err |
| 64 | } |
| 65 | |
| 66 | func (e *Encoder) encode(ext super.Type) (super.Type, error) { |
| 67 | switch ext := ext.(type) { |
no test coverage detected