Created
August 19, 2009 16:50
-
-
Save ashgti/170457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[5] => PMC 'PAST;Op' { | |
<name> => "" | |
<source> => \past | |
<pos> => 153 | |
<pasttype> => "call" | |
<invocant_holder> => \past | |
[0] => PMC 'PAST;Op' { | |
<inline> => " %r = descalarref %0" | |
[0] => PMC 'PAST;Var' { | |
<sigil> => "$" | |
<source> => \past | |
<name> => "$b" | |
<pos> => 150 | |
} | |
} | |
[1] => PMC 'PAST;Op' { | |
<inline> => " %r = find_method %0, \"foo\"" | |
[0] => PMC 'PAST;Var' { | |
<name> => "A" | |
<namespace> => ResizablePMCArray (size:0) [ | |
] | |
<scope> => "package" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl6 | |
use v6; | |
class A { | |
method foo { say 'A::test'; } | |
} | |
class B is A { | |
method foo { | |
say 'but also B::foo'; | |
} | |
} | |
my B $b .= new; | |
A::foo $b; | |
$b.A::foo; | |
$b.'A::foo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/parser/actions.pm b/src/parser/actions.pm | |
index 05be6aa..e62933c 100644 | |
--- a/src/parser/actions.pm | |
+++ b/src/parser/actions.pm | |
@@ -1405,6 +1405,10 @@ method dottyop($/, $key) { | |
method methodop($/, $key) { | |
my $past; | |
+ | |
+ my @ns; | |
+ my $short_name; | |
+ my $scope_var; | |
if $key eq 'null' { | |
$past := PAST::Op.new(); | |
@@ -1416,7 +1420,32 @@ method methodop($/, $key) { | |
$past.node($/); | |
if $<name> { | |
- $past.name(~$<name>); | |
+ @ns := Perl6::Compiler.parse_name(~$<name>); | |
+ $short_name := ~@ns.pop(); | |
+ | |
+ if @ns { | |
+ $past.name(''); | |
+ $past.pasttype('call'); | |
+ | |
+ $scope_var := PAST::Op.new( | |
+ :inline(' %r = find_method %0, "' ~ $short_name ~ '"'), | |
+ PAST::Var.new( | |
+ :scope('package'), | |
+ :name(@ns.pop), | |
+ :namespace(@ns) | |
+ )); | |
+ | |
+ # $scope_var := PAST::Var.new( | |
+ # :scope('package'), | |
+ # :namespace(@ns), | |
+ # :name($short_name) | |
+ # ); | |
+ | |
+ $past.unshift($scope_var); | |
+ } | |
+ else { | |
+ $past.name(~$<name>); | |
+ } | |
} | |
elsif $<variable> { | |
$past.unshift( $<variable>.ast ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment