Instantly share code, notes, and snippets.

What would you like to do?
pack, unpack, pack, unpack
  1. We wrap the macro argument QAST in a Perl6::AST object, which we incarnate immediately, since this is an object we'll only see one, due to the way parsing only proceeds forwards. This means we store OUTER information in the Perl6::AST.

  2. Most of the time, such a Perl6::AST object ends up in the unquote of a quasi. It should then be stripped of its Perl6::AST-hood, and the original QAST gets spliced into the quasi's QAST. We wrap the spliced-in QAST in a QAST::Block so that we can set the QAST::Block's OUTER to the Perl6::AST's OUTER. Since this is a runtime trait, we have to do this in the form of a fixup.

  3. The whole quasi is packaged up as an incarnated Perl6::AST.

  4. The macro returns, hopefully with a Perl6::AST. This is then similarly stripped of its Perl6::AST-hood, wrapped in a QAST::Block, and re-OUTERed with information from the Perl6::AST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment