Skip to content

Commit 804c320

Browse files
committed
wip
1 parent 98dce8c commit 804c320

File tree

12 files changed

+2407
-1637
lines changed

12 files changed

+2407
-1637
lines changed

common/types/schema.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
package types
22

3+
const (
4+
ROOT_NAME = "Root"
5+
TYPEREF_NAME = "TypeRef"
6+
)
7+
38
// Schema is the result of parsing types.
49
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
1012

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
1315
}
1416

1517
// NewSchema initializes a new schema with root nodes.
1618
func NewSchema(nativeDialect string) *Schema {
17-
pool := NewNodePool()
18-
1919
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),
2422
}
2523

2624
return schema
2725
}
2826

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+
}
3533
}

0 commit comments

Comments
 (0)