develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35154 - branches/rvar2/languages/perl6/src/parser

From:
jonathan
Date:
January 7, 2009 10:11
Subject:
[svn:parrot] r35154 - branches/rvar2/languages/perl6/src/parser
Message ID:
20090107181054.9C918CB9F9@x12.develooper.com
Author: jonathan
Date: Wed Jan  7 10:10:53 2009
New Revision: 35154

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

Log:
[rakudo] Make 'has $x' style declarations work correctly again. This gets us compiling and passing some of S12-class/attributes.t.

Modified: branches/rvar2/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar2/languages/perl6/src/parser/actions.pm	(original)
+++ branches/rvar2/languages/perl6/src/parser/actions.pm	Wed Jan  7 10:10:53 2009
@@ -1405,6 +1405,17 @@
             if $_.isa(PAST::Var) {
                 my $var := $_;
 
+                # If it's an attribute with no twigil, need to modify the
+                # name to include one, but also register it in the block
+                # with the original name.
+                if $scope eq 'attribute' && $var<twigil> eq '' {
+                    $block.symbol( $var.name(), :scope($scope) );
+                    $var<twigil> := '!';
+                    my $sigil := substr($var.name(), 0, 1);
+                    my $name  := substr($var.name(), 1);
+                    $var.name($sigil ~ '!' ~ $name);
+                }
+
                 # This is a variable declaration, so we set the scope in
                 # the block's symbol table as well as the variable itself.
                 $block.symbol( $var.name(), :scope($scope) );



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