Skip to content

Commit

Permalink
[pcc] Replaced VTABLE access to number of args/params with macro use.
Browse files Browse the repository at this point in the history
Delayed error checking until absolutely necessary.

git-svn-id: https://svn.parrot.org/parrot/trunk@44038 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed Feb 16, 2010
1 parent b75b38d commit 355095f
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions src/call/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,15 +1000,17 @@ fill_params(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
ARGIN(PMC *raw_sig), ARGIN(void *arg_info), ARGIN(struct pcc_set_funcs *accessor))
{
ASSERT_ARGS(fill_params)
PMC *named_used_list = PMCNULL;
INTVAL *raw_params;
const INTVAL param_count = VTABLE_elements(interp, raw_sig);
PMC *named_used_list = PMCNULL;
INTVAL param_count = 0;
INTVAL param_index = 0;
INTVAL arg_index = 0;
INTVAL named_count = 0;
INTVAL err_check = 0;
INTVAL positional_args;

GETATTR_FixedIntegerArray_size(interp, raw_sig, param_count);

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (PARROT_ERRORS_test(interp, PARROT_ERRORS_PARAM_COUNT_FLAG))
Expand Down Expand Up @@ -1610,7 +1612,7 @@ fill_results(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
if (PMC_IS_NULL(call_object)) {
/* If the return_count is 0, then there are no return values waiting to
* fill the results, so no error. */
if (return_count > 0 && (err_check))
if (return_count > 0 && err_check)
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"too few returns: 0 passed, %d expected", return_count);
Expand Down Expand Up @@ -2104,8 +2106,7 @@ Parrot_pcc_fill_returns_from_op(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
ARGIN(PMC *raw_sig), ARGIN(opcode_t *raw_returns))
{
ASSERT_ARGS(Parrot_pcc_fill_returns_from_op)
const INTVAL raw_return_count = VTABLE_elements(interp, raw_sig);
INTVAL err_check = 0;

static pcc_get_funcs function_pointers = {
(intval_func_t)intval_arg_from_op,
(numval_func_t)numval_arg_from_op,
Expand All @@ -2118,27 +2119,30 @@ Parrot_pcc_fill_returns_from_op(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_object),
(pmc_func_t)pmc_constant_from_op,
};

INTVAL raw_return_count = 0;

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
err_check = 1;
GETATTR_FixedIntegerArray_size(interp, raw_sig, raw_return_count);

/* A null call object is fine if there are no arguments and no returns. */
if (PMC_IS_NULL(call_object)) {
if (raw_return_count > 0) {
if (err_check)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"too many return values: %d passed, 0 expected",
raw_return_count);
}

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (raw_return_count > 0
&& PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"too many return values: %d passed, 0 expected",
raw_return_count);
return;
}

fill_results(interp, call_object, raw_sig, raw_returns, &function_pointers);

return;
}


/*
=item C<void Parrot_pcc_fill_returns_from_continuation(PARROT_INTERP, PMC
Expand All @@ -2158,7 +2162,7 @@ Parrot_pcc_fill_returns_from_continuation(PARROT_INTERP, ARGMOD_NULLOK(PMC *call
{
ASSERT_ARGS(Parrot_pcc_fill_returns_from_continuation)
const INTVAL raw_return_count = VTABLE_elements(interp, raw_sig);
INTVAL err_check = 0;

static pcc_get_funcs function_pointers = {
(intval_func_t)intval_arg_from_continuation,
(numval_func_t)numval_arg_from_continuation,
Expand All @@ -2171,20 +2175,17 @@ Parrot_pcc_fill_returns_from_continuation(PARROT_INTERP, ARGMOD_NULLOK(PMC *call
(pmc_func_t)pmc_arg_from_continuation,
};


/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
err_check = 1;

/* A null call object is fine if there are no arguments and no returns. */
if (PMC_IS_NULL(call_object)) {
if (raw_return_count > 0) {
if (err_check)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"too many return values: %d passed, 0 expected",
raw_return_count);
}

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (raw_return_count > 0
&& PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"too many return values: %d passed, 0 expected",
raw_return_count);
return;
}

Expand All @@ -2193,6 +2194,7 @@ Parrot_pcc_fill_returns_from_continuation(PARROT_INTERP, ARGMOD_NULLOK(PMC *call
return;
}


/*
=item C<void Parrot_pcc_fill_returns_from_c_args(PARROT_INTERP, PMC
Expand All @@ -2219,7 +2221,6 @@ Parrot_pcc_fill_returns_from_c_args(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_objec
ASSERT_ARGS(Parrot_pcc_fill_returns_from_c_args)
va_list args;
INTVAL raw_return_count = 0;
INTVAL err_check = 0;
PMC *raw_sig = PMCNULL;
PMC *invalid_sig = PMCNULL;

Expand All @@ -2236,21 +2237,20 @@ Parrot_pcc_fill_returns_from_c_args(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_objec
};

parse_signature_string(interp, signature, &raw_sig, &invalid_sig);

if (!PMC_IS_NULL(invalid_sig))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"parameters should not be included in the return signature");

raw_return_count = VTABLE_elements(interp, raw_sig);

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
err_check = 1;

/* A null call object is fine if there are no arguments and no returns. */
if (PMC_IS_NULL(call_object)) {
if (raw_return_count > 0)
if (err_check)

/* Check if we should be throwing errors. This is configured separately
* for parameters and return values. */
if (raw_return_count > 0
&& PARROT_ERRORS_test(interp, PARROT_ERRORS_RESULT_COUNT_FLAG))
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"too many return values: %d passed, 0 expected",
Expand All @@ -2263,6 +2263,7 @@ Parrot_pcc_fill_returns_from_c_args(PARROT_INTERP, ARGMOD_NULLOK(PMC *call_objec
va_end(args);
}


/*
=item C<static void parse_signature_string(PARROT_INTERP, const char *signature,
Expand Down

0 comments on commit 355095f

Please sign in to comment.