Commit d7980ca8 authored by Eric Myhre's avatar Eric Myhre

schema compiler: regularize some names in carrier types.

Use a "__" pattern -- the same one already used in our schema codegen.

This is less ambiguous given we have some other names which already use
single underscores to demarcate other semantics (e.g. union membership
groupings).

Also things now ready left-to-right as is normal for golang (e.g., the
word "map" or "list" now comes first).

No logical changes.  Just naming.
parent eed03b4c
......@@ -133,7 +133,7 @@ func (c *Compiler) TypeLink(name TypeName, expectedTypeRef TypeName) {
c.addType(&TypeLink{c.ts, name, TypeReference(name), expectedTypeRef})
}
func (c *Compiler) TypeStruct(name TypeName, fields structFieldList, rstrat StructRepresentation) {
func (c *Compiler) TypeStruct(name TypeName, fields list__StructField, rstrat StructRepresentation) {
t := TypeStruct{
ts: c.ts,
name: name,
......@@ -158,7 +158,7 @@ func (Compiler) MakeStructField(name StructFieldName, typ TypeReference, optiona
return StructField{nil, name, typ, optional, nullable}
}
func (Compiler) MakeStructRepresentation_Map(fieldDetails structFieldNameStructRepresentation_Map_FieldDetailsMap) StructRepresentation {
func (Compiler) MakeStructRepresentation_Map(fieldDetails map__StructFieldName__StructRepresentation_Map_FieldDetails) StructRepresentation {
return StructRepresentation_Map{nil, fieldDetails.x}
}
......@@ -176,7 +176,7 @@ func (c *Compiler) TypeList(name TypeName, valueTypeRef TypeReference, valueNull
c.addType(&TypeList{c.ts, name, TypeReference(name), valueTypeRef, valueNullable})
}
func (c *Compiler) TypeUnion(name TypeName, members typeNameList, rstrat UnionRepresentation) {
func (c *Compiler) TypeUnion(name TypeName, members list__TypeName, rstrat UnionRepresentation) {
t := TypeUnion{
ts: c.ts,
name: name,
......@@ -191,7 +191,7 @@ func (c *Compiler) TypeUnion(name TypeName, members typeNameList, rstrat UnionRe
//go:generate quickimmut -output=compiler_carriers.go -attach=Compiler list TypeName
func (Compiler) MakeUnionRepresentation_Keyed(discriminantTable stringTypeNameMap) UnionRepresentation {
func (Compiler) MakeUnionRepresentation_Keyed(discriminantTable map__String__TypeName) UnionRepresentation {
return &UnionRepresentation_Keyed{nil, discriminantTable.x}
}
......
......@@ -15,108 +15,108 @@ package schema
// Code generated by comments in carrier.go. DO NOT EDIT below this line.
// ---
type structFieldList struct {
type list__StructField struct {
x []StructField
}
type structFieldListBuilder structFieldList
type list__StructField__Builder list__StructField
func (Compiler) MakeStructFieldList(ents ...StructField) structFieldList {
func (Compiler) MakeList__StructField(ents ...StructField) list__StructField {
x := make([]StructField, len(ents))
copy(x, ents)
return structFieldList{x}
return list__StructField{x}
}
func (Compiler) StartStructFieldList(sizeHint int) structFieldListBuilder {
return structFieldListBuilder{make([]StructField, 0, sizeHint)}
func (Compiler) StartList__StructField(sizeHint int) list__StructField__Builder {
return list__StructField__Builder{make([]StructField, 0, sizeHint)}
}
func (b *structFieldListBuilder) Append(v StructField) {
func (b *list__StructField__Builder) Append(v StructField) {
b.x = append(b.x, v)
}
func (b *structFieldListBuilder) Finish() structFieldList {
func (b *list__StructField__Builder) Finish() list__StructField {
v := *b
b.x = nil
return structFieldList(v)
return list__StructField(v)
}
type structFieldNameStructRepresentation_Map_FieldDetailsMap struct {
type map__StructFieldName__StructRepresentation_Map_FieldDetails struct {
x map[StructFieldName]StructRepresentation_Map_FieldDetails
}
type structFieldNameStructRepresentation_Map_FieldDetailsEntry struct {
type map__StructFieldName__StructRepresentation_Map_FieldDetails__Entry struct {
k StructFieldName
v StructRepresentation_Map_FieldDetails
}
type structFieldNameStructRepresentation_Map_FieldDetailsMapBuilder structFieldNameStructRepresentation_Map_FieldDetailsMap
type map__StructFieldName__StructRepresentation_Map_FieldDetails__Builder map__StructFieldName__StructRepresentation_Map_FieldDetails
func (Compiler) MakeStructFieldNameStructRepresentation_Map_FieldDetailsMap(ents ...structFieldNameStructRepresentation_Map_FieldDetailsEntry) structFieldNameStructRepresentation_Map_FieldDetailsMap {
func (Compiler) MakeMap__StructFieldName__StructRepresentation_Map_FieldDetails(ents ...map__StructFieldName__StructRepresentation_Map_FieldDetails__Entry) map__StructFieldName__StructRepresentation_Map_FieldDetails {
x := make(map[StructFieldName]StructRepresentation_Map_FieldDetails, len(ents))
for _, y := range ents {
x[y.k] = y.v
}
return structFieldNameStructRepresentation_Map_FieldDetailsMap{x}
return map__StructFieldName__StructRepresentation_Map_FieldDetails{x}
}
func (Compiler) MakeStructFieldNameStructRepresentation_Map_FieldDetailsMapEntry(k StructFieldName, v StructRepresentation_Map_FieldDetails) structFieldNameStructRepresentation_Map_FieldDetailsEntry {
return structFieldNameStructRepresentation_Map_FieldDetailsEntry{k, v}
func (Compiler) MakeMap__StructFieldName__StructRepresentation_Map_FieldDetails__Entry(k StructFieldName, v StructRepresentation_Map_FieldDetails) map__StructFieldName__StructRepresentation_Map_FieldDetails__Entry {
return map__StructFieldName__StructRepresentation_Map_FieldDetails__Entry{k, v}
}
func (Compiler) StartStructFieldNameStructRepresentation_Map_FieldDetailsMap(sizeHint int) structFieldNameStructRepresentation_Map_FieldDetailsMapBuilder {
return structFieldNameStructRepresentation_Map_FieldDetailsMapBuilder{make(map[StructFieldName]StructRepresentation_Map_FieldDetails, sizeHint)}
func (Compiler) StartMap__StructFieldName__StructRepresentation_Map_FieldDetails(sizeHint int) map__StructFieldName__StructRepresentation_Map_FieldDetails__Builder {
return map__StructFieldName__StructRepresentation_Map_FieldDetails__Builder{make(map[StructFieldName]StructRepresentation_Map_FieldDetails, sizeHint)}
}
func (b *structFieldNameStructRepresentation_Map_FieldDetailsMapBuilder) Append(k StructFieldName, v StructRepresentation_Map_FieldDetails) {
func (b *map__StructFieldName__StructRepresentation_Map_FieldDetails__Builder) Append(k StructFieldName, v StructRepresentation_Map_FieldDetails) {
b.x[k] = v
}
func (b *structFieldNameStructRepresentation_Map_FieldDetailsMapBuilder) Finish() structFieldNameStructRepresentation_Map_FieldDetailsMap {
func (b *map__StructFieldName__StructRepresentation_Map_FieldDetails__Builder) Finish() map__StructFieldName__StructRepresentation_Map_FieldDetails {
v := *b
b.x = nil
return structFieldNameStructRepresentation_Map_FieldDetailsMap(v)
return map__StructFieldName__StructRepresentation_Map_FieldDetails(v)
}
type typeNameList struct {
type list__TypeName struct {
x []TypeName
}
type typeNameListBuilder typeNameList
type list__TypeName__Builder list__TypeName
func (Compiler) MakeTypeNameList(ents ...TypeName) typeNameList {
func (Compiler) MakeList__TypeName(ents ...TypeName) list__TypeName {
x := make([]TypeName, len(ents))
copy(x, ents)
return typeNameList{x}
return list__TypeName{x}
}
func (Compiler) StartTypeNameList(sizeHint int) typeNameListBuilder {
return typeNameListBuilder{make([]TypeName, 0, sizeHint)}
func (Compiler) StartList__TypeName(sizeHint int) list__TypeName__Builder {
return list__TypeName__Builder{make([]TypeName, 0, sizeHint)}
}
func (b *typeNameListBuilder) Append(v TypeName) {
func (b *list__TypeName__Builder) Append(v TypeName) {
b.x = append(b.x, v)
}
func (b *typeNameListBuilder) Finish() typeNameList {
func (b *list__TypeName__Builder) Finish() list__TypeName {
v := *b
b.x = nil
return typeNameList(v)
return list__TypeName(v)
}
type stringTypeNameMap struct {
type map__String__TypeName struct {
x map[string]TypeName
}
type stringTypeNameEntry struct {
type map__String__TypeName__Entry struct {
k string
v TypeName
}
type stringTypeNameMapBuilder stringTypeNameMap
type map__String__TypeName__Builder map__String__TypeName
func (Compiler) MakeStringTypeNameMap(ents ...stringTypeNameEntry) stringTypeNameMap {
func (Compiler) MakeMap__String__TypeName(ents ...map__String__TypeName__Entry) map__String__TypeName {
x := make(map[string]TypeName, len(ents))
for _, y := range ents {
x[y.k] = y.v
}
return stringTypeNameMap{x}
return map__String__TypeName{x}
}
func (Compiler) MakeStringTypeNameMapEntry(k string, v TypeName) stringTypeNameEntry {
return stringTypeNameEntry{k, v}
func (Compiler) MakeMap__String__TypeName__Entry(k string, v TypeName) map__String__TypeName__Entry {
return map__String__TypeName__Entry{k, v}
}
func (Compiler) StartStringTypeNameMap(sizeHint int) stringTypeNameMapBuilder {
return stringTypeNameMapBuilder{make(map[string]TypeName, sizeHint)}
func (Compiler) StartMap__String__TypeName(sizeHint int) map__String__TypeName__Builder {
return map__String__TypeName__Builder{make(map[string]TypeName, sizeHint)}
}
func (b *stringTypeNameMapBuilder) Append(k string, v TypeName) {
func (b *map__String__TypeName__Builder) Append(k string, v TypeName) {
b.x[k] = v
}
func (b *stringTypeNameMapBuilder) Finish() stringTypeNameMap {
func (b *map__String__TypeName__Builder) Finish() map__String__TypeName {
v := *b
b.x = nil
return stringTypeNameMap(v)
return map__String__TypeName(v)
}
......@@ -85,7 +85,7 @@ func (schdmt Schema) Compile() (*schema.TypeSystem, []error) {
// Feed it all into the compiler.
c.TypeStruct(
schema.TypeName(tn.String()),
schema.Compiler{}.MakeStructFieldList(fields...),
schema.Compiler{}.MakeList__StructField(fields...),
rstrat,
)
case TypeUnion:
......@@ -118,7 +118,7 @@ func (schdmt Schema) Compile() (*schema.TypeSystem, []error) {
// Feed it all into the compiler.
c.TypeUnion(
schema.TypeName(tn.String()),
schema.Compiler{}.MakeTypeNameList(members...),
schema.Compiler{}.MakeList__TypeName(members...),
rstrat,
)
case TypeEnum:
......@@ -156,9 +156,9 @@ func (dmt MapRepresentation) compile(c *schema.Compiler) schema.MapRepresentatio
func (dmt StructRepresentation_Map) compile() schema.StructRepresentation {
if !dmt.FieldFields().Exists() {
return schema.Compiler{}.MakeStructRepresentation_Map(schema.Compiler{}.MakeStructFieldNameStructRepresentation_Map_FieldDetailsMap())
return schema.Compiler{}.MakeStructRepresentation_Map(schema.Compiler{}.MakeMap__StructFieldName__StructRepresentation_Map_FieldDetails())
}
fields := schema.Compiler{}.StartStructFieldNameStructRepresentation_Map_FieldDetailsMap(int(dmt.FieldFields().Must().Length()))
fields := schema.Compiler{}.StartMap__StructFieldName__StructRepresentation_Map_FieldDetails(int(dmt.FieldFields().Must().Length()))
for itr := dmt.FieldFields().Must().Iterator(); !itr.Done(); {
fn, det := itr.Next()
fields.Append(
......@@ -194,7 +194,7 @@ func (dmt StructRepresentation_Listpairs) compile() schema.StructRepresentation
}
func (dmt UnionRepresentation_Keyed) compile() schema.UnionRepresentation {
ents := schema.Compiler{}.StartStringTypeNameMap(int(dmt.Length()))
ents := schema.Compiler{}.StartMap__String__TypeName(int(dmt.Length()))
for itr := dmt.Iterator(); !itr.Done(); {
k, v := itr.Next()
ents.Append(k.String(), schema.TypeName(v.String()))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment