Weekly GSoC progress report

I have finally implemented the closure deserialization correctly.
It required changing the way static lexicals are handle. (Static lexicals are the one declared by a QAST::Var node with a decl equal to 'static', which means they are bound to a serialized object and we are free to assume they don't get bound to at runtime). Previously for every code ref which was a part of a serialized object (but not a closure) I have emited code to recreat all the static lexicals for all of it's outer context. Needless to say the resulting code was long and ugly.
I'm now avoiding that by just inlining the code to fetch the value of the static lexical (which is not supposed to change) instead of actually accessing it. We also need to record the setting a closure uses, so that when we recreate all the lexicals all the builitins like &say etc. appear (they are loaded at runtime).
It turned out deserializing closures was the only things neccessary to get roles to work, which proves the power of having the metamodel written in Not Quite Perl. One thing that was neccessary to get ClassHOW.add_attribute to work was iterating over all the key/value pairs of a hash. I added a test for that and implemented that.
In the lowlevel metamodel code we use the more lowlevel nqp::iterkey_s and nqp::iterval forms instead of .key/.value as the method aren't setup yet.
What I'm currently working on is implementing grammars.
Grammars in Perl 6 are a hybrid of a top down recursive descent approach and a NFA (http://en.wikipedia.org/wiki/Nondeterministic_finite_automaton).
We need the automaton to efficiently find the longest matching token. Which in turn is necessary for proper language extensibility so we can add new constructs to Perl6 which won't be shadowed by existing one with a shorter prefix. Silly example: We could define and 'if 123' prefix operator and the grammar engine would try to use it first instead of an if statement.
As the grammars can mutate at runtime the AST is kept at runtime so that the NFA can be regenerated when adding a new rule to a protoregex. That means we need QAST::Node at runtime. Which I'm implementing right now. It's bringing up interesting bug in rakudo-js. For example default is a valid method name in Perl6 and it's need mangling in JavaScript. Many other bu
gs are uncovered (like problems in deserlialization for some more fancy code). I'll be fixing them and adding tests.
Example: https://github.com/perl6/nqp/blob/master/t/nqp/69-js-keywords-as-identif....
Luckily that was easily remedied https://github.com/pmurias/rakudo-js/commit/047be23822bea56a8ac175db9d18...