[svn:parrot] r40717 - in branches/pcc_arg_unify/src: call pmc
tene at svn.parrot.org
tene at svn.parrot.org
Sat Aug 22 17:52:37 UTC 2009
Author: tene
Date: Sat Aug 22 17:52:35 2009
New Revision: 40717
URL: https://trac.parrot.org/parrot/changeset/40717
Log:
[pcc] First draft of support for named params.
Modified:
branches/pcc_arg_unify/src/call/pcc.c
branches/pcc_arg_unify/src/pmc/capture.pmc
Modified: branches/pcc_arg_unify/src/call/pcc.c
==============================================================================
--- branches/pcc_arg_unify/src/call/pcc.c Sat Aug 22 14:49:15 2009 (r40716)
+++ branches/pcc_arg_unify/src/call/pcc.c Sat Aug 22 17:52:35 2009 (r40717)
@@ -458,11 +458,12 @@
else
string_value = CTX_REG_STR(ctx, raw_index);
- if (arg_flags & PARROT_ARG_NAME)
+ if (arg_flags & PARROT_ARG_NAME) {
extract_named_arg_from_op(interp, call_object, string_value,
- raw_sig, raw_args, raw_index);
- else
- VTABLE_push_string(interp, call_object, string_value);
+ raw_sig, raw_args, ++arg_index);
+ }
+
+ VTABLE_push_string(interp, call_object, string_value);
break;
}
@@ -878,7 +879,7 @@
CTX_REG_INT(ctx, raw_index) = got_optional;
got_optional = -1;
- break; /* on to next parameter */
+ continue; /* on to next parameter */
}
/* Collected ("slurpy") parameter */
else if (param_flags & PARROT_ARG_SLURPY_ARRAY) {
@@ -906,7 +907,7 @@
CTX_REG_PMC(ctx, raw_index) = collect_positional;
}
- break; /* on to next parameter */
+ continue; /* on to next parameter */
}
/* Named non-collected */
else if (param_flags & PARROT_ARG_NAME) {
@@ -916,7 +917,7 @@
? ctx->constants[raw_index]->u.string
: CTX_REG_STR(ctx, raw_index);
- break; /* on to next parameter */
+ continue;
}
else if (!STRING_IS_NULL(param_name)) {
/* The previous parameter was a parameter name. Now set the
Modified: branches/pcc_arg_unify/src/pmc/capture.pmc
==============================================================================
--- branches/pcc_arg_unify/src/pmc/capture.pmc Sat Aug 22 14:49:15 2009 (r40716)
+++ branches/pcc_arg_unify/src/pmc/capture.pmc Sat Aug 22 17:52:35 2009 (r40717)
@@ -431,6 +431,90 @@
/*
+=item C<void set_number_keyed_str(STRING *key, FLOATVAL value)>
+
+=item C<void set_integer_keyed_str(STRING *key, INTVAL value)>
+
+=item C<void set_pmc_keyed_str(STRING *key, PMC *value)>
+
+=item C<void set_string_keyed_str(STRING *key, STRING *value)>
+
+Sets a value in the hash component of the Capture.
+
+=cut
+
+*/
+
+ VTABLE void set_number_keyed_str(STRING *key, FLOATVAL value) {
+ CAPTURE_hash_CREATE(INTERP, SELF);
+ VTABLE_set_number_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key, value);
+ }
+
+ VTABLE void set_integer_keyed_str(STRING *key, INTVAL value) {
+ CAPTURE_hash_CREATE(INTERP, SELF);
+ VTABLE_set_integer_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key, value);
+ }
+
+ VTABLE void set_pmc_keyed_str(STRING *key, PMC *value) {
+ CAPTURE_hash_CREATE(INTERP, SELF);
+ VTABLE_set_pmc_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key, value);
+ }
+
+ VTABLE void set_string_keyed_str(STRING *key, STRING *value) {
+ CAPTURE_hash_CREATE(INTERP, SELF);
+ VTABLE_set_string_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key, value);
+ }
+
+/*
+
+=item C<FLOATVAL get_number_keyed_str(STRING *key)>
+
+=item C<INTVAL get_integer_keyed_str(STRING *key)>
+
+=item C<PMC *get_pmc_keyed_str(STRING *key)>
+
+=item C<STRING *get_string_keyed_str(STRING *key)>
+
+Retrieves a value in the hash component of the Capture.
+
+=cut
+
+*/
+
+ VTABLE FLOATVAL get_number_keyed_str(STRING *key) {
+ if (!(PARROT_CAPTURE(SELF)->hash))
+ return 0.0;
+ return VTABLE_get_number_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key);
+ }
+
+ VTABLE INTVAL get_integer_keyed_str(STRING *key) {
+ if (!(PARROT_CAPTURE(SELF)->hash))
+ return 0;
+ return VTABLE_get_integer_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key);
+ }
+
+ VTABLE PMC *get_pmc_keyed_str(STRING *key) {
+ if (!(PARROT_CAPTURE(SELF)->hash))
+ return PMCNULL;
+ return VTABLE_get_pmc_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key);
+ }
+
+ VTABLE STRING *get_string_keyed_str(STRING *key) {
+ if (!(PARROT_CAPTURE(SELF)->hash))
+ return CONST_STRING(INTERP, "");
+ return VTABLE_get_string_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
+ key);
+ }
+
+/*
+
=item C<INTVAL defined_keyed(PMC *key)>
Return true if element C<key> of the hash component is defined.
@@ -464,6 +548,39 @@
/*
+=item C<INTVAL defined_keyed_str(STRING *key)>
+
+Return true if element C<key> of the hash component is defined.
+
+=item C<INTVAL exists_keyed_str(STRING *key)>
+
+Return true if element C<key> of the hash component exists.
+
+=item C<void delete_keyed_str(STRING *key)>
+
+Delete the element corresponding to C<key> in the hash component.
+
+=cut
+
+*/
+
+ VTABLE INTVAL defined_keyed_str(STRING *key) {
+ if (!PARROT_CAPTURE(SELF)->hash) return 0;
+ return VTABLE_defined_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+ }
+
+ VTABLE INTVAL exists_keyed_str(STRING *key) {
+ if (!PARROT_CAPTURE(SELF)->hash) return 0;
+ return VTABLE_exists_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+ }
+
+ VTABLE void delete_keyed_str(STRING *key) {
+ if (PARROT_CAPTURE(SELF)->hash)
+ VTABLE_delete_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+ }
+
+/*
+
=item C<void set_pmc(PMC *capture)>
Set this capture to hold the value of another. If set to PMCNULL,
More information about the parrot-commits
mailing list