Author: leo
Date: Wed Aug 10 02:25:20 2005
New Revision: 8901

Modified:
   branches/leo-ctx5/classes/parrotio.pmc
   branches/leo-ctx5/imcc/parser_util.c
   branches/leo-ctx5/imcc/pcc.c
   branches/leo-ctx5/t/pmc/builtin.t
Log:
fix class method; reenable test

Modified: branches/leo-ctx5/classes/parrotio.pmc
==============================================================================
--- branches/leo-ctx5/classes/parrotio.pmc      (original)
+++ branches/leo-ctx5/classes/parrotio.pmc      Wed Aug 10 02:25:20 2005
@@ -38,9 +38,8 @@ as class method
 */
 
     METHOD INTVAL say(STRING *s) {
-        PMC *p2  = CONTEXT(INTERP->ctx)->current_object;
-        PMC *out = p2 == Parrot_base_vtables[enum_class_ParrotIO]->class ?
-            PIO_STDOUT(INTERP) : p2;
+        PMC *out = SELF == Parrot_base_vtables[enum_class_ParrotIO]->class ?
+            PIO_STDOUT(INTERP) : SELF;
         INTVAL r = PIO_putps(INTERP, out, s);
         r  += PIO_puts(INTERP, out, "\n");
         return r;

Modified: branches/leo-ctx5/imcc/parser_util.c
==============================================================================
--- branches/leo-ctx5/imcc/parser_util.c        (original)
+++ branches/leo-ctx5/imcc/parser_util.c        Wed Aug 10 02:25:20 2005
@@ -296,6 +296,7 @@ maybe_builtin(Interp *interpreter, IMC_U
         sub = ins->r[0];
         IMCC_itcall_sub(interpreter, meth);
         sub->pcc_sub->object = ns_sym;
+
         first_arg = 1;
     }
     else {    /* method y = x."cos"() */

Modified: branches/leo-ctx5/imcc/pcc.c
==============================================================================
--- branches/leo-ctx5/imcc/pcc.c        (original)
+++ branches/leo-ctx5/imcc/pcc.c        Wed Aug 10 02:25:20 2005
@@ -288,8 +288,20 @@ expand_pcc_sub_call(Parrot_Interp interp
     sub = ins->r[0];
     tail_call = (sub->pcc_sub->flags & isTAIL_CALL);
 
-    if (sub->pcc_sub->object)
+    if (sub->pcc_sub->object) {
         meth_call = 1;
+        /* set P2, obj */
+        if (sub->pcc_sub->object->color != 2) {
+            regs[0] = get_pasm_reg(interp, "P2");
+            regs[1] = sub->pcc_sub->object;
+            if (regs[1]->set == 'S') {
+                ins = insINS(interp, unit, ins, "getclass", regs, 2);
+                sub->pcc_sub->object = regs[0];
+            }
+            else
+                ins = insINS(interp, unit, ins, "set", regs, 2);
+        }
+    }
 
     /*
      * See if we need to create a temporary sub object for the short
@@ -364,15 +376,6 @@ expand_pcc_sub_call(Parrot_Interp interp
                 s0 = mk_const(interp, str_dup(arg->name), 'S');
         }
 
-        /* set P2, obj */
-        if (sub->pcc_sub->object->color != 2) {
-            regs[0] = get_pasm_reg(interp, "P2");
-            regs[1] = sub->pcc_sub->object;
-            if (regs[1]->set == 'S')
-                ins = insINS(interp, unit, ins, "getclass", regs, 2);
-            else
-                ins = insINS(interp, unit, ins, "set", regs, 2);
-        }
     }
 
     /*

Modified: branches/leo-ctx5/t/pmc/builtin.t
==============================================================================
--- branches/leo-ctx5/t/pmc/builtin.t   (original)
+++ branches/leo-ctx5/t/pmc/builtin.t   Wed Aug 10 02:25:20 2005
@@ -45,9 +45,27 @@ function      0.540302
 method        0.540302
 OUT
 
+pir_output_is(<<'CODE', <<'OUT', "say");
+.sub main @MAIN
+    .local pmc io
+    $I0 = say "ok 1"
+    io = getstdout
+    $I0 = say io, "ok 2"
+    say "ok 3"
+    say io, "ok 4"
+    "say"(io, "ok 5")
+.end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUT
+
 SKIP: {
-    skip("class methods - n/y", 3);
-pir_output_is(<<'CODE', <<'OUT', "class methods");
+    skip("bound methods - n/y", 2);
+pir_output_is(<<'CODE', <<'OUT', "bound methods");
 .sub main @MAIN
     .local pmc x, y, cl, m
     x = new Float
@@ -97,20 +115,4 @@ ok 4
 ok 5
 OUT
 
-pir_output_is(<<'CODE', <<'OUT', "say");
-.sub main @MAIN
-    .local pmc io
-    $I0 = say "ok 1"
-    io = getstdout
-    $I0 = say io, "ok 2"
-    say "ok 3"
-    say io, "ok 4"
-.end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUT
-
 }

Reply via email to