Skip to content

Commit

Permalink
Can't .include the parametric roles macro at runtime, so just inline …
Browse files Browse the repository at this point in the history
…the PIR (best I can think of for now; don't see to have Q:PIR{ } in NQP, which may allow something shorter).
  • Loading branch information
jnthn committed Apr 4, 2009
1 parent 2ed3618 commit f17a691
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/parser/actions.pm
Expand Up @@ -20,9 +20,26 @@ method TOP($/) {
declare_implicit_routine_vars($past);
$past.lexical(0);

# Make sure we have the interpinfo constants and parametric role macros.
# Make sure we have the interpinfo constants and parametric role macro.
$past.unshift( PAST::Op.new( :inline('.include "interpinfo.pasm"') ) );
$past.unshift( PAST::Op.new( :inline('.include "src/pr_macros.pir"') ) );
$past.unshift( PAST::Op.new( :inline('.macro create_parametric_role(mr)',
' "!meta_compose"(.mr)',
' .local pmc orig_role, meths, meth_iter',
' orig_role = getprop "$!orig_role", .mr',
' meths = orig_role."methods"()',
' meth_iter = iter meths',
' it_loop:',
' unless meth_iter goto it_loop_end',
' $S0 = shift meth_iter',
' $P0 = meths[$S0]',
' $P1 = getprop "$!signature", $P0',
' $P0 = newclosure $P0',
' setprop $P0, "$!signature", $P1',
' .mr."add_method"($S0, $P0)',
' goto it_loop',
' it_loop_end:',
' .return (.mr)',
'.endm') ) );

# Set package for unit mainline
$past.unshift(set_package_magical());
Expand Down

0 comments on commit f17a691

Please sign in to comment.