Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen: approaching self-host #61

Merged
merged 7 commits into from
Jul 27, 2020
Merged

Codegen: approaching self-host #61

merged 7 commits into from
Jul 27, 2020

Conversation

warpfork
Copy link
Collaborator

This branch has a collection of miscellaneous fixes and improvements that are covering the remaining ground to where the system can host its own description. (That last milestone will come in another PR, but will be right on the heels of this one.)

  • The type info in the schema package had to be refactored (it now uses more pointers, and the 'Spawn' methods use more strings) so that it can describe cycles.
  • There's now a graph completeness validator for the type info.
  • Various other minor fixes...
    • Some vestigial tests are dropped (just housekeeping).
    • The rest of the 'Spawn{Kind}' methods are now in place.
    • A couple of fixes for generation around keyed unions were made (brought on my more tests).
    • Field symbol override configuration now works correctly. (We'll need this when we wrangle codegen of the schema-schema, momentarily, because it has fields named "type", which is of course a reserved word in golang!)

The diff is a bit large, since all the tests using the 'Spawn' methods for type info changed to account for the cycle description feature. The rest is minor stuff.

warpfork added 7 commits July 9, 2020 17:23
These were apparently never used, or their users got churned under
at some point and I failed to clean these up at the same time.

It's a good idea to have tests that are agnostic to codegen vs
runtime type semantics implementations... but at this point we should
reengage with that by just extracting the stuff currently in the
codegen package's tests, because it's much more comprehensive and
also almost entirely abstracted already (it just happens to be in the
wrong place in the file/package hierarchy for no particular reason).
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.
This thing need to be replaced with non-placeholder code soon; it's
getting pretty nasty.
@warpfork warpfork merged commit 8eda117 into master Jul 27, 2020
@warpfork warpfork deleted the moar-codegen branch July 27, 2020 19:48
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant