Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

particle (3326)

particle
  (email not shown publicly)

Journal of particle (3326)

Wednesday January 09, 2008
06:31 PM

[perl6]: subclass PCT::HLLCompiler

[ #35342 ]

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'.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.