[svn:parrot] r41627 - branches/pcc_reapply/src/call
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sat Oct 3 01:49:54 UTC 2009
Author: whiteknight
Date: Sat Oct 3 01:49:52 2009
New Revision: 41627
URL: https://trac.parrot.org/parrot/changeset/41627
Log:
[pcc] move around the logic for handling optionals. Named params can be optional too, but the fill_params_* functions were short circuiting when a named argument was found and were not setting the correspondig opt_flag. This fixes that issue
Modified:
branches/pcc_reapply/src/call/pcc.c
Modified: branches/pcc_reapply/src/call/pcc.c
==============================================================================
--- branches/pcc_reapply/src/call/pcc.c Sat Oct 3 00:40:03 2009 (r41626)
+++ branches/pcc_reapply/src/call/pcc.c Sat Oct 3 01:49:52 2009 (r41627)
@@ -900,6 +900,12 @@
const INTVAL raw_index = raw_params[param_index + 2];
+ /* If it's also optional, set that info */
+ if (param_flags & PARROT_ARG_OPTIONAL) {
+ got_optional = 1;
+ optional_count++;
+ }
+
/* opt_flag parameter */
if (param_flags & PARROT_ARG_OPT_FLAG) {
if (optional_count <= 0)
@@ -956,6 +962,7 @@
else if (!STRING_IS_NULL(param_name)) {
/* The previous parameter was a parameter name. Now set the
* value of the named parameter.*/
+
if (VTABLE_exists_keyed_str(interp, call_object, param_name)) {
named_count++;
@@ -1029,13 +1036,12 @@
continue; /* on to next parameter */
}
- /* Otherwise, we have a positional argument to assign to the
- * positional parameter, so go ahead and assign it. */
- if (param_flags & PARROT_ARG_OPTIONAL) {
- got_optional = 1;
- optional_count++;
- }
+ /* If last argument was an optional, but this arg isn't the
+ corresponding opt_flag, reset the flag. */
+ if (got_optional && !param_flags & PARROT_ARG_OPTIONAL)
+ got_optional = -1;
+ /* It's a (possibly optional) positional. Fill it. */
switch (PARROT_ARG_TYPE_MASK_MASK(param_flags)) {
case PARROT_ARG_INTVAL:
CTX_REG_INT(ctx, raw_index) =
@@ -1141,6 +1147,11 @@
INTVAL param_flags = VTABLE_get_integer_keyed_int(interp,
raw_sig, param_index);
+ if (param_flags & PARROT_ARG_OPTIONAL) {
+ got_optional = 1;
+ optional_count++;
+ }
+
/* opt_flag parameter */
if (param_flags & PARROT_ARG_OPT_FLAG) {
if (optional_count <= 0)
@@ -1302,12 +1313,11 @@
continue; /* on to next parameter */
}
- /* Otherwise, we have a positional argument to assign to the
- * positional parameter, so go ahead and assign it. */
- if (param_flags & PARROT_ARG_OPTIONAL) {
- got_optional = 1;
- optional_count++;
- }
+ /* If the last argument was an optional but this one isn't the
+ corresponding opt_flag, reset the state info because we won't
+ get it. */
+ if (got_optional && !(param_flags & PARROT_ARG_OPTIONAL))
+ got_optional = -1;
switch (PARROT_ARG_TYPE_MASK_MASK(param_flags)) {
case PARROT_ARG_INTVAL:
More information about the parrot-commits
mailing list