while trying to write a test for subclassing the Exporter PMC in PIR, i came across a problem: there's no way i can find to call a supermethod. the supermethodcc opcode isn't implemented. and even if it was, there's no PIR sugar to make the call pretty. the Super PMC is broken and has been for some time.
attached, please find my patch. i'm blocking on this effort until it can be resolved; of course there are plenty of other things for me to do. based on a recent pdd commit, i suspect this is fresh on the minds of allison and jonathan, so i figure it's best for me to provide this patch now rather than implementing anything that may or may not make sense in the near future. ~jerry
Index: t/pmc/exporter.t =================================================================== --- t/pmc/exporter.t (revision 20910) +++ t/pmc/exporter.t (working copy) @@ -6,7 +6,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 12; +use Parrot::Test tests => 13; =head1 NAME @@ -418,6 +418,73 @@ OUT +pir_output_is( <<'CODE', <<'OUT', 'PIR subclass' ); +.sub 'test' :main + .local pmc exp, ns + exp = new 'MyExporter' + ns = get_namespace ['foo'] + exp.'import'( 'foo' :named('source'), 'bar' :named('globals') ) + 'bar'() +.end + + +.namespace ['MyExporter'] +.include 'call_bits.pasm' + +.sub 'onload' :load :init + .local pmc class + class = subclass 'Exporter', 'MyExporter' + .return (class) +.end + +# override Exporter's 'globals' method, and call the super method +# this multi variant is enough to handle this test case +# real code needs a default multi to deal with does(hash) and does(array) +.sub 'globals' :method :multi(String) + .param string globals :optional + .param int has_globals :opt_flag + # the params above aren't really optional + # since otherwise this multi variant wouldn't have been called + + unless has_globals goto returns + .local pmc glb_pre, glb_post + glb_pre = new 'ResizableStringArray' + glb_post = new 'ResizableStringArray' + glb_pre = split ' ', globals + + .local pmc iter + iter = new 'Iterator', glb_pre + lp: + unless iter goto ex + .local string glb + glb = shift iter + glb = concat '&', glb + push glb_post, glb + ex: + globals = glb_post + # call the superclass method - TODO really need PIR sugar here + $I0 = PARROT_ARG_NAME + $S0 = concat '(', $I0 + $S0 = concat $S0, ')' + set_args $S0, globals + callmethodsupercc 'globals' + + returns: + .return 'globals'() + end: + .return () +.end + + +.namespace ['foo'] + +.sub '&bar' + print 'ok' +.end +CODE +OUT + + # TODO test exporting mmd subs