|
1 | 1 | package types
|
2 | 2 |
|
| 3 | +const ( |
| 4 | + ROOT_NAME = "Root" |
| 5 | + TYPEREF_NAME = "TypeRef" |
| 6 | +) |
| 7 | + |
3 | 8 | // Schema is the result of parsing types.
|
4 | 9 | type Schema struct {
|
5 |
| - // RootID is the node ID of the root of types in the order found. |
6 |
| - RootID string |
7 |
| - |
8 |
| - // TypeRefID is the node ID that holds a map of named types by name. |
9 |
| - TypeRefID string |
| 10 | + // Root is the node ID of the root of types in the order found. |
| 11 | + Root *TypeNode |
10 | 12 |
|
11 |
| - // NodePool is the pool of all TypeNodes. |
12 |
| - NodePool *NodePool |
| 13 | + // TypeRef is the node ID that holds a map of named types by name. |
| 14 | + TypeRef *TypeNode |
13 | 15 | }
|
14 | 16 |
|
15 | 17 | // NewSchema initializes a new schema with root nodes.
|
16 | 18 | func NewSchema(nativeDialect string) *Schema {
|
17 |
| - pool := NewNodePool() |
18 |
| - |
19 | 19 | schema := &Schema{
|
20 |
| - RootID: pool.NewRootNode("Root", nativeDialect).ID, |
21 |
| - TypeRefID: pool.NewRootNode("TypeRef", nativeDialect).ID, |
22 |
| - |
23 |
| - NodePool: pool, |
| 20 | + Root: NewRootNode(ROOT_NAME, nativeDialect), |
| 21 | + TypeRef: NewRootNode(TYPEREF_NAME, nativeDialect), |
24 | 22 | }
|
25 | 23 |
|
26 | 24 | return schema
|
27 | 25 | }
|
28 | 26 |
|
29 |
| -func (schema *Schema) RootNode() *TypeNode { |
30 |
| - return schema.NodePool.Nodes[schema.RootID] |
31 |
| -} |
32 |
| - |
33 |
| -func (schema *Schema) TypeRefNode() *TypeNode { |
34 |
| - return schema.NodePool.Nodes[schema.TypeRefID] |
| 27 | +// CopyWithoutNative removes all native dialects for the minimal schema. |
| 28 | +func (schema *Schema) CopyWithoutNative() *Schema { |
| 29 | + return &Schema{ |
| 30 | + Root: schema.Root.CopyWithoutNative(), |
| 31 | + TypeRef: schema.TypeRef.CopyWithoutNative(), |
| 32 | + } |
35 | 33 | }
|
0 commit comments