Author: mdiep
Date: Thu Mar  8 08:52:09 2007
New Revision: 17384

Modified:
   trunk/src/pmc/delegate.pmc
   trunk/t/pmc/parrotobject.t

Log:
[core]: Fix #41733 - invoke :vtable - execution stops.

For the time being, the invoke :vtable doesn't work with arguments or
return values.


Modified: trunk/src/pmc/delegate.pmc
==============================================================================
--- trunk/src/pmc/delegate.pmc  (original)
+++ trunk/src/pmc/delegate.pmc  Thu Mar  8 08:52:09 2007
@@ -197,6 +197,27 @@
         return SUPER();
     }
 
+/*
+
+=item C<void *invoke(void *next)>
+
+Invokes a subroutine.
+
+=cut
+
+*/
+
+    void* invoke(void *next) {
+        STRING *meth = CONST_STRING(interp, "__invoke");
+        STRING *meth_v = CONST_STRING(interp, "invoke");
+        PMC *sub = Parrot_find_vtable_meth(interp, pmc, meth_v);
+        if (PMC_IS_NULL(sub))
+            sub = find_or_die(interp, pmc, meth);
+        (void *)Parrot_run_meth_fromc_args(interp, sub, pmc, meth, "??");
+
+        return next;
+    }
+
 }
 
 /*

Modified: trunk/t/pmc/parrotobject.t
==============================================================================
--- trunk/t/pmc/parrotobject.t  (original)
+++ trunk/t/pmc/parrotobject.t  Thu Mar  8 08:52:09 2007
@@ -6,7 +6,7 @@
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 9;
+use Parrot::Test tests => 11;
 
 =head1 NAME
 
@@ -192,7 +192,49 @@
 1
 OUT
 
-pir_output_like( <<'CODE', <<'OUT', 'RT#41732');
+pir_output_is(<<'CODE', <<'OUT', 'RT#41733 - Execution ends after returning 
from invoke');
+.namespace ['Foo']
+
+.sub invoke :vtable
+say "you invoked me!"
+.return()
+.end
+
+.sub main :main
+$P0 = newclass "Foo"
+$P1 = new "Foo"
+$P1()
+say "got here"
+.end
+CODE
+you invoked me!
+got here
+OUT
+
+pir_output_is(<<'CODE', <<'OUT', 'params/returns from overridden invoke', 
'todo' => 'not sure how to do this yet');
+.namespace ['Foo']
+
+.sub invoke :vtable
+  .param int a
+  print a
+  print "\n"
+  inc a
+  .return(a)
+.end
+
+.sub main :main
+  $P0 = newclass "Foo"
+  $P1 = new "Foo"
+  $I0 = $P1(2)
+  print $I0
+  print "\n"
+.end
+CODE
+2
+3
+OUT
+
+pir_output_like( <<'CODE', <<'OUT', 'RT#41732', 'todo' => 'not sure how to do 
this yet');
 .namespace ['Foo']
 
 .sub __invoke :method

Reply via email to