develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34552 - branches/rvar/languages/perl6/src/parser

From:
pmichaud
Date:
December 28, 2008 22:31
Subject:
[svn:parrot] r34552 - branches/rvar/languages/perl6/src/parser
Message ID:
20081229063153.94AFECB9FA@x12.develooper.com
Author: pmichaud
Date: Sun Dec 28 22:31:52 2008
New Revision: 34552

Modified:
   branches/rvar/languages/perl6/src/parser/actions.pm

Log:
[rakudo]:  Restore &-sigil vars.


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	Sun Dec 28 22:31:52 2008
@@ -1806,6 +1806,14 @@
         my $varname    := $sigil ~ $name;
         $past := PAST::Var.new( :name($varname), :node($/) );
 
+        if $sigil eq '&' {
+            $varname := $name;
+            $past.name($varname);
+            $past.scope('package');
+            my $sym := outer_symbol($varname);
+            if $sym && $sym<scope> { $past.scope( $sym<scope> ); }
+        }
+
         ##  if twigil is ^ or :, it's a placeholder var
         if $twigil eq '^' || $twigil eq ':' {
             if $?BLOCK.symbol('!signature') {
@@ -2485,6 +2493,18 @@
 }
 
 
+# search through outer blocks for a symbol table entry
+sub outer_symbol($name) {
+    our @?BLOCK;
+    my $symbol;
+    for @?BLOCK {
+        $symbol := $_.symbol($name);
+        if $symbol { return $symbol; }
+    }
+    return $symbol;
+}
+
+
 # Used by all calling code to process arguments into the correct form.
 sub build_call($args) {
     if !$args.isa(PAST::Op) || $args.name() ne 'infix:,' {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About