Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Using representations that don't exist should die.
Before, it failed silently, falling back to KnowHOW.
  • Loading branch information
jnthn committed Feb 24, 2013
1 parent cd22fa9 commit ac4421c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/6model/repr_registry.c
Expand Up @@ -247,11 +247,17 @@ void REPR_initialize_registry(PARROT_INTERP) {
/* Get a representation's ID from its name. Note that the IDs may change so
* it's best not to store references to them in e.g. the bytecode stream. */
INTVAL REPR_name_to_id(PARROT_INTERP, STRING *name) {
if (!VTABLE_exists_keyed_str(interp, repr_name_to_id_map, name))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Representation '%Ss' does not exist", name);
return VTABLE_get_integer_keyed_str(interp, repr_name_to_id_map, name);
}

/* Gets a representation by ID. */
REPROps * REPR_get_by_id(PARROT_INTERP, INTVAL id) {
if (id < 0 || id >= num_reprs)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Invalid representation index");
return repr_registry[id];
}

Expand Down

0 comments on commit ac4421c

Please sign in to comment.