Files
dolt/datas/commit.go
Erik Arvidsson 3ff6ee6add Inline struct type declaration into chunk (#1324)
Struct type definition is now inlined into the chunk. To break
cycles we use back references.

- Removes unresolved type refs
- Removes packages

Fixes #1164
Fixes #1165
2016-04-27 20:39:51 -07:00

52 lines
1.2 KiB
Go

package datas
import "github.com/attic-labs/noms/types"
var commitType *types.Type
const (
ParentsField = "parents"
ValueField = "value"
)
func init() {
structName := "Commit"
// struct Commit {
// value: Value
// parents: Set<Ref<Commit>>
// }
fieldTypes := []types.Field{
types.Field{Name: ValueField, T: types.ValueType},
types.Field{Name: ParentsField, T: nil},
}
commitType = types.MakeStructType(structName, fieldTypes, []types.Field{})
commitType.Desc.(types.StructDesc).Fields[1].T = types.MakeSetType(types.MakeRefType(commitType))
}
func NewCommit() types.Struct {
initialFields := map[string]types.Value{
ValueField: types.NewString(""),
ParentsField: NewSetOfRefOfCommit(),
}
return types.NewStruct(commitType, initialFields)
}
func typeForMapOfStringToRefOfCommit() *types.Type {
return types.MakeMapType(types.StringType, types.MakeRefType(commitType))
}
func NewMapOfStringToRefOfCommit() types.Map {
return types.NewTypedMap(typeForMapOfStringToRefOfCommit())
}
func typeForSetOfRefOfCommit() *types.Type {
return types.MakeSetType(types.MakeRefType(commitType))
}
func NewSetOfRefOfCommit() types.Set {
return types.NewTypedSet(typeForSetOfRefOfCommit())
}