cvsuser 03/12/05 07:54:47
Modified: . MANIFEST
ops object.ops
Added: t/pmc object-meths.t
Log:
objects-6
* throw exception for unknown methods
* call a method - the hackish way
s. comments in test
Revision Changes Path
1.512 +2 -1 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.511
retrieving revision 1.512
diff -u -w -r1.511 -r1.512
--- MANIFEST 1 Dec 2003 22:16:31 -0000 1.511
+++ MANIFEST 5 Dec 2003 15:54:43 -0000 1.512
@@ -2247,6 +2247,7 @@
t/pmc/multiarray.t []
t/pmc/nci.t []
t/pmc/objects.t []
+t/pmc/object-meths.t []
t/pmc/orderedhash.t []
t/pmc/perlarray.t []
t/pmc/perlhash.t []
1.1 parrot/t/pmc/object-meths.t
Index: object-meths.t
===================================================================
#! perl -w
use Parrot::Test tests => 2;
use Test::More;
output_like(<<'CODE', <<'OUTPUT', "callmeth - unknown");
newclass P2, "Foo"
set S0, "nada"
callmeth
print "nope\n"
end
CODE
/Method 'nada' not found/
OUTPUT
output_is(<<'CODE', <<'OUTPUT', "callmeth 1");
newclass P2, "Foo"
set S0, "meth"
# cant mangle method names yet
find_global P3, "meth"
# so store ref to the sub with the real name
store_global "Foo\x0meth", P3
print "main\n"
callmethcc
print "back\n"
end
# .mangle "::" "\x00"
# .pcc_sub Foo::meth:
# or some such
.pcc_sub meth:
print "in meth\n"
invoke P1
CODE
main
in meth
back
OUTPUT
1.21 +6 -3 parrot/ops/object.ops
Index: object.ops
===================================================================
RCS file: /cvs/public/parrot/ops/object.ops,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- object.ops 5 Dec 2003 12:07:56 -0000 1.20
+++ object.ops 5 Dec 2003 15:54:47 -0000 1.21
@@ -46,12 +46,14 @@
op callmeth() {
PMC *method_pmc;
opcode_t *dest;
+ opcode_t *next = expr NEXT();
method_pmc = VTABLE_find_method(interpreter, REG_PMC(2), REG_STR(0));
if (NULL == method_pmc) {
- /* Pitch a fit */
+ real_exception(interpreter, next, METH_NOT_FOUND,
+ "Method '%Ss' not found", REG_STR(0));
}
REG_PMC(0) = method_pmc;
- dest = (opcode_t *)VTABLE_invoke(interpreter, REG_PMC(0), expr NEXT());
+ dest = (opcode_t *)VTABLE_invoke(interpreter, REG_PMC(0), next);
goto ADDRESS(dest);
}
@@ -64,7 +66,8 @@
method_pmc = VTABLE_find_method(interpreter, REG_PMC(2), REG_STR(0));
if (NULL == method_pmc) {
- /* Pitch a fit */
+ real_exception(interpreter, next, METH_NOT_FOUND,
+ "Method '%Ss' not found", REG_STR(0));
}
REG_PMC(0) = method_pmc;
dest = (opcode_t *)REG_PMC(0)->vtable->invoke(interpreter, REG_PMC(0), next);