Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created August 19, 2009 18:49
Show Gist options
  • Save ashgti/170571 to your computer and use it in GitHub Desktop.
Save ashgti/170571 to your computer and use it in GitHub Desktop.
From 6cb500344a9e51c7c80a0c037c36b3edf7dd00d6 Mon Sep 17 00:00:00 2001
From: John Harrison <ash@greaterthaninfinity.com>
Date: Wed, 19 Aug 2009 13:32:39 -0500
Subject: [PATCH 9/9] Updated direct calling for parent methods.
---
src/builtins/guts.pir | 3 +++
src/parser/actions.pm | 29 ++++++++++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/builtins/guts.pir b/src/builtins/guts.pir
index 9d45304..0575278 100644
--- a/src/builtins/guts.pir
+++ b/src/builtins/guts.pir
@@ -106,9 +106,12 @@ Does an indirect method dispatch.
.param pmc pos_args :slurpy
.param pmc name_args :slurpy :named
+ $I0 = isa methodish, 'P6Invocation'
+ if $I0 goto ready_to_dispatch
$P0 = get_hll_global 'Callable'
$I0 = $P0.'ACCEPTS'(methodish)
unless $I0 goto candidate_list
+ ready_to_dispatch:
.tailcall methodish(obj, pos_args :flat, name_args :flat :named)
candidate_list:
diff --git a/src/parser/actions.pm b/src/parser/actions.pm
index 05be6aa..bac705a 100644
--- a/src/parser/actions.pm
+++ b/src/parser/actions.pm
@@ -1387,9 +1387,8 @@ method dotty($/, $key) {
# We actually need to send dispatches for named method calls (other than .*)
# through the.dispatcher.
- if $<dottyop><methodop><variable> {
+ if $past.pasttype() eq 'call' {
$past.name('!dispatch_method_indirect');
- $past.pasttype('call');
}
}
@@ -1405,6 +1404,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,10 +1419,30 @@ 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)
+ ));
+
+ $past.unshift($scope_var);
+ }
+ else {
+ $past.name(~$<name>);
+ }
}
elsif $<variable> {
$past.unshift( $<variable>.ast );
+ $past.pasttype('call');
}
else {
$past.name( $<quote>.ast );
--
1.6.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment