[svn:parrot] r41841 - in branches/pcc_reapply: include/parrot src src/ops src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Oct 13 19:54:04 UTC 2009


Author: bacek
Date: Tue Oct 13 19:54:04 2009
New Revision: 41841
URL: https://trac.parrot.org/parrot/changeset/41841

Log:
Prune parrot_interp_t struct. Also remove old version of mmd_sort_manhattan function which doesn't work anymore

Modified:
   branches/pcc_reapply/include/parrot/interpreter.h
   branches/pcc_reapply/include/parrot/multidispatch.h
   branches/pcc_reapply/src/multidispatch.c
   branches/pcc_reapply/src/ops/object.ops
   branches/pcc_reapply/src/pmc/continuation.pmc
   branches/pcc_reapply/src/pmc/multisub.pmc
   branches/pcc_reapply/src/sub.c

Modified: branches/pcc_reapply/include/parrot/interpreter.h
==============================================================================
--- branches/pcc_reapply/include/parrot/interpreter.h	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/include/parrot/interpreter.h	Tue Oct 13 19:54:04 2009	(r41841)
@@ -295,14 +295,6 @@
 
     UINTVAL recursion_limit;                  /* Sub call resursion limit */
 
-
-    opcode_t *current_args;                   /* ptr into code w/ set_args op */
-    opcode_t *current_params;                 /* ... w/ get_params op */
-    opcode_t *current_returns;                /* ... w/ get_returns op */
-    PMC      *args_signature;                 /* non-const args signature PMC */
-    PMC      *params_signature;               /* non-const params sig PMC     */
-    PMC      *returns_signature;              /* non-const returns sig PMC    */
-
     /* during a call sequencer the caller fills these objects
      * inside the invoke these get moved to the context structure */
     PMC *current_cont;                        /* the return continuation PMC */

Modified: branches/pcc_reapply/include/parrot/multidispatch.h
==============================================================================
--- branches/pcc_reapply/include/parrot/multidispatch.h	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/include/parrot/multidispatch.h	Tue Oct 13 19:54:04 2009	(r41841)
@@ -199,13 +199,6 @@
 PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-PMC * Parrot_mmd_sort_manhattan(PARROT_INTERP, ARGIN(PMC *candidates))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
 PMC * Parrot_mmd_sort_manhattan_by_sig_pmc(PARROT_INTERP,
     ARGIN(PMC *candidates),
     ARGIN(PMC *invoke_sig))
@@ -283,9 +276,6 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(name) \
     , PARROT_ASSERT_ARG(sig))
-#define ASSERT_ARGS_Parrot_mmd_sort_manhattan __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(candidates))
 #define ASSERT_ARGS_Parrot_mmd_sort_manhattan_by_sig_pmc \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \

Modified: branches/pcc_reapply/src/multidispatch.c
==============================================================================
--- branches/pcc_reapply/src/multidispatch.c	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/src/multidispatch.c	Tue Oct 13 19:54:04 2009	(r41841)
@@ -136,11 +136,6 @@
         __attribute__nonnull__(3);
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PMC* Parrot_mmd_arg_tuple_func(PARROT_INTERP)
-        __attribute__nonnull__(1);
-
-PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 static PMC * Parrot_mmd_get_cached_multi_sig(PARROT_INTERP,
     ARGIN(PMC *sub_pmc))
@@ -214,8 +209,6 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(name) \
     , PARROT_ASSERT_ARG(candidates))
-#define ASSERT_ARGS_Parrot_mmd_arg_tuple_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_Parrot_mmd_get_cached_multi_sig \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -396,141 +389,6 @@
 }
 
 
-/*
-
-=item C<PMC * Parrot_mmd_sort_manhattan(PARROT_INTERP, PMC *candidates)>
-
-Given an array PMC (usually a MultiSub) sorts the mmd candidates by their
-manhattan distance to the current args and returns the best one.
-
-=cut
-
-*/
-PARROT_EXPORT
-PARROT_CAN_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-PMC *
-Parrot_mmd_sort_manhattan(PARROT_INTERP, ARGIN(PMC *candidates))
-{
-    ASSERT_ARGS(Parrot_mmd_sort_manhattan)
-    const INTVAL n = VTABLE_elements(interp, candidates);
-
-    if (n) {
-        PMC * const arg_tuple = Parrot_mmd_arg_tuple_func(interp);
-        return Parrot_mmd_sort_candidates(interp, arg_tuple, candidates);
-    }
-
-    return PMCNULL;
-}
-
-
-/*
-
-=item C<static PMC* Parrot_mmd_arg_tuple_func(PARROT_INTERP)>
-
-Return a list of argument types. PMC arguments are taken from registers
-according to calling conventions.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-static PMC*
-Parrot_mmd_arg_tuple_func(PARROT_INTERP)
-{
-    ASSERT_ARGS(Parrot_mmd_arg_tuple_func)
-    PMC                *arg;
-    PMC                *args_array;    /* from recent set_args opcode */
-    PackFile_Constant **constants;
-
-    /*
-     * if there is no signature e.g. because of
-     *      m = getattribute l, "__add"
-     * - we have to return the MultiSub
-     * - create a BoundMulti
-     * - dispatch in invoke - yeah ugly
-     */
-
-    PMC * const arg_tuple = pmc_new(interp, enum_class_ResizableIntegerArray);
-    opcode_t   *args_op   = interp->current_args;
-    INTVAL sig_len, i, type;
-
-    if (!args_op)
-        return arg_tuple;
-
-    PARROT_ASSERT(*args_op == PARROT_OP_set_args_pc);
-    constants  = interp->code->const_table->constants;
-    ++args_op;
-    args_array = constants[*args_op]->u.key;
-
-    ASSERT_SIG_PMC(args_array);
-
-    sig_len = VTABLE_elements(interp, args_array);
-    if (!sig_len)
-        return arg_tuple;
-
-    ++args_op;
-
-    for (i = 0; i < sig_len; ++i, ++args_op) {
-        type = VTABLE_get_integer_keyed_int(interp, args_array, i);
-
-        /* named don't MMD */
-        if (type & PARROT_ARG_NAME)
-            break;
-        switch (type & (PARROT_ARG_TYPE_MASK | PARROT_ARG_FLATTEN)) {
-            case PARROT_ARG_INTVAL:
-                VTABLE_push_integer(interp, arg_tuple, enum_type_INTVAL);
-                break;
-            case PARROT_ARG_FLOATVAL:
-                VTABLE_push_integer(interp, arg_tuple, enum_type_FLOATVAL);
-                break;
-            case PARROT_ARG_STRING:
-                VTABLE_push_integer(interp, arg_tuple, enum_type_STRING);
-                break;
-            case PARROT_ARG_PMC:
-                {
-                const int idx = *args_op;
-                if ((type & PARROT_ARG_CONSTANT))
-                    arg = constants[idx]->u.key;
-                else
-                    arg = REG_PMC(interp, idx);
-
-                if (PMC_IS_NULL(arg))
-                    type = enum_type_PMC;
-                else
-                    type = VTABLE_type(interp, arg);
-
-                VTABLE_push_integer(interp, arg_tuple, type);
-                }
-                break;
-            case PARROT_ARG_FLATTEN | PARROT_ARG_PMC:  {
-                /* expand flattening args */
-                int j, n;
-
-                const int idx = *args_op;
-                arg           = REG_PMC(interp, idx);
-                n             = VTABLE_elements(interp, arg);
-
-                for (j = 0; j < n; ++j)  {
-                    PMC * const elem = VTABLE_get_pmc_keyed_int(interp, arg, j);
-                    type             = VTABLE_type(interp, elem);
-                    VTABLE_push_integer(interp, arg_tuple, type);
-                }
-                break;
-            }
-            default:
-                Parrot_ex_throw_from_c_args(interp, NULL, 1,
-                    "Unknown signature type %d in mmd_arg_tuple", type);
-                break;
-        }
-    }
-
-
-    return arg_tuple;
-}
-
 
 /*
 

Modified: branches/pcc_reapply/src/ops/object.ops
==============================================================================
--- branches/pcc_reapply/src/ops/object.ops	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/src/ops/object.ops	Tue Oct 13 19:54:04 2009	(r41841)
@@ -51,11 +51,8 @@
   STRING   * const meth       = $2;
   opcode_t * const next       = expr NEXT();
 
-  /* a class-specific find_method can overwrite interp->current_args()! */
-  opcode_t *current_args      = interp->current_args;
   PMC      * const method_pmc = VTABLE_find_method(interp, object, meth);
   opcode_t *dest              = NULL;
-  interp->current_args        = current_args;
 
   if (PMC_IS_NULL(method_pmc)) {
     PMC * const _class = VTABLE_get_class(interp, object);
@@ -95,11 +92,8 @@
   STRING   * const meth       = $2;
   opcode_t * const next       = expr NEXT();
 
-  /* a class-specific find_method can overwrite interp->current_args()! */
-  opcode_t *current_args      = interp->current_args;
   PMC      * const method_pmc = VTABLE_find_method(interp, object, meth);
   opcode_t *dest              = NULL;
-  interp->current_args        = current_args;
 
 
   if (PMC_IS_NULL(method_pmc)) {

Modified: branches/pcc_reapply/src/pmc/continuation.pmc
==============================================================================
--- branches/pcc_reapply/src/pmc/continuation.pmc	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/src/pmc/continuation.pmc	Tue Oct 13 19:54:04 2009	(r41841)
@@ -254,8 +254,6 @@
         }
 
         /* switch segment */
-        INTERP->current_args = NULL;
-
         if (INTERP->code != cc->seg)
             Parrot_switch_to_cs(INTERP, cc->seg, 1);
 

Modified: branches/pcc_reapply/src/pmc/multisub.pmc
==============================================================================
--- branches/pcc_reapply/src/pmc/multisub.pmc	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/src/pmc/multisub.pmc	Tue Oct 13 19:54:04 2009	(r41841)
@@ -62,17 +62,19 @@
                 SELF, sig_obj);
 
         if (PMC_IS_NULL(func))
-            Parrot_ex_throw_from_c_args(INTERP, NULL, 1,
-                "No applicable methods.\n");
+            Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
 
         return VTABLE_invoke(INTERP, func, next);
     }
 
     VTABLE PMC *get_iter() {
-        PMC * const sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
+        PMC * const sig_obj = CONTEXT(interp)->current_sig;
+        PMC * const sub     = Parrot_mmd_sort_manhattan_by_sig_pmc(interp,
+                SELF, sig_obj);
 
         if (PMC_IS_NULL(sub))
             Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
+
         return SUPER();
     }
 
@@ -81,14 +83,20 @@
        ResizablePMCArray's VTABLE methods of the same names. Hopefully we
        don't need anything beyond that. */
     VTABLE PMC *get_pmc_keyed(PMC *key) {
-        PMC * const sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
+        PMC * const sig_obj = CONTEXT(interp)->current_sig;
+        PMC * const sub     = Parrot_mmd_sort_manhattan_by_sig_pmc(interp,
+                SELF, sig_obj);
+
         if (PMC_IS_NULL(sub))
             Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
         return SUPER(key);
     }
 
     VTABLE PMC *get_pmc_keyed_str(STRING *s) {
-        PMC * const sub = Parrot_mmd_sort_manhattan(INTERP, SELF);
+        PMC * const sig_obj = CONTEXT(interp)->current_sig;
+        PMC * const sub     = Parrot_mmd_sort_manhattan_by_sig_pmc(interp,
+                SELF, sig_obj);
+
         if (PMC_IS_NULL(sub))
             Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "No applicable methods.\n");
         return SUPER(s);

Modified: branches/pcc_reapply/src/sub.c
==============================================================================
--- branches/pcc_reapply/src/sub.c	Tue Oct 13 19:53:31 2009	(r41840)
+++ branches/pcc_reapply/src/sub.c	Tue Oct 13 19:54:04 2009	(r41841)
@@ -138,12 +138,6 @@
              * the running program.
              */
             PMC      * const saved_ccont       = interp->current_cont;
-            opcode_t * const current_args      = interp->current_args;
-            opcode_t * const current_params    = interp->current_params;
-            opcode_t * const current_returns   = interp->current_returns;
-            PMC      * const args_signature    = interp->args_signature;
-            PMC      * const params_signature  = interp->params_signature;
-            PMC      * const returns_signature = interp->returns_signature;
 
             Parrot_block_GC_mark(interp);
 
@@ -151,12 +145,6 @@
 
             /* Restore stuff that might have got overwritten */
             interp->current_cont      = saved_ccont;
-            interp->current_args      = current_args;
-            interp->current_params    = current_params;
-            interp->current_returns   = current_returns;
-            interp->args_signature    = args_signature;
-            interp->params_signature  = params_signature;
-            interp->returns_signature = returns_signature;
 
             if (sub->name)
                 VTABLE_push_string(interp, ns_array, sub->name);


More information about the parrot-commits mailing list