1. 26 Apr, 2020 6 commits
  2. 19 Apr, 2020 1 commit
  3. 29 Mar, 2020 1 commit
    • Eric Myhre's avatar
      Begin reboot of codegen; also, some research. · 3f138f7f
      Eric Myhre authored
      In research: I found that there are more low-cost ways to switch which
      methods are available to call on a value than I thought.  Also, these
      techniques work even for methods of the same name.  This is going to
      improve some code in NodeAssemblers significantly -- there are several
      situations where this will let us reuse existing pieces of memory
      instead of needing to allocate new ones; even the basicnode package
      now already needs updates to improve this.  It's also going to make
      returning representation nodes from our typed nodes *significantly*
      easier and and lower in performance costs.  (Before finding methodsets
      are in fact so feasible, I was afraid this was going to require our
      typed nodes to embed yet another small struct with a pointer back to
      themselves so we can have amortized availability of value that contains
      the representation's logic for the Node interface... which while it
      certainly would've worked, would've definitely made me sigh deeply.)
      Quite exciting for several reasons; only wish I'd noticed this earlier.
      
      Also in research: I found a novel way to make it (I believe) impossible
      to create zero values of a type, whilst also making a symbol available
      for it in other packages, so that we can do type assertions, etc,
      with that symbol.  This is neat.  We're gonna use this to make sure
      that types in your schema package can never be created without passing
      through any validation logic that the user applies.
      
      In codegen: lots of files disappear.  I'm doing a tabula rasa workflow.
      (A bunch of the old files stick around in my working directory, and
      are being... "inspirational"... but everything is getting whitelisted
      before any of it ports over to the new commits.  This is an effective
      way to force myself to do things like naming consistency re-checks
      across the board.  And there's *very* little that's getting zero change
      since the changes to pointer strategy and assembler interface are so
      sweeping, so... there's very little reason *not* to tabula rasa.)
      
      Strings are reimplemented already.  *With* representations.
      
      Most of the codegen interfaces stay roughly the same so far.
      I've exported more things this time around.
      
      Lots of "mixins" based on lessons learned in the prior joust.
      (Also a bunch of those kind-based rejections look *much* nicer now,
      since we also made those standard across the other node packages.)
      
      Some parts of the symbol munging still up in the air a bit.
      I think I'm going to go for getting all the infrastructure in place
      for allowing symbol-rename adjunct configuration this time.
      (I doubt I'll wire it all the way up to real usable configuration yet,
      but it'll be nice to get as many of the interventions as possible into
      topologically the right places to minimize future effort required.)
      
      There's a HACKME_wip.md file which contains some other notes on
      priorities/goals/lessoned-learned-now-being-applied in this rewrite
      which may contain some information about what's changing at a higher
      level than trying to track the diffs.  (But, caveat: I'm not really
      writing it for an audience; more my own tracking.  So, it comes with
      no guarantee it will make sense or be useful.)
      3f138f7f
  4. 25 Oct, 2019 1 commit
  5. 24 Oct, 2019 2 commits
  6. 30 Aug, 2019 1 commit
    • Eric Myhre's avatar
      Add LookupSegment to Node interface. · c96c25d3
      Eric Myhre authored
      Fix traversal internals to use it (!) rather than converting segments
      to strings, which was both wasteful, and in some cases, *wrong* (!)
      (although by coincidence happened to mostly work at present because of
      another thing from early-days code that was also technically wrong).
      
      Fix ipldfree.Node to reject LookupString if used on a list node!
      (This is the other "wrong" thing that made the traversal coincidentally
      work.)
      
      LookupSegment method generation also added to codegen.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      c96c25d3
  7. 26 Aug, 2019 1 commit
    • Eric Myhre's avatar
      Fix generality of codegen helper mixins. · 5042c7e4
      Eric Myhre authored
      So far everything we've used these mixins for was generating based on
      a *schema.Type*.  This isn't true anymore: representation nodes are
      still nodes, so most of the same helpers are useful for the same
      reasons and we want to reuse them... but then now they're not always
      directly related to a particular reified schema.Type anymore.
      
      Correspondingly, these helper templates were using the .Type.Kind
      property as a shortcut to avoid more args, but that is wrong now:
      for example, if we're going to generate the representation node for
      a struct with a stringjoin representation, the closest thing we would
      have to a schema.Type is the struct; but that kind clearly isn't right.
      So, now that is another property passed internally to the embeddable
      helpers (the helper-helpers, I guess?), and affixed by the helper
      rather than provided by a schema.Type param (which, again, we no
      longer have).
      
      Note for more future work: this is the first time that a "TypeIdent"
      property has shown up explicitly, but it's also *all over* in the
      templates in a defacto way.  So far, my policy has been that extracting
      consts from the templates isn't a priority until it proves it has a
      reason to also be handled *outside* the immediate locality of the
      templates (because if we pulled *everything* out the templates will
      become a thin unreadable soup; and doing bulk sed-like edits to the
      templates is fairly easy as long as they're consistent).  Now, that
      criteria is probably satisfied, so more refactors on this are probably
      due very soon.
      
      And one more further sub-note on that note: I'm not actually sure if
      some of these types should have a "_" prefix on them or not.
      "$T_NodeBuilder" currently doesn't -- meaning it's exported -- and that
      might not be desirable.  I started them that way, so for now I'm just
      sticking with it, but it's a thing that deserves consideration.
      (It might be nice for godoc readability if there's a clear hint that
      the builders exist; but also, at present, there's no guarantee that
      their zero values are at all usable, and that should be cause for
      concern.  Other considerations may also exist; I haven't attepmted to
      weigh them all yet.)
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      5042c7e4
  8. 13 Aug, 2019 1 commit
    • Eric Myhre's avatar
      Add TypeName field to ErrWrongKind. · fe4aa0a8
      Eric Myhre authored
      In general, picking a consistent strategy with this error and sticking
      with it.  The strings were starting to accumulate too much ~stuff~,
      otherwise.
      
      It might not be a bad idea to upgrade the MethodName strings to a bunch
      of consts, but I don't think it will get any harder to do that in the
      future if we should so choose either, so, meh.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      fe4aa0a8
  9. 12 Aug, 2019 2 commits
  10. 20 Jul, 2019 4 commits
    • Eric Myhre's avatar
      Add Node.IsUndefined, ipld.Undef and ipld.Null. · 6802ea10
      Eric Myhre authored
      The comment in the ipld.Node type about IsUndefined has been there
      quite a while; today we're finally using it.
      
      With this set of changes, the generated code for structs now compiles
      successfully again: the Undef and Null thunks are both used there.
      6802ea10
    • Eric Myhre's avatar
      25702f19
    • Eric Myhre's avatar
      Ok, I have learned a hard lesson about embedding. · f6e469ce
      Eric Myhre authored
      Fields in these structs are now named.  Embedding is reserved for
      things that are very explicitly supposed to carry their methods along.
      
      At some earlier point, I embedded the Type field in some of the
      generate structs because it saved me a few keystrokes in refactoring
      template strings.  This was not important.
      
      Today I learned: if you have embeddings which cause a name to be
      shadowed -- as the generateKindedRejections_String.Type field
      could shadow the generateKindString.Type field, for example -- if those
      resolve "neutrally" (I don't know if there's a better technical term
      for this), then... in that case, the templating system will be like
      "yeah, fine, whatev", and it works.  If you give one of those two
      fields a *separate type*, the templating system will now reject it as
      if no field of that name can be found.
      
      I encountered this while working on the generator for structs (which I
      *swear* I will commit any second now, when I stop finding prerequisite
      yaks to shave -- there have been many) and trying to use a more
      specialized TypeStruct instead of the Type interface.  Whee.
      
      I get the logic of this.  The error message could be better.
      
      Anyway: even though it technically didn't affect generateString (yet),
      making the change here for consistency with what's to come
      (including specializing the field even though there's currently no
      actual need for it).
      f6e469ce
    • Eric Myhre's avatar
      Extract some error path generation. · 83bbe5e1
      Eric Myhre authored
      This isn't a net negative size diff yet, but it certainly will have
      that effect momentarily when we add a generator for another kind.
      More importantly, it reduces the set of functions in the real
      generator file to *just* the relevant ones.
      
      We'll almost certainly extend this to cover the NodeBuilder half of
      things as well, later; I just haven't gotten there yet.
      83bbe5e1