Skip to content

Commit

Permalink
move control exceptions to their own number block, add _ALL types tha…
Browse files Browse the repository at this point in the history
…t catch any exception of that type
  • Loading branch information
mlschroe committed Nov 4, 2011
1 parent 0d94c86 commit 461e486
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion compilers/pct/src/PAST/Compiler.pir
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ any value type.
## type of exception handler we support
.local pmc controltypes
controltypes = new 'Hash'
controltypes['CONTROL'] = '.CONTROL_RETURN, .CONTROL_OK, .CONTROL_BREAK, .CONTROL_CONTINUE, .CONTROL_TAKE, .CONTROL_LEAVE, .CONTROL_EXIT, .CONTROL_LOOP_NEXT, .CONTROL_LOOP_LAST, .CONTROL_LOOP_REDO'
controltypes['CONTROL'] = '.CONTROL_ALL'
controltypes['RETURN'] = '.CONTROL_RETURN'
controltypes['OK'] = '.CONTROL_OK'
controltypes['BREAK'] = '.CONTROL_BREAK'
Expand Down
11 changes: 7 additions & 4 deletions include/parrot/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/* &gen_from_enum(except_types.pasm) */
typedef enum {
EXCEPTION_BAD_BUFFER_SIZE,
EXCEPTION_BAD_BUFFER_SIZE = 0x00000,
EXCEPTION_MISSING_ENCODING_NAME,
EXCEPTION_INVALID_STRING_REPRESENTATION,
EXCEPTION_ICU_ERROR,
Expand Down Expand Up @@ -80,19 +80,22 @@ typedef enum {
EXCEPTION_LIBRARY_NOT_LOADED,
EXCEPTION_SYNTAX_ERROR,
EXCEPTION_MALFORMED_PACKFILE,
EXCEPTION_ALL = 0x0ffff,

CONTROL_RETURN,
CONTROL_RETURN = 0x10000,
CONTROL_OK,
CONTROL_BREAK,
CONTROL_CONTINUE,
CONTROL_ERROR,
CONTROL_TAKE,
CONTROL_LEAVE,
CONTROL_EXIT,

CONTROL_LOOP_NEXT,
CONTROL_LOOP_LAST,
CONTROL_LOOP_REDO
CONTROL_LOOP_REDO,
CONTROL_ALL = 0x1ffff,

EXCEPTION_TYPE_ALL_MASK = 0xffff
} exception_type_enum;

/* &end_gen */
Expand Down
7 changes: 4 additions & 3 deletions src/pmc/exceptionhandler.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ Report whether the exception handler can handle a particular type of exception.
if (handled_types->vtable->base_type == enum_class_Key) {
PMC *key = handled_types;
for (; key; key = Parrot_key_next(INTERP, key)) {
if (Parrot_key_integer(INTERP, key) == type)
const INTVAL handled_type = Parrot_key_integer(INTERP, key);
if (handled_type == type || handled_type == (type | EXCEPTION_TYPE_ALL_MASK))
RETURN(INTVAL 1);
}
}
Expand All @@ -256,7 +257,7 @@ Report whether the exception handler can handle a particular type of exception.
for (i = 0; i < elems; ++i) {
const INTVAL handled_type =
VTABLE_get_integer_keyed_int(INTERP, handled_types, i);
if (handled_type == type)
if (handled_type == type || handled_type == (type | EXCEPTION_TYPE_ALL_MASK))
RETURN(INTVAL 1);
}
}
Expand All @@ -276,7 +277,7 @@ Report whether the exception handler can handle a particular type of exception.
for (i = 0; i < elems; ++i) {
const INTVAL handled_type = VTABLE_get_integer_keyed_int(INTERP,
handled_types_except, i);
if (handled_type == type)
if (handled_type == type || handled_type == (type | EXCEPTION_TYPE_ALL_MASK))
RETURN(INTVAL 0);
}
}
Expand Down

0 comments on commit 461e486

Please sign in to comment.