Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r35052 - branches/rvar/languages/perl6/src/parser
From:
jonathan
Date:
January 6, 2009 09:26
Subject:
[svn:parrot] r35052 - branches/rvar/languages/perl6/src/parser
Message ID:
20090106172630.EDEA8CB9F9@x12.develooper.com
Author: jonathan
Date: Tue Jan 6 09:26:30 2009
New Revision: 35052
Modified:
branches/rvar/languages/perl6/src/parser/actions.pm
Log:
[rakudo] Need to give subs/methods an empty signature if they don't have one declared by the user or from placeholders (which don't generate a signature yet - added a comment that we need to do that later).
Modified: branches/rvar/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar/languages/perl6/src/parser/actions.pm (original)
+++ branches/rvar/languages/perl6/src/parser/actions.pm Tue Jan 6 09:26:30 2009
@@ -845,6 +845,7 @@
@?BLOCK[0].symbol( $name, :scope('package') );
}
$past.control('return_pir');
+ create_signature_if_none($past);
make $past;
}
@@ -865,6 +866,7 @@
);
$past.control('return_pir');
+ create_signature_if_none($past);
make $past;
}
@@ -905,6 +907,7 @@
my $sigpast := PAST::Op.new( :pasttype('stmts'), :node($/) );
my $block := PAST::Block.new( $sigpast, :blocktype('declaration') );
$block<signature> := 1;
+ $block<explicit_signature> := 1;
@?BLOCK.unshift($block);
}
else {
@@ -1610,7 +1613,7 @@
# If twigil is ^ or :, it's a placeholder var. Create the
# parameter for the block if one doesn't already exist.
if $twigil eq '^' || $twigil eq ':' {
- if $?BLOCK<signature> {
+ if $?BLOCK<explicit_signature> {
$/.panic("Cannot use placeholder var in block with signature.");
}
$twigil := '';
@@ -1627,6 +1630,9 @@
$i--;
}
$block[$i] := $param;
+
+ # XXX Need to generate Signature accounting for the placeholders.
+ $?BLOCK<signature> := 1;
}
}
@@ -2630,6 +2636,19 @@
}
+# Adds an empty signature to a routine if it is missing one.
+sub create_signature_if_none($block) {
+ unless $block<signature> {
+ my $sigobj := PAST::Var.new( :scope('register') );
+ $block.loadinit().push(
+ PAST::Op.new( :inline(' %0 = new "Signature"',
+ ' setprop block, "$!signature", %0'),
+ $sigobj)
+ );
+ }
+}
+
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
-
[svn:parrot] r35052 - branches/rvar/languages/perl6/src/parser
by jonathan