as the perl6 compiler grows, it needs more and more customization. in order to make it easier to customize, today i decided that rather than having 'Perl6::Compiler' be an instance of 'PCT::HLLCompiler', it was time to make it a subclass. this was incredibly easy.
view the patch here:
http://perlsix.org/svn/parrot/revision/?rev=24706>
previously all the initialization code in perl6.pir ran during library load. a 'PCT::HLLCompiler' object was created, attribute values were assigned, etc. now, we'll generate a subclass at library load time, and inside the 'init' method of the subclass we'll deal with attribute assignment and the like.
the first difference is in the 'onload' subroutine. i load the 'Protomaker' bytecode, which allows me to work with parrot protoobjects. first, i get the 'Protomaker' protoobject and stash it in the virtual register $P0. next, i get the 'PCT::HLLCompiler' class, and then i call the 'new_subclass' method on Protomaker to create a new subclass of 'PCT::HLLCompiler' named 'Perl6::Compiler'. that ends the 'onload' subroutine, and initialization continues in the 'init' vtable method.
in the next differences, there are two things going on. firstly, i remove the call to create a new PCT::HLLCompiler, since 'Perl6::Compiler' is now a subclass. secondly, inside parrot methods 'self' is automatically defined, so the remaining differences are simply to replace the virtual register '$P0' with the keyword 'self'.