Skip to content

Commit

Permalink
Standardize internal exception calls (James deBoer, james at huronbox…
Browse files Browse the repository at this point in the history
… dot com).

See #32769.


git-svn-id: https://svn.parrot.org/parrot/trunk@7282 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed Dec 12, 2004
1 parent 05ac062 commit d185452
Show file tree
Hide file tree
Showing 46 changed files with 168 additions and 144 deletions.
8 changes: 4 additions & 4 deletions classes/array.pmc
Expand Up @@ -50,7 +50,7 @@ static PMC* retval(Interp *interp, void *ret)
{
PMC *value;
if (ret == 0)
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!\n");
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!");
/* XXX getting non existent value, exception or undef?
* current is for perlarray */
if (ret == (void*) -1)
Expand Down Expand Up @@ -135,7 +135,7 @@ Parrot_Array_set_pmc_ptr(Interp *interp, List *list, INTVAL key)
PMC *value;

if (ret == 0)
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!\n");
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!");
/* assign into a sparse or not yet set value */
if (ret == (void*) -1 || *(PMC**)ret == 0) {
value = undef(interp);
Expand Down Expand Up @@ -675,7 +675,7 @@ Sets the PMC at element C<idx> to C<*src>.
INTVAL length;
length = ((List *) PMC_data(SELF))->length;
if (idx >= length || -idx > length) {
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!\n");
internal_exception(OUT_OF_BOUNDS, "Array index out of bounds!");
}

list_assign(INTERP, (List *) PMC_data(SELF), idx,
Expand Down Expand Up @@ -974,7 +974,7 @@ C<offset>.

void splice(PMC* value, INTVAL offset, INTVAL count) {
if (SELF->vtable->base_type != value->vtable->base_type)
internal_exception(1, "Type mismatch in splice\n");
internal_exception(1, "Type mismatch in splice");
list_splice(INTERP, (List*) PMC_data(SELF), value, offset, count);
}

Expand Down
6 changes: 3 additions & 3 deletions classes/complex.pmc
Expand Up @@ -114,7 +114,7 @@ complex_parse_string (Parrot_Interp interp,
if( (*t != 'i' && *t != 'j') || (*(t+1) != 0) ) {
/* imaginary part does not end in 'i' or 'j' */
internal_exception(INVALID_STRING_REPRESENTATION,
"Complex: malformed string\n");
"Complex: malformed string");
first_num_length = second_num_length = 0;
}
/* this is useful if there is no number for the
Expand All @@ -126,7 +126,7 @@ complex_parse_string (Parrot_Interp interp,
else {
/* "+" or "-" not found: error */
internal_exception(INVALID_STRING_REPRESENTATION,
"Complex: malformed string\n");
"Complex: malformed string");
first_num_length = second_num_length = 0;
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ complex_locate_keyed_num(Parrot_Interp interp, PMC* self, STRING *key) {
if(0 == string_equal(interp, key, real))
return &RE(self);
internal_exception(KEY_NOT_FOUND,
"Complex: key is neither 'real' or 'imag'\n");
"Complex: key is neither 'real' or 'imag'");
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/default.pmc
Expand Up @@ -55,7 +55,7 @@ static void
cant_do_method(Parrot_Interp interpreter, PMC * pmc, const char *methname)
{
internal_exception(ILL_INHERIT,
"%s() not implemented in class '%s'\n", methname,
"%s() not implemented in class '%s'", methname,
caller(interpreter, pmc));
}

Expand Down
4 changes: 2 additions & 2 deletions classes/delegate.pmc
Expand Up @@ -87,15 +87,15 @@ find_or_die(Parrot_Interp interpreter, PMC *pmc, STRING *meth) {
if (PObj_is_object_TEST(pmc)) {
class = GET_CLASS((Buffer *)PMC_data(pmc), pmc);
internal_exception(METH_NOT_FOUND,
"Can't find method '%s' for object '%s'\n",
"Can't find method '%s' for object '%s'",
string_to_cstring(interpreter, meth),
string_to_cstring(interpreter, PMC_str_val(
get_attrib_num((SLOTTYPE *)PMC_data(class),
PCD_CLASS_NAME)))
);
} else {
internal_exception(METH_NOT_FOUND,
"Can't find method '%s' - erroneous PMC\n",
"Can't find method '%s' - erroneous PMC",
string_to_cstring(interpreter, meth)
);
}
Expand Down
6 changes: 3 additions & 3 deletions classes/fixedbooleanarray.pmc
Expand Up @@ -157,7 +157,7 @@ Returns the integer value of the element at index C<key>.
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedBooleanArray: index out of bounds!\n");
"FixedBooleanArray: index out of bounds!");

data = (INTVAL *)PMC_data(SELF);
return data[key];
Expand Down Expand Up @@ -288,7 +288,7 @@ Resizes the array to C<size> elements.

void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
internal_exception(OUT_OF_BOUNDS, "FixedBooleanArray: Can't resize!\n");
internal_exception(OUT_OF_BOUNDS, "FixedBooleanArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate(size * sizeof(INTVAL));
PObj_active_destroy_SET(SELF);
Expand All @@ -308,7 +308,7 @@ Sets the integer value of the element at index C<key> to C<value>.
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedBooleanArray: index out of bounds!\n");
"FixedBooleanArray: index out of bounds!");

data = (INTVAL*)PMC_data(SELF);
data[key] = (value != 0);
Expand Down
6 changes: 3 additions & 3 deletions classes/fixedfloatarray.pmc
Expand Up @@ -188,7 +188,7 @@ Returns the floating-point value of the element at index C<key>.
FLOATVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedFloatArray: index out of bounds!\n");
"FixedFloatArray: index out of bounds!");

data = (FLOATVAL *)PMC_data(SELF);
return data[key];
Expand Down Expand Up @@ -288,7 +288,7 @@ Resizes the array to C<size> elements.

void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
internal_exception(OUT_OF_BOUNDS, "FixedFloatArray: Can't resize!\n");
internal_exception(OUT_OF_BOUNDS, "FixedFloatArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate(size * sizeof(FLOATVAL));
PObj_active_destroy_SET(SELF);
Expand Down Expand Up @@ -339,7 +339,7 @@ C<value>.
FLOATVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedFloatArray: index out of bounds!\n");
"FixedFloatArray: index out of bounds!");

data = (FLOATVAL*)PMC_data(SELF);
data[key] = value;
Expand Down
6 changes: 3 additions & 3 deletions classes/fixedintegerarray.pmc
Expand Up @@ -157,7 +157,7 @@ Returns the integer value of the element at index C<key>.
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedIntegerArray: index out of bounds!\n");
"FixedIntegerArray: index out of bounds!");

data = (INTVAL *)PMC_data(SELF);
return data[key];
Expand Down Expand Up @@ -288,7 +288,7 @@ Resizes the array to C<size> elements.

void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
internal_exception(OUT_OF_BOUNDS, "FixedIntegerArray: Can't resize!\n");
internal_exception(OUT_OF_BOUNDS, "FixedIntegerArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate(size * sizeof(INTVAL));
PObj_active_destroy_SET(SELF);
Expand All @@ -308,7 +308,7 @@ Sets the integer value of the element at index C<key> to C<value>.
INTVAL *data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedIntegerArray: index out of bounds!\n");
"FixedIntegerArray: index out of bounds!");

data = (INTVAL*)PMC_data(SELF);
data[key] = value;
Expand Down
6 changes: 3 additions & 3 deletions classes/fixedpmcarray.pmc
Expand Up @@ -422,7 +422,7 @@ Returns the PMC value of the element at index C<key>.
PMC **data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedPMCArray: index out of bounds!\n");
"FixedPMCArray: index out of bounds!");

data = (PMC **)PMC_data(SELF);
return data[key];
Expand Down Expand Up @@ -458,7 +458,7 @@ Resizes the array to C<size> elements.
PMC **data;

if (PMC_int_val(SELF) && size)
internal_exception(OUT_OF_BOUNDS, "FixedPMCArray: Can't resize!\n");
internal_exception(OUT_OF_BOUNDS, "FixedPMCArray: Can't resize!");
if (!size)
return;
PMC_int_val(SELF) = size;
Expand Down Expand Up @@ -604,7 +604,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
PMC **data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedPMCArray: index out of bounds!\n");
"FixedPMCArray: index out of bounds!");

data = (PMC**)PMC_data(SELF);
DOD_WRITE_BARRIER(INTERP, SELF, data[key], src);
Expand Down
6 changes: 3 additions & 3 deletions classes/fixedstringarray.pmc
Expand Up @@ -243,7 +243,7 @@ Returns the Parrot string value of the element at index C<key>.
STRING **data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedStringArray: index out of bounds!\n");
"FixedStringArray: index out of bounds!");

data = (STRING **)PMC_data(SELF);
return data[key];
Expand Down Expand Up @@ -312,7 +312,7 @@ Resizes the array to C<size> elements.

void set_integer_native (INTVAL size) {
if (PMC_int_val(SELF) || size < 1)
internal_exception(OUT_OF_BOUNDS, "FixedStringArray: Can't resize!\n");
internal_exception(OUT_OF_BOUNDS, "FixedStringArray: Can't resize!");
PMC_int_val(SELF) = size;
PMC_data(SELF) = mem_sys_allocate_zeroed(size * sizeof(STRING*));
PObj_custom_mark_destroy_SETALL(SELF);
Expand Down Expand Up @@ -406,7 +406,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
STRING **data;
if (key < 0 || key >= PMC_int_val(SELF))
internal_exception(OUT_OF_BOUNDS,
"FixedStringArray: index out of bounds!\n");
"FixedStringArray: index out of bounds!");

data = (STRING**)PMC_data(SELF);
data[key] = value;
Expand Down
6 changes: 3 additions & 3 deletions classes/integer.pmc
Expand Up @@ -598,7 +598,7 @@ Divides the integer by C<*value> and returns the result in C<*dest>.
*/
void divide (PMC* value, PMC* dest) {
MMD_PerlUndef: {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
MMD_BigInt: {
overflow_p(INTERP, SELF, value, dest, MMD_DIVIDE);
Expand All @@ -609,7 +609,7 @@ MMD_DEFAULT: {
FLOATVAL d;
INTVAL i;
if (valf == 0.0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
return;
}
d = PMC_int_val(SELF)/valf;
Expand All @@ -623,7 +623,7 @@ MMD_DEFAULT: {

void floor_divide (PMC* value, PMC* dest) {
MMD_PerlUndef: {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
MMD_BigInt: {
overflow_p(INTERP, SELF, value, dest, MMD_DIVIDE);
Expand Down
4 changes: 2 additions & 2 deletions classes/intlist.pmc
Expand Up @@ -20,7 +20,7 @@ C<IntList> provides an integer-only array.

#include "parrot/parrot.h"

#define THROW_UNSUPPORTED internal_exception(INTERP_ERROR, "Operation not supported\n")
#define THROW_UNSUPPORTED internal_exception(INTERP_ERROR, "Operation not supported")

pmclass IntList does array {

Expand Down Expand Up @@ -212,7 +212,7 @@ Removes and returns the first element in the list.

void splice(PMC* value, INTVAL offset, INTVAL count) {
if (SELF->vtable->base_type != value->vtable->base_type)
internal_exception(1, "Type mismatch in splice\n");
internal_exception(1, "Type mismatch in splice");
list_splice(INTERP, (List*) PMC_struct_val(SELF), value,
offset, count);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/iterator.pmc
Expand Up @@ -40,7 +40,7 @@ Raises an exception. Use C<init_pmc()>.
*/

void init () {
internal_exception(1, "Iterator init without aggregate\n");
internal_exception(1, "Iterator init without aggregate");
}

/*
Expand Down Expand Up @@ -283,7 +283,7 @@ Reset the Iterator. C<value> must be one of
void set_integer_native (INTVAL value) {
PMC *key, *agg;
if (value < ITERATE_FROM_START || value > ITERATE_FROM_END)
internal_exception(1, "Illegal set_integer on iterator\n");
internal_exception(1, "Illegal set_integer on iterator");
/* reset iterator on aggregate */
agg = (PMC*) PMC_pmc_val(SELF);
if (agg->vtable->base_type == enum_class_Slice) {
Expand Down
2 changes: 1 addition & 1 deletion classes/null.pl
Expand Up @@ -49,7 +49,7 @@
}

print " $retval $methname ($args) {\n";
print " internal_exception(NULL_REG_ACCESS, \"Fatal exception: Null PMC access (PMC::$methname)!\\n\");\n";
print " internal_exception(NULL_REG_ACCESS, \"Fatal exception: Null PMC access (PMC::$methname)!\");\n";
if($retval ne 'void') {
print " return ($retval)0;\n";
}
Expand Down
2 changes: 1 addition & 1 deletion classes/parrotobject.pmc
Expand Up @@ -62,7 +62,7 @@ C<Parrot_instantiate_object()>.
*/

void init() {
internal_exception(1, "Can't create new ParrotObjects\n",
internal_exception(1, "Can't create new ParrotObjects",
"use the registered class instead");
}

Expand Down
2 changes: 1 addition & 1 deletion classes/perlhash.pmc
Expand Up @@ -142,7 +142,7 @@ static STRING* make_hash_key(Interp* interpreter, PMC * key)
{
if (key == NULL) {
internal_exception(OUT_OF_BOUNDS,
"Cannot use NULL key for PerlHash!\n");
"Cannot use NULL key for PerlHash!");
return NULL;
}
return key_string(interpreter, key);
Expand Down
2 changes: 1 addition & 1 deletion classes/perlstring.pmc
Expand Up @@ -268,7 +268,7 @@ When Python mode is enabled does sprintf :(
}
else {
internal_exception(INVALID_OPERATION,
"modulus() not implemented for PerlString\n");
"modulus() not implemented for PerlString");
}
}

Expand Down
20 changes: 10 additions & 10 deletions classes/perlundef.pmc
Expand Up @@ -306,15 +306,15 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in division");
if(value->vtable == Parrot_base_vtables[enum_class_PerlUndef]) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
else if(value->vtable == Parrot_base_vtables[enum_class_PerlInt]) {
if(VTABLE_get_integer(INTERP, value) == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
}
else if(VTABLE_get_number(INTERP, value) == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}

VTABLE_set_integer_native(INTERP, dest, 0);
Expand All @@ -332,7 +332,7 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in integer division");
if(value == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
VTABLE_set_integer_native(INTERP, dest, 0);
}
Expand All @@ -350,7 +350,7 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in numeric division");
if(value == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
VTABLE_set_integer_native(INTERP, dest, 0);
}
Expand All @@ -367,15 +367,15 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in modulus");
if(value->vtable == Parrot_base_vtables[enum_class_PerlUndef]) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
else if(value->vtable == Parrot_base_vtables[enum_class_PerlInt]) {
if(VTABLE_get_integer(INTERP, value) == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
}
else if(VTABLE_get_number(INTERP, value) == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}

VTABLE_set_integer_native(INTERP, dest, 0);
Expand All @@ -393,7 +393,7 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in integer modulus");
if(value == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
VTABLE_set_integer_native(INTERP, dest, 0);
}
Expand All @@ -411,7 +411,7 @@ Morphs to a C<PerlString> with the value of C<*value>.
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Use of uninitialized value in numeric modulus");
if(value == 0) {
internal_exception(DIV_BY_ZERO, "division by zero!\n");
internal_exception(DIV_BY_ZERO, "division by zero!");
}
VTABLE_set_integer_native(INTERP, dest, 0);
}
Expand Down

0 comments on commit d185452

Please sign in to comment.