Commit f5b24ad8 authored by Eric Myhre's avatar Eric Myhre

typed: Commit some long-stale partial diffs.

(These have been on my working copy for *months*, waiting to get some
sliver of time to get back to working on this half of the project...)

So, back in the last time period I was working on schemas, it seemed
plausible to try to get some self-bootstrapping amount of codegen to
help me write the whole declaration package itself.  This has not
held up, lol.

The long end of line comment is my updated feelings about this:
the main reason self-hosting even during bootstrap would've been nice
is for map order consistency.  But... we don't... need that.  Per se.

This commit will be merge-ignored momentarily; gonna pick up on
schema work again starting from a somewhat different angle of attack.
Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent 4169feeb
......@@ -125,7 +125,7 @@ var (
)
type TypeStruct struct {
Fields map[string]StructField
Fields AnonMap__TypeStruct__fields // map order things are the main reason it's tempting to do bilgey generation mixing. do gen 1 and gen 2. just *ignore* map order in gen 1 -- it's only relevant to determinstic generation, and *we can skip that* until generation 2!
Representation StructRepresentation
}
......
package typedeclaration
import "fmt"
type String string
// Get looks up a value in the map by key.
//
// TraverseField performs a similar function, but is the ipld.Node generic variant;
// Get takes the native typed key and explicitly returns the native typed value.
//
// This is a generated method.
func (m AnonMap__TypeStruct__fields) Get(k String) (*StructField, error) {
v, ok := m.val[k]
if !ok {
return nil, fmt.Errorf("404")
}
return &v, nil
}
type AnonMap__TypeStruct__fields struct {
val map[String]StructField
ord []string
}
......@@ -27,6 +27,18 @@ func Test(t *testing.T) {
KeyType: "String",
ValueType: declaration.TypeName("TypeName"),
}},
{"AnonMap__TypeStruct__fields", declaration.TypeMap{ // hacky placeholder name; avoiding using power of TypeTerm for now.
KeyType: "String",
ValueType: declaration.TypeName("StructField"),
}},
{"StructField", declaration.TypeStruct{
// TODO TypeStruct is gonna be a barrel of laughs: `Fields: AnonMap__TypeStruct_fields{}` -- you're gonna need nodebuilders to even hardcode this.
// ahaha and the fields are unexported so we literally really do need a builder.
Fields: declaration.AnonMap__TypeStruct__fields{}, //__Build ?
// Type: declaration.TypeName("TypeTerm"),
// Optional: declaration.TypeName("Bool"),
// Nullable: declaration.TypeName("Bool"),
}},
}
os.Mkdir("test", 0755)
openOrPanic := func(filename string) *os.File {
......
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