Permalink
Browse files

[pmc] update *IntegerArray to use ATTRs

git-svn-id: https://svn.parrot.org/parrot/trunk@36053 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent e827b7b commit e5dead2ed00fdcfc383ad82fe92c74636f8f2a45 @cotto cotto committed Jan 27, 2009
View
@@ -1388,7 +1388,7 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
break;
case PFC_STRING:
ns_pmc = constant_pmc_new(interp, enum_class_String);
- PMC_str_val(ns_pmc) = ct->constants[ns_const]->u.string;
+ VTABLE_set_string_native(interp, ns_pmc, ct->constants[ns_const]->u.string);
break;
default:
break;
@@ -363,7 +363,7 @@ STRING* set_retval_s(PARROT_INTERP, int sig_ret, ARGIN(Parrot_Context *ctx))
*(pc) == PARROT_OP_get_params_pc || \
*(pc) == PARROT_OP_set_returns_pc) { \
PMC * const sig = (seg)->const_table->constants[(pc)[1]]->u.key; \
- (n) += SIG_ELEMS(sig); \
+ (n) += VTABLE_elements((interp), sig); \
} \
} while (0)
@@ -131,7 +131,7 @@ get_args(PARROT_INTERP)
++args_op;
sig = constants[*args_op]->u.key;
ASSERT_SIG_PMC(sig);
- sig_len = SIG_ELEMS(sig);
+ sig_len = VTABLE_elements(interp, sig);
/* If we have a zero-length signature, we're done. */
if (sig_len == 0)
@@ -140,7 +140,7 @@ get_args(PARROT_INTERP)
/* Otherwise, we have arguments. */
++args_op;
for (i = 0; i < sig_len; ++i, ++args_op) {
- const INTVAL type = SIG_ITEM(sig, i);
+ const INTVAL type = VTABLE_get_integer_keyed_int(interp, sig, i);
const int idx = *args_op;
/* If we find a named argument, then we know there's no more positional
View
@@ -22,13 +22,14 @@ subroutines.
#include "parrot/parrot.h"
#include "parrot/oplib/ops.h"
#include "inter_call.str"
+#include "pmc/pmc_fixedintegerarray.h"
/* HEADERIZER HFILE: include/parrot/inter_call.h */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void check_for_opt_flag(ARGMOD(call_state *st), int has_arg)
+static void check_for_opt_flag(PARROT_INTERP, ARGMOD(call_state *st), int has_arg)
__attribute__nonnull__(1)
FUNC_MODIFIES(*st);
@@ -138,7 +139,7 @@ static int locate_named_named(PARROT_INTERP, ARGMOD(call_state *st))
__attribute__nonnull__(2)
FUNC_MODIFIES(*st);
-static void next_arg_sig(ARGMOD(call_state_item *sti))
+static void next_arg_sig(PARROT_INTERP, ARGMOD(call_state_item *sti))
__attribute__nonnull__(1)
FUNC_MODIFIES(*sti);
@@ -429,7 +430,7 @@ These functions return 0 if no arguments are present, or 1 on success.
PARROT_EXPORT
int
-Parrot_init_arg_indexes_and_sig_pmc(SHIM_INTERP, ARGIN(Parrot_Context *ctx),
+Parrot_init_arg_indexes_and_sig_pmc(PARROT_INTERP, ARGIN(Parrot_Context *ctx),
ARGIN_NULLOK(opcode_t *indexes), ARGIN_NULLOK(PMC *sig_pmc),
ARGMOD(call_state_item *sti))
{
@@ -453,11 +454,11 @@ Parrot_init_arg_indexes_and_sig_pmc(SHIM_INTERP, ARGIN(Parrot_Context *ctx),
ASSERT_SIG_PMC(sig_pmc);
sti->u.op.signature = sig_pmc;
sti->u.op.pc = indexes;
- sti->n = SIG_ELEMS(sig_pmc);
+ sti->n = VTABLE_elements(interp, sig_pmc);
/* initialize sti->sig */
if (sti->n)
- next_arg_sig(sti);
+ next_arg_sig(interp, sti);
}
return sti->n > 0;
@@ -507,7 +508,7 @@ const_table), registers, function signature, and arguments.
PARROT_EXPORT
int
-Parrot_init_arg_sig(SHIM_INTERP, ARGIN(Parrot_Context *ctx),
+Parrot_init_arg_sig(PARROT_INTERP, ARGIN(Parrot_Context *ctx),
ARGIN(const char *sig), ARGIN_NULLOK(void *ap),
ARGMOD(call_state_item *sti))
{
@@ -526,7 +527,7 @@ Parrot_init_arg_sig(SHIM_INTERP, ARGIN(Parrot_Context *ctx),
/* initialize st->sig */
if (sti->n)
- next_arg_sig(sti);
+ next_arg_sig(interp, sti);
}
return sti->n > 0;
@@ -589,12 +590,13 @@ type of argument/parameter to get next. The index gets increased elsewhere.
*/
static void
-next_arg_sig(ARGMOD(call_state_item *sti))
+next_arg_sig(PARROT_INTERP, ARGMOD(call_state_item *sti))
{
ASSERT_ARGS(next_arg_sig)
switch (sti->mode & CALL_S_D_MASK) {
case CALL_STATE_OP:
- sti->sig = SIG_ITEM(sti->u.op.signature, sti->i);
+ sti->sig = VTABLE_get_integer_keyed_int(interp,
+ sti->u.op.signature, sti->i);
break;
case CALL_STATE_SIG:
switch (sti->u.sig.sig[sti->i]) {
@@ -770,7 +772,7 @@ Parrot_fetch_arg(PARROT_INTERP, ARGMOD(call_state *st))
st->src.used = 0;
- next_arg_sig(&st->src);
+ next_arg_sig(interp, &st->src);
/* check if we're supposed to continue a :flat argument */
if (st->src.mode & CALL_STATE_FLATTEN) {
@@ -807,7 +809,7 @@ Parrot_fetch_arg(PARROT_INTERP, ARGMOD(call_state *st))
&& !(st->src.sig & PARROT_ARG_FLATTEN)) {
fetch_arg_op(interp, st);
st->name = UVal_str(st->val);
- next_arg_sig(&st->src);
+ next_arg_sig(interp, &st->src);
}
switch (st->src.mode & CALL_S_D_MASK) {
@@ -839,7 +841,7 @@ int
Parrot_fetch_arg_nci(PARROT_INTERP, ARGMOD(call_state *st))
{
ASSERT_ARGS(Parrot_fetch_arg_nci)
- next_arg_sig(&st->dest);
+ next_arg_sig(interp, &st->dest);
if (st->dest.sig & PARROT_ARG_SLURPY_ARRAY) {
PMC *slurped = pmc_new(interp,
@@ -1013,7 +1015,7 @@ Otherwise moves on.
*/
static void
-check_for_opt_flag(ARGMOD(call_state *st), int has_arg)
+check_for_opt_flag(PARROT_INTERP, ARGMOD(call_state *st), int has_arg)
{
ASSERT_ARGS(check_for_opt_flag)
INTVAL idx;
@@ -1026,7 +1028,7 @@ check_for_opt_flag(ARGMOD(call_state *st), int has_arg)
if (dest->i >= dest->n)
return;
- next_arg_sig(dest);
+ next_arg_sig(interp, dest);
/* if this isn't an :opt_flag argument, we need to reset things
* and go to the next argument */
@@ -1113,7 +1115,8 @@ init_first_dest_named(PARROT_INTERP, ARGMOD(call_state *st))
/* 1) count named args, make sure there is less than 32/64
* 2) create slurpy hash if needed */
for (i = st->dest.i; i < st->dest.n; ++i) {
- const INTVAL sig = SIG_ITEM(st->dest.u.op.signature, i);
+ const INTVAL sig = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i);
/* skip the arg name, only count the actual args of the named args */
if (!(sig & PARROT_ARG_NAME))
@@ -1168,7 +1171,8 @@ locate_named_named(PARROT_INTERP, ARGMOD(call_state *st))
int idx;
STRING *param;
- st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i);
+ st->dest.sig = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i);
if (!(st->dest.sig & PARROT_ARG_NAME))
continue;
@@ -1183,7 +1187,8 @@ locate_named_named(PARROT_INTERP, ARGMOD(call_state *st))
if (st->name == param || string_equal(interp, st->name, param) == 0) {
++i;
- st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i);
+ st->dest.sig = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i);
st->dest.i = i;
/* if bit is set we have a duplicate */
@@ -1371,7 +1376,8 @@ check_named(PARROT_INTERP, ARGMOD(call_state *st))
for (i = st->first_named; i < st->dest.n; ++i) {
/* verify that a name exists */
- const INTVAL sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i);
+ const INTVAL sig = st->dest.sig =
+ VTABLE_get_integer_keyed_int(interp, st->dest.u.op.signature, i);
if (sig & PARROT_ARG_NAME) {
INTVAL arg_sig;
int last_name_pos;
@@ -1387,12 +1393,17 @@ check_named(PARROT_INTERP, ARGMOD(call_state *st))
i++;
/* verify that an actual arg exists */
- arg_sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i);
+ arg_sig = st->dest.sig = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i);
PARROT_ASSERT(!(arg_sig & PARROT_ARG_NAME));
/* if this named arg is already filled, continue */
if (st->named_done & (1 << n_named)) {
- arg_sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i+1);
+ /* XXX: This reads past the end of the array. TT #233*/
+ INTVAL* int_array;
+ GETATTR_FixedIntegerArray_int_array(interp,
+ st->dest.u.op.signature, int_array);
+ arg_sig = st->dest.sig = int_array[i+1];
/* skip associated opt flag arg as well */
if (arg_sig & PARROT_ARG_OPT_FLAG)
@@ -1409,7 +1420,8 @@ check_named(PARROT_INTERP, ARGMOD(call_state *st))
/* Don't walk off the end of the array */
if (i+1 >= st->dest.n)
continue;
- arg_sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i+1);
+ arg_sig = st->dest.sig = VTABLE_get_integer_keyed_int(interp,
+ st->dest.u.op.signature, i+1);
if (arg_sig & PARROT_ARG_OPT_FLAG) {
i++;
idx = st->dest.u.op.pc[i];
@@ -1505,7 +1517,7 @@ Parrot_process_args(PARROT_INTERP, ARGMOD(call_state *st), arg_pass_t param_or_r
int has_arg;
/* check if the next dest arg is :slurpy */
- next_arg_sig(dest);
+ next_arg_sig(interp, dest);
if (dest->sig & PARROT_ARG_SLURPY_ARRAY)
break;
@@ -1534,11 +1546,11 @@ Parrot_process_args(PARROT_INTERP, ARGMOD(call_state *st), arg_pass_t param_or_r
PARROT_ASSERT(idx >= 0);
store_arg(st, idx);
- check_for_opt_flag(st, 0);
+ check_for_opt_flag(interp, st, 0);
/* next dest arg */
dest->i++;
- next_arg_sig(dest);
+ next_arg_sig(interp, dest);
}
/* Restore value */
@@ -1553,7 +1565,7 @@ Parrot_process_args(PARROT_INTERP, ARGMOD(call_state *st), arg_pass_t param_or_r
if (!has_arg)
break;
dest->i++;
- next_arg_sig(dest);
+ next_arg_sig(interp, dest);
}
/* if there *is* an arg, convert it */
@@ -1581,7 +1593,7 @@ Parrot_process_args(PARROT_INTERP, ARGMOD(call_state *st), arg_pass_t param_or_r
/* if we're at an :optional argument, check for an :opt_flag */
if (dest->sig & PARROT_ARG_OPTIONAL)
- check_for_opt_flag(st, has_arg);
+ check_for_opt_flag(interp, st, has_arg);
}
/* 2nd: Positional :slurpy */
@@ -1653,7 +1665,7 @@ Parrot_process_args(PARROT_INTERP, ARGMOD(call_state *st), arg_pass_t param_or_r
/* if we're at an :optional argument, check for an :opt_flag */
if (dest->sig & PARROT_ARG_OPTIONAL)
- check_for_opt_flag(st, 1);
+ check_for_opt_flag(interp, st, 1);
}
/* otherwise this doesn't get reset and we can't catch positional args
View
@@ -593,14 +593,14 @@ Parrot_mmd_arg_tuple_func(PARROT_INTERP)
ASSERT_SIG_PMC(args_array);
- sig_len = SIG_ELEMS(args_array);
+ sig_len = VTABLE_elements(interp, args_array);
if (!sig_len)
return arg_tuple;
++args_op;
for (i = 0; i < sig_len; ++i, ++args_op) {
- type = SIG_ITEM(args_array, i);
+ type = VTABLE_get_integer_keyed_int(interp, args_array, i);
/* named don't MMD */
if (type & PARROT_ARG_NAME)
View
@@ -564,7 +564,7 @@ op set_args(inconst PMC) :flow {
/* for now just point to the opcode */
interp->current_args = _this;
- argc = SIG_ELEMS(signature);
+ argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
}
@@ -574,7 +574,7 @@ op get_results(inconst PMC) :flow {
INTVAL argc;
CONTEXT(interp)->current_results = _this;
- argc = SIG_ELEMS(signature);
+ argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
}
@@ -608,7 +608,7 @@ op get_params(inconst PMC) :flow {
Parrot_free_context(interp, caller_ctx, 1);
interp->current_args = NULL;
}
- argc = SIG_ELEMS(signature);
+ argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
}
@@ -646,7 +646,7 @@ op set_returns(inconst PMC) :flow {
parrot_pass_args(interp, ctx, ctx->caller_ctx, interp->current_returns,
ctx->caller_ctx->current_results, PARROT_PASS_RESULTS);
}
- argc = SIG_ELEMS(signature);
+ argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
}
View
@@ -762,9 +762,9 @@ pbc_merge_ctpointers(PARROT_INTERP, ARGMOD(pbc_merge_input **inputs),
const PMC * const sig = bc->const_table->constants[op_ptr[1]]->u.key;
/* Loop over the arguments to locate any that need a fixup. */
- const int sig_items = SIG_ELEMS(sig);
+ const int sig_items = VTABLE_elements(interp, sig);
for (cur_arg = 0; cur_arg < sig_items; cur_arg++) {
- switch (SIG_ITEM(sig, cur_arg)) {
+ switch (VTABLE_get_integer_keyed_int(interp, sig, cur_arg)) {
case PARROT_ARG_NC:
case PARROT_ARG_PC:
case PARROT_ARG_SC:
Oops, something went wrong.

0 comments on commit e5dead2

Please sign in to comment.