Author: leo
Date: Wed Jan 18 05:28:34 2006
New Revision: 11240
Modified:
trunk/include/parrot/inter_call.h
trunk/t/op/calling.t
Log:
Calling conventions 4 - extend call_state
* stub in some more variables for param count check and named
* add TODO test for param count check
Modified: trunk/include/parrot/inter_call.h
==============================================================================
--- trunk/include/parrot/inter_call.h (original)
+++ trunk/include/parrot/inter_call.h Wed Jan 18 05:28:34 2006
@@ -20,6 +20,8 @@ enum call_state_mode {
CALL_STATE_MASK = 0x003,
CALL_STATE_FLATTEN = 0x010,
+ CALL_STATE_NAMED = 0x020,
+ CALL_STATE_NAMED_FLATTEN = 0x040,
CALL_STATE_NEXT_ARG = 0x100
};
@@ -49,8 +51,13 @@ struct call_state {
struct call_state_1 src;
struct call_state_1 dest;
UnionVal val;
- int opt_so_far;
- int n_actual_args;
+ int opt_so_far; /* opt_flag handling */
+ int n_actual_args; /* arguments incl. flatten */
+ int optionals; /* sum of optionals */
+ int params; /* sum of params */
+ int first_named; /* param idx of 1st named */
+ UINTVAL named_done; /* bit mask, 1 if named was assigned */
+ STRING *name; /* name of argument if any */
};
PARROT_API int Parrot_init_arg_sig(Interp *, parrot_context_t *ctx,
Modified: trunk/t/op/calling.t
==============================================================================
--- trunk/t/op/calling.t (original)
+++ trunk/t/op/calling.t Wed Jan 18 05:28:34 2006
@@ -564,6 +564,30 @@ hello
ok
OUTPUT
+pir_output_like(<<'CODE', <<'OUTPUT', "argc mismatch, optional", todo=>'wrong
counts');
+.sub main :main
+ .include "errors.pasm"
+ errorson .PARROT_ERRORS_PARAM_COUNT_FLAG
+ .local pmc ar
+ ar = new ResizableIntegerArray
+ push ar, 1
+ push ar, 2
+ push ar, 3
+ push ar, 4
+ foo(ar :flat)
+ print "never\n"
+.end
+.sub foo
+ .param int i
+ .param int j :optional
+ .param int got_j :opt_flag
+ .param int k :optional
+ .param int got_k :opt_flag
+.end
+CODE
+/too many arguments passed/
+OUTPUT
+
output_is(<<'CODE', <<'OUTPUT', "get_param later");
.pcc_sub main:
set I16, 77
@@ -1603,5 +1627,5 @@ OUTPUT
## remember to change the number of tests :-)
-BEGIN { plan tests => 59; }
+BEGIN { plan tests => 60; }