[svn:parrot] r44741 - branches/pcc_hackathon_6Mar10/src/call
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sun Mar 7 16:50:55 UTC 2010
Author: whiteknight
Date: Sun Mar 7 16:50:50 2010
New Revision: 44741
URL: https://trac.parrot.org/parrot/changeset/44741
Log:
slight refactor of Parrot_pcc_build_call_from_varargs to handle implied invocant. infinite exception loop replaced by single non-looping exception.
Modified:
branches/pcc_hackathon_6Mar10/src/call/args.c
branches/pcc_hackathon_6Mar10/src/call/pcc.c
Modified: branches/pcc_hackathon_6Mar10/src/call/args.c
==============================================================================
--- branches/pcc_hackathon_6Mar10/src/call/args.c Sun Mar 7 15:23:29 2010 (r44740)
+++ branches/pcc_hackathon_6Mar10/src/call/args.c Sun Mar 7 16:50:50 2010 (r44741)
@@ -753,24 +753,21 @@
PMC * arg_flags = PMCNULL;
PMC * ignored_flags = PMCNULL;
PMC * const call_object = Parrot_pmc_new(interp, enum_class_CallContext);
- const INTVAL sig_len = strlen(sig);
+ INTVAL sig_len = strlen(sig);
INTVAL in_return_sig = 0;
INTVAL i;
int append_pi = 1;
+ const INTVAL has_invocant = !PMC_IS_NULL(obj);
- if (sig_len) {
- parse_signature_string(interp, sig, &arg_flags);
- VTABLE_set_attr_str(interp, call_object, CONST_STRING(interp, "arg_flags"), arg_flags);
- }
+ parse_signature_string(interp, sig, &arg_flags);
+ if (has_invocant && (sig[0] != 'P' || sig[1] != 'i'))
+ VTABLE_unshift_integer(interp, arg_flags, PARROT_ARG_PMC | PARROT_ARG_INVOCANT);
+ VTABLE_set_attr_str(interp, call_object, CONST_STRING(interp, "arg_flags"), arg_flags);
/* Process the varargs list */
for (i = 0; i < sig_len; ++i) {
const INTVAL type = sig[i];
- /* Don't process returns */
- if (in_return_sig)
- break;
-
/* Regular arguments just set the value */
switch (type) {
case 'I':
@@ -787,20 +784,19 @@
const INTVAL type_lookahead = sig[i+1];
PMC * const pmc_arg = va_arg(*args, PMC *);
if (type_lookahead == 'f') {
- dissect_aggregate_arg(interp, call_object, pmc_arg);
+ dissect_aggregate_arg(interp, call_object, pmc_arg);
i++; /* skip 'f' */
}
- else {
- VTABLE_push_pmc(interp, call_object, clone_key_arg(interp, pmc_arg));
- if (type_lookahead == 'i') {
- if (i != 0)
- Parrot_ex_throw_from_c_args(interp, NULL,
- EXCEPTION_INVALID_OPERATION,
- "Dispatch: only the first argument can be an invocant");
- i++; /* skip 'i' */
- append_pi = 0; /* Don't append Pi in front of signature */
- }
+ else if (type_lookahead == 'i') {
+ if (i != 0)
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_INVALID_OPERATION,
+ "Dispatch: only the first argument can be an invocant");
+ i++; /* skip 'i' */
+ VTABLE_push_pmc(interp, call_object, obj);
}
+ else
+ VTABLE_push_pmc(interp, call_object, clone_key_arg(interp, pmc_arg));
break;
}
case '-':
@@ -813,10 +809,6 @@
}
}
- /* Check if we have an invocant, and add it to the front of the arguments iff needed */
- if (!PMC_IS_NULL(obj) && append_pi)
- VTABLE_unshift_pmc(interp, call_object, obj);
-
return call_object;
}
Modified: branches/pcc_hackathon_6Mar10/src/call/pcc.c
==============================================================================
--- branches/pcc_hackathon_6Mar10/src/call/pcc.c Sun Mar 7 15:23:29 2010 (r44740)
+++ branches/pcc_hackathon_6Mar10/src/call/pcc.c Sun Mar 7 16:50:50 2010 (r44741)
@@ -193,8 +193,7 @@
Parrot_pcc_split_signature_string(interp, signature, &arg_sig, &ret_sig);
va_start(args, signature);
- call_obj = Parrot_pcc_build_call_from_varargs(interp, pmc,
- arg_sig, &args);
+ call_obj = Parrot_pcc_build_call_from_varargs(interp, pmc, arg_sig, &args);
/* Find the subroutine object as a named method on pmc */
sub_obj = VTABLE_find_method(interp, pmc, method_name);
More information about the parrot-commits
mailing list