Author: leo
Date: Sat Apr 23 03:47:26 2005
New Revision: 7917

Modified:
   trunk/imcc/parser_util.c
   trunk/imcc/pcc.c
   trunk/src/builtin.c
   trunk/src/trace.c
Log:
trace: disassemble infix; better builtin calls

* convert infix, n_infix back to user opcde in trace
* fix indexed trace output
* don't emit callmethodcc for builtin NCI calls



Modified: trunk/imcc/parser_util.c
==============================================================================
--- trunk/imcc/parser_util.c    (original)
+++ trunk/imcc/parser_util.c    Sat Apr 23 03:47:26 2005
@@ -297,6 +297,7 @@
         sub = ins->r[0];
         IMCC_itcall_sub(interpreter, meth);
         sub->pcc_sub->object = ns_sym;
+        sub->pcc_sub->nci = 1;
         for (i = 1; i < n; ++i) {
             add_pcc_arg(sub, rr[i]);
         }
@@ -309,6 +310,7 @@
         sub = ins->r[0];
         IMCC_itcall_sub(interpreter, meth);
         sub->pcc_sub->object = rr[1];
+        sub->pcc_sub->nci = 1;
         for (i = 2; i < n; ++i) {
             add_pcc_arg(sub, rr[i]);
         }

Modified: trunk/imcc/pcc.c
==============================================================================
--- trunk/imcc/pcc.c    (original)
+++ trunk/imcc/pcc.c    Sat Apr 23 03:47:26 2005
@@ -932,17 +932,24 @@
 
     /*
      * setup P0, and P2, S0 if method
+     *
+     * Due to implicit call arguments (call opcodes that
+     * either take a Sub/P0, method/S2, return continuation/P1,
+     * object/P2 or not)
+     * this is really a mess
      */
     arg = sub->pcc_sub->sub;
     if (meth_call) {
         /* set S0, meth */
         regs[0] = get_pasm_reg(interp, "S0");;
-        if ( (arg->type == VTIDENTIFIER ||
-                 arg->type == VTPASM ||
-                 arg->type == VTREG))
-            s0 = arg;
-        else
-            s0 = mk_const(interp, str_dup(arg->name), 'S');
+        if (arg->set != 'P') {
+            if ( (arg->type == VTIDENTIFIER ||
+                        arg->type == VTPASM ||
+                        arg->type == VTREG))
+                s0 = arg;
+            else
+                s0 = mk_const(interp, str_dup(arg->name), 'S');
+        }
 
         /* set P2, obj */
         if (sub->pcc_sub->object->color != 2) {
@@ -953,7 +960,7 @@
             else
                 ins = insINS(interp, unit, ins, "set", regs, 2);
         }
-        if (sub->pcc_sub->nci)
+        if (sub->pcc_sub->nci && (!meth_call || arg->set == 'P'))
             goto move_sub;
     }
     else {
@@ -1010,7 +1017,7 @@
      *
      * so convert to opcode and await the returned PMC as P5
      */
-    if (meth_call && strcmp(s0->name, "\"instantiate\"") == 0) {
+    if (meth_call && s0 && strcmp(s0->name, "\"instantiate\"") == 0) {
         SymReg *p5 = get_pasm_reg(interp, "P5");
         regs[0] = p5;
         ins = insINS(interp, unit, ins, "instantiate", regs, 1);
@@ -1023,7 +1030,7 @@
             if (!need_cc)
                 ins = insINS(interp, unit, ins, "updatecc", regs, 0);
         /* insert the call */
-        if (meth_call && !sub->pcc_sub->nci) {
+        if (meth_call && sub->pcc_sub->sub->set != 'P') {
             regs[0] = s0;
             n = 0;
             if (s0)

Modified: trunk/src/builtin.c
==============================================================================
--- trunk/src/builtin.c (original)
+++ trunk/src/builtin.c Sat Apr 23 03:47:26 2005
@@ -33,6 +33,7 @@
 
 static Builtins builtins[] = {
     { "cos",   "P!O",          "Float",        0, 0 },
+    { "index",  "I!SS.I",       "String",       0, 0 },
     { "lower",         "P!O",          "String",       0, 0 },
     { "open",  "P!S.S",        "ParrotIO",     0, 0 },
     { "puts",  "I!OS",         "ParrotIO",     0, 0 }

Modified: trunk/src/trace.c
==============================================================================
--- trunk/src/trace.c   (original)
+++ trunk/src/trace.c   Sat Apr 23 03:47:26 2005
@@ -217,21 +217,35 @@
 trace_op_dump(Interp *interpreter, opcode_t *code_start,
               opcode_t *pc)
 {
-    INTVAL i;
+    INTVAL i, s;
     char *escaped;
     int more = 0;
     op_info_t *info = &interpreter->op_info_table[*pc];
 
-    PIO_eprintf(interpreter, "%6vu %s", (UINTVAL)(pc - code_start), 
info->name);
+    s = 1;
+    PIO_eprintf(interpreter, "%6vu ", (UINTVAL)(pc - code_start));
+    if (strcmp(info->name, "infix") == 0) {
+            PIO_eprintf(interpreter, "%s",
+                    Parrot_MMD_method_name(interpreter, pc[1]) + 2);
+            s = 2;
+    }
+    else if (strcmp(info->name, "n_infix") == 0) {
+            PIO_eprintf(interpreter, "n_%s",
+                    Parrot_MMD_method_name(interpreter, pc[1]) + 2);
+            s = 2;
+    }
+    else
+        PIO_eprintf(interpreter, "%s", info->name);
 
     if (info->arg_count > 1) {
         PIO_eprintf(interpreter, " ");
         /* pass 1 print arguments */
-        for (i = 1; i < info->arg_count; i++) {
+        for (i = s; i < info->arg_count; i++) {
             opcode_t o = *(pc + i);
-            if (i > 1 &&
+            if (i > s &&
                     info->types[i] != PARROT_ARG_KC &&
                     info->types[i] != PARROT_ARG_KIC &&
+                    info->types[i] != PARROT_ARG_KI &&
                     info->types[i] != PARROT_ARG_K
                     ) {
                 PIO_eprintf(interpreter, ", ");
@@ -260,6 +274,10 @@
                 case PARROT_ARG_KIC:
                     PIO_eprintf(interpreter, "[%vd]", o);
                     break;
+                case PARROT_ARG_KI:
+                    PIO_eprintf(interpreter, "[I%vd]", o);
+                    more = 1;
+                    break;
                 case PARROT_ARG_K:
                     PIO_eprintf(interpreter, "[P%vd]",o);
                     more = 1;
@@ -280,10 +298,6 @@
                     PIO_eprintf(interpreter, "S%vd", o);
                     more = 1;
                     break;
-                case PARROT_ARG_KI:
-                    PIO_eprintf(interpreter, "I%vd", o);
-                    more = 1;
-                    break;
                 default:
                     internal_exception(1, "unhandled type in trace");
                     break;
@@ -295,7 +309,7 @@
         /* pass 2 print argument details if needed */
         for (i = 1; i < info->arg_count; i++) {
             opcode_t o = *(pc + i);
-            if (i > 1) {
+            if (i > s) {
                 PIO_eprintf(interpreter, ", ");
             }
             switch (info->types[i]) {

Reply via email to