• Eric Myhre's avatar
    Refactor the schema.Type info to support cycles. · 47abab45
    Eric Myhre authored
    This is full of mundane plonking away at adding stars and ampersands,
    of which approximately none are interesting.
    
    (I'm particularly frustrated by this because these are all placeholder
    types, and we're getting *very* close to replacing them, as we get
    closer and closer to self-hosting... at which point all of this bonking
    about will be made totally irrelevant.  And yet to close the last mile,
    these "small" fixes are surprisingly irritating.  Ah well.)
    
    The bits that *are* interesting:
    
    - the Spawn functions for type info now take strings rather than types
    (so that they don't provoke a cycle problem for the user when
    constructing the information to describe cyclic type info);
    
    - all of the Type info structure hold a pointer to the TypeSystem, and
    use that to look up reified Type info for related types, so that their
    methods don't force the caller to do that themselves.
    
    (The TypeSystem pointer was already there, amusingly; just never before
    initialized, because it hadn't turned out to be load-bearing yet.)
    
    It also would've been possible to just change all the methods on the
    Type types to return TypeName rather than full Type info.  That would
    avoid the need to use a TypeSystem pointer.  I didn't because:
    
    Overall, this was done in such a way as to minimize the diff that
    impacts within the templates.  This was a goal because updating
    templates is a fair bit more work than other code due to the weak
    compiler support.  And we'll end up reviewing and changing these
    methods when we get to our goal of self-hosting generation of the
    schema types from the schema-schema, so, it's not worth pushing around
    diffs in that same area when they'd be sure to be churned under soon.
    47abab45
tmpBuilders.go 4.03 KB