Author: Whiteknight
Date: Sun Nov 30 14:25:55 2008
New Revision: 33382

Modified:
   branches/call_conv_redux/src/inter_call.c
   branches/call_conv_redux/src/multidispatch.c

Log:
[call_conv_redux] removing some unneeded cruft to get a better idea of what 
else has changed

Modified: branches/call_conv_redux/src/inter_call.c
==============================================================================
--- branches/call_conv_redux/src/inter_call.c   (original)
+++ branches/call_conv_redux/src/inter_call.c   Sun Nov 30 14:25:55 2008
@@ -1865,71 +1865,6 @@
     return NULL;
 }
 
-
-/*
-
-=item C<static void commit_last_arg>
-
-Called by C<Parrot_PCCINVOKE> when it reaches the end of each arg in the arg
-signature.  See C<Parrot_PCCINVOKE> for signature syntax.
-
-=cut
-
-*/
-
-static void
-commit_last_arg(PARROT_INTERP, int index, int cur,
-    ARGMOD(opcode_t *n_regs_used), int seen_arrow, ARGIN(PMC * const *sigs),
-    ARGMOD(opcode_t **indexes), ARGMOD(Parrot_Context *ctx),
-    ARGIN_NULLOK(PMC *pmc), ARGIN(va_list *list))
-{
-    int reg_offset = 0;
-
-    /* invocant already commited, just return */
-    if (seen_arrow == 0 && index == 0 && pmc)
-        return;
-
-    /* calculate arg's register offset */
-    switch (cur & PARROT_ARG_TYPE_MASK) { /* calc reg offset */
-        case PARROT_ARG_INTVAL:
-            reg_offset = n_regs_used[seen_arrow * 4 + REGNO_INT]++; break;
-        case PARROT_ARG_FLOATVAL:
-            reg_offset = n_regs_used[seen_arrow * 4 + REGNO_NUM]++; break;
-        case PARROT_ARG_STRING:
-            reg_offset = n_regs_used[seen_arrow * 4 + REGNO_STR]++; break;
-        case PARROT_ARG_PMC :
-            reg_offset = n_regs_used[seen_arrow * 4 + REGNO_PMC]++; break;
-        default:
-            Parrot_ex_throw_from_c_args(interp, NULL, 
EXCEPTION_INVALID_OPERATION,
-                "Parrot_PCCINVOKE: invalid reg type");
-    }
-
-    /* set the register offset into the index int[] */
-    indexes[seen_arrow][index] = reg_offset;
-
-    /* set the PARROT_ARG_FLAGS into the signature FIA */
-    VTABLE_set_integer_keyed_int(interp, sigs[seen_arrow], index, cur);
-
-    /* perform the arg accessor function, assigning the arg to its
-     * corresponding register */
-    if (!seen_arrow) {
-        switch (cur & PARROT_ARG_TYPE_MASK) {
-            case PARROT_ARG_INTVAL:
-                CTX_REG_INT(ctx, reg_offset) = va_arg(*list, INTVAL);   break;
-            case PARROT_ARG_FLOATVAL:
-                CTX_REG_NUM(ctx, reg_offset) = va_arg(*list, FLOATVAL); break;
-            case PARROT_ARG_STRING:
-                CTX_REG_STR(ctx, reg_offset) = va_arg(*list, STRING *); break;
-            case PARROT_ARG_PMC:
-                CTX_REG_PMC(ctx, reg_offset) = va_arg(*list, PMC *);    break;
-            default:
-                Parrot_ex_throw_from_c_args(interp, NULL,
-                    EXCEPTION_INVALID_OPERATION,
-                    "Parrot_PCCINVOKE: invalid reg type");
-        }
-    }
-}
-
 /*
 
 =item C<static Parrot_Context * count_signature_elements>
@@ -2188,68 +2123,6 @@
     Parrot_pop_context(interp);
 }
 
-/*
-
-=item C<static void set_context_sig_returns_varargs>
-
-Sets the subroutine return arguments in the context C<ctx>. Takes a C string
-for the return signature C<ret_x> and a varargs list of return parameters 
C<returns>.
-
-To unify this function with C<set_context_sig_returns>, C<Parrot_PCCINVOKE>
-needs to be changed to convert the va_list of input arguments into a signature
-object, and the results list from that object needs to be passed to this
-function instead of the va_list itself.
-
-=cut
-
-*/
-
-static void
-set_context_sig_returns_varargs(PARROT_INTERP, ARGMOD(Parrot_Context *ctx),
-    ARGMOD(opcode_t **indexes), ARGIN(const char *ret_x), ARGMOD(va_list 
returns))
-{
-    unsigned int index = 0;
-    unsigned int seen_arrow = 1;
-    const char *x;
-
-    /* result_accessors perform the arg accessor function,
-     * assigning the corresponding registers to the result variables */
-    for (x = ret_x; x && *x; x++) {
-        if (isupper((unsigned char)*x)) {
-            switch (*x) {
-                case 'I':
-                    {
-                    INTVAL * const tmpINTVAL = va_arg(returns, INTVAL*);
-                    *tmpINTVAL = CTX_REG_INT(ctx, indexes[seen_arrow][index]);
-                    }
-                    break;
-                case 'N':
-                    {
-                    FLOATVAL * const tmpFLOATVAL = va_arg(returns, FLOATVAL*);
-                    *tmpFLOATVAL = CTX_REG_NUM(ctx, 
indexes[seen_arrow][index]);
-                    }
-                    break;
-                case 'S':
-                    {
-                    STRING ** const tmpSTRING = va_arg(returns, STRING**);
-                    *tmpSTRING = CTX_REG_STR(ctx, indexes[seen_arrow][index]);
-                    }
-                    break;
-                case 'P':
-                    {
-                    PMC ** const tmpPMC = va_arg(returns, PMC**);
-                    *tmpPMC = CTX_REG_PMC(ctx, indexes[seen_arrow][index]);
-                    }
-                    break;
-                default:
-                    Parrot_ex_throw_from_c_args(interp, NULL,
-                        EXCEPTION_INVALID_OPERATION,
-                        "Parrot_PCCINVOKE: invalid reg type %c!", *x);
-            }
-        }
-    }
-    Parrot_pop_context(interp);
-}
 
 /*
 
@@ -2398,43 +2271,6 @@
 by the OUT results variables.  You must pass the address_of(&) the OUT
 results, of course.
 
-Signatures:
-  uppercase letters repesent each arg and denote its types
-
-  I INTVAL
-  N FLOATVAL
-  S STRING *
-  P PMC *
-
-  lowercase letters are adverb modifiers to the preceeding uppercase arg
-  identifier
-
-  f flatten
-  n named
-  s slurpy
-  o optional
-  p opt flag
-
-  -> is the separator between args and results, similar to type theory
-  notation.
-
-  Named args require two arg slots. The first is the name, the second the arg.
-
-Example signature:
-
-  "SnIPf->INPs"
-
-  The args to the method invocation are
-    a named INTVAL:  SnI
-    a flattened PMC:  Pf
-
-  The results of the method invocation are
-    a INTVAL: I
-    a FLOATVAL: N
-    a slurpy PMC: Ps
-
-invokes a PMC method
-
 =cut
 
 */
@@ -2444,8 +2280,6 @@
 Parrot_PCCINVOKE(PARROT_INTERP, ARGIN(PMC* pmc), ARGMOD(STRING *method_name),
         ARGIN(const char *signature), ...)
 {
-#define PARROT_PCCINVOKE_UNIFY_FLAG 0
-#if PARROT_PCCINVOKE_UNIFY_FLAG
     PMC *sig_obj;
     PMC *sub_obj;
     va_list args;
@@ -2462,170 +2296,6 @@
     /* Invoke the subroutine object with the given CallSignature object */
     Parrot_pcc_invoke_from_sig_object(interp, sub_obj, sig_obj);
     dod_unregister_pmc(interp, sig_obj);
-#else
-#  define PCC_ARG_MAX 1024
-    /* variables from PCCINVOKE impl in PCCMETHOD.pm */
-    /* args INSP, returns INSP */
-    INTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-
-    /* Each of these is 8K. Do we want 16K on the stack? */
-    opcode_t arg_indexes[PCC_ARG_MAX];
-    opcode_t result_indexes[PCC_ARG_MAX];
-
-    PMC * const args_sig    = pmc_new(interp, enum_class_FixedIntegerArray);
-    PMC * const results_sig = pmc_new(interp, enum_class_FixedIntegerArray);
-    PMC * const ret_cont    = new_ret_continuation_pmc(interp, NULL);
-
-    Parrot_Context *ctx;              /* The newly created context */
-    PMC              *pccinvoke_meth;
-
-    opcode_t         *save_current_args;
-    PMC              *save_args_signature;
-    PMC              *save_current_object;
-
-    /* temporary state vars for building PCC index and PCC signature arrays. */
-
-    /* arg_indexes, result_indexes */
-    opcode_t   *indexes[2];
-
-    /* args_sig, results_sig */
-    PMC        *sigs[2];
-
-    int         seen_arrow = 0;
-
-    const char *x;
-    const char *ret_x = NULL;
-    int         index = -1;
-    int         cur   =  0;
-
-    va_list list;
-    va_start(list, signature);
-
-    indexes[0] = arg_indexes;
-    indexes[1] = result_indexes;
-    sigs[0]    = args_sig;
-    sigs[1]    = results_sig;
-
-    /* account for passing invocant in-band */
-    if (!pmc)
-        Parrot_ex_throw_from_c_args(interp, NULL, 1,
-            "NULL PMC passed into Parrot_PCCINVOKE");
-
-    ctx = count_signature_elements(interp, signature, args_sig, results_sig, 
1);
-
-    /* second loop through signature to build all index and arg_flag
-     * loop also assigns args(up to the ->) to registers */
-
-    /* account for passing invocant in-band */
-    indexes[0][0] = 0;
-
-    VTABLE_set_integer_keyed_int(interp, sigs[0], 0, PARROT_ARG_PMC);
-    CTX_REG_PMC(ctx, 0) = pmc;
-
-    n_regs_used[REGNO_PMC]++;
-    index = 0;
-
-    for (x = signature; *x != '\0'; x++) {
-        /* detect -> separator */
-        if (*x == '-') {
-
-            /* skip '>' */
-            x++;
-
-            /* allows us to jump directly to the result signature portion
-             * during results assignment */
-            ret_x = x;
-
-            /* save off pointer to results */
-            ret_x++;
-
-            if (index >= 0)
-                commit_last_arg(interp, index, cur, n_regs_used, seen_arrow,
-                    sigs, indexes, ctx, pmc, &list);
-
-            /* reset parsing state so we can now handle results */
-            seen_arrow =  1;
-            index      = -1;
-
-            /* reset n_regs_used for reuse during result index allocation */
-            n_regs_used[0] = 0;
-            n_regs_used[1] = 0;
-            n_regs_used[2] = 0;
-            n_regs_used[3] = 0;
-        }
-        /* parse arg type */
-        else if (isupper((unsigned char)*x)) {
-            if (index >= 0)
-                commit_last_arg(interp, index, cur, n_regs_used, seen_arrow,
-                    sigs, indexes, ctx, pmc, &list);
-
-            index++;
-
-            switch (*x) {
-                case 'I': cur = PARROT_ARG_INTVAL;   break;
-                case 'N': cur = PARROT_ARG_FLOATVAL; break;
-                case 'S': cur = PARROT_ARG_STRING;   break;
-                case 'P': cur = PARROT_ARG_PMC;      break;
-                default:
-                  Parrot_ex_throw_from_c_args(interp, NULL,
-                    EXCEPTION_INVALID_OPERATION,
-                    "Parrot_PCCINVOKE: invalid reg type %c!", *x);
-            }
-
-        }
-        /* parse arg adverbs */
-        else if (islower((unsigned char)*x)) {
-            switch (*x) {
-                case 'n': cur |= PARROT_ARG_NAME;         break;
-                case 'f': cur |= PARROT_ARG_FLATTEN;      break;
-                case 's': cur |= PARROT_ARG_SLURPY_ARRAY; break;
-                case 'o': cur |= PARROT_ARG_OPTIONAL;     break;
-                case 'p': cur |= PARROT_ARG_OPT_FLAG;     break;
-                default:
-                    Parrot_ex_throw_from_c_args(interp, NULL,
-                        EXCEPTION_INVALID_OPERATION,
-                        "Parrot_PCCINVOKE: invalid adverb type %c!", *x);
-            }
-        }
-    }
-
-    if (index >= 0)
-        commit_last_arg(interp, index, cur, n_regs_used, seen_arrow, sigs,
-            indexes, ctx, pmc, &list);
-
-    /* code from PCCINVOKE impl in PCCMETHOD.pm */
-    save_current_args      = interp->current_args;
-    save_args_signature    = interp->args_signature;
-    save_current_object    = interp->current_object;
-
-    interp->current_args   = arg_indexes;
-    interp->args_signature = args_sig;
-    ctx->current_results   = result_indexes;
-    ctx->results_signature = results_sig;
-
-    /* arg_accessors assigned in loop above */
-
-    interp->current_object       = pmc;
-    interp->current_cont         = NEED_CONTINUATION;
-    ctx->current_cont            = ret_cont;
-    PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
-    pccinvoke_meth               = VTABLE_find_method(interp, pmc, 
method_name);
-
-    if (PMC_IS_NULL(pccinvoke_meth))
-        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_METH_NOT_FOUND,
-            "Method '%Ss' not found", method_name);
-    else
-        VTABLE_invoke(interp, pccinvoke_meth, NULL);
-
-    set_context_sig_returns_varargs(interp, ctx, indexes, ret_x, list);
-    PObj_live_CLEAR(args_sig);
-    PObj_live_CLEAR(results_sig);
-    interp->current_args   = save_current_args;
-    interp->args_signature = save_args_signature;
-    interp->current_object = save_current_object;
-    va_end(list);
-#endif
-#undef PARROT_PCCINVOKE_UNIFY_FLAG
 }
 
 /*

Modified: branches/call_conv_redux/src/multidispatch.c
==============================================================================
--- branches/call_conv_redux/src/multidispatch.c        (original)
+++ branches/call_conv_redux/src/multidispatch.c        Sun Nov 30 14:25:55 2008
@@ -404,13 +404,14 @@
 
 =item C<PMC* Parrot_build_sig_object_from_varargs>
 
-Take a varargs list, and convert it into a CallSignature PMC. The CallSignature
-stores the original short signature string, and an array of integer types to
-pass on to the multiple dispatch search.
+Take a varargs list, and convert it into a CallSignature PMC. The
+CallSignature stores the original short signature string, and an array of
+integer types to pass on to the multiple dispatch search.
 
 =cut
 
 */
+
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
@@ -422,7 +423,6 @@
     INTVAL in_return_sig     = 0;
     PMC    *returns          = PMCNULL;
     PMC    *call_object      = pmc_new(interp, enum_class_CallSignature);
-    PMC    *type_tuple =  PMCNULL; // = pmc_new(interp, 
enum_class_FixedIntegerArray);
     INTVAL  sig_len          = strlen(sig);
     STRING *s_sig            = string_from_cstring(interp, sig, sig_len);
     STRING *string_sig       = NULL;
@@ -437,17 +437,11 @@
     if (PMC_IS_NULL(obj))
         string_sig = s_sig;
     else {
-        /* Should verify here that the signature doesn't already have
-           "Pi" at the beginning, some callers might have added this
-           already. */
         STRING *invocant_sig = CONST_STRING(interp, "Pi");
         string_sig = string_concat(interp, invocant_sig, s_sig, 0);
         sig_len = sig_len + 2;
     }
 
-    //VTABLE_set_integer_native(interp, type_tuple, sig_len);
-    //VTABLE_set_pmc(interp, call_object, type_tuple);
-
     VTABLE_set_string_native(interp, call_object, string_sig);
 
     for (i = 0; i < sig_len; ++i) {
@@ -535,12 +529,15 @@
             }
         }
     }
-
-    type_tuple = Parrot_mmd_build_type_tuple_from_sig_obj(interp, call_object);
-    VTABLE_set_pmc(interp, call_object, type_tuple);
+    {
+        PMC *type_tuple = PMCNULL;
+        type_tuple = Parrot_mmd_build_type_tuple_from_sig_obj(interp, 
call_object);
+        VTABLE_set_pmc(interp, call_object, type_tuple);
+    }
     return call_object;
 }
 
+
 /*
 
 =item C<void Parrot_mmd_multi_dispatch_from_c_args>

Reply via email to