NAME ^

src/exceptions.c - Exceptions

DESCRIPTION ^

Define the internal interpreter exceptions.

Functions ^

void internal_exception

Signal a fatal exception. This involves printing an error message to stderr, and calling Parrot_exit to invoke exit handlers and exit the process with the given exitcode. No error handlers are used, so it is not possible for Parrot bytecode to intercept a fatal error (cf. real_exception). Furthermore, no stack unwinding is done, so the exit handlers run in the current dynamic environment.

void do_panic

Panic handler.

void push_exception

Add the exception handler on the stack.

static void run_cleanup_action

RT#48260: Not yet documented!!!

void Parrot_push_action

Push an action handler onto the dynamic environment.

void Parrot_push_mark

Push a cleanup mark onto the dynamic environment.

void Parrot_pop_mark

Pop items off the dynamic environment up to the mark.

static PMC *find_exception_handler

Find the exception handler for exception.

INTVAL count_exception_handlers

Return the number of exception handlers on the exeception handler stack.

PMC *get_exception_handler

Return an exception handler by index into the exeception handler stack.

PMC *get_all_exception_handlers

Return an array of all exception handlers.

void pop_exception

Pops the topmost exception handler off the stack.

PMC *new_c_exception_handler

Generate an exception handler, that catches PASM level exceptions inside a C function. This could be a separate class too, for now just a private flag bit is set.

void push_new_c_exception_handler

Pushes an new C exception handler onto the stack.

opcode_t *throw_exception

Throw the exception.

opcode_t *rethrow_exception

Rethrow the exception.

void rethrow_c_exception

Return back to runloop, assumes exception is still in todo (see RT#45915) and that this is called from within a handler setup with new_c_exception.

static size_t dest2offset

Translate an absolute bytecode location to an offset used for resuming after an exception had occurred.

static opcode_t *create_exception

Create an exception.

size_t handle_exception

Handle an exception.

void new_internal_exception

Create a new internal exception buffer, either by allocating it or by getting one from the free list.

void free_internal_exception

Place internal exception buffer back on the free list.

void destroy_exception_list

RT#48260: Not yet documented!!!

void really_destroy_exception_list

RT#48260: Not yet documented!!!

void do_exception

Called from interrupt code. Does a longjmp in front of the runloop, which calls handle_exception(), returning the handler address where execution then resumes.

void do_str_exception

void do_pmc_exception

*/

PARROT_API PARROT_DOES_NOT_RETURN void do_str_exception(PARROT_INTERP, ARGIN(STRING *msg)) { Parrot_exception * const the_exception = interp->exceptions;

    the_exception->error = E_RuntimeError;
    the_exception->severity = EXCEPT_error;
    the_exception->msg = msg;
    the_exception->resume = NULL;
    longjmp(the_exception->destination, 1);
}
PARROT_API PARROT_DOES_NOT_RETURN void do_pmc_exception(PARROT_INTERP, ARGIN(PMC *msg)) { Parrot_exception * const the_exception = interp->exceptions;

    the_exception->error = E_RuntimeError;
    the_exception->severity = EXCEPT_error;
    the_exception->msg = VTABLE_get_string(interp, msg);;
    the_exception->resume = NULL;
    longjmp(the_exception->destination, 1);
}
PARROT_API PARROT_DOES_NOT_RETURN void do_exception(PARROT_INTERP, INTVAL severity, long error) { Parrot_exception * const the_exception = interp->exceptions;

    the_exception->error = error;
    the_exception->severity = severity;
    the_exception->msg = NULL;
    the_exception->resume = NULL;
    longjmp(the_exception->destination, 1);
}
/*

void real_exception

Throws a real exception, with an error message constructed from the format string and arguments. ret_addr is the address from which to resume, if some handler decides that is appropriate, or zero to make the error non-resumable. exitcode is a exception_type_enum value.

See also internal_exception(), which signals fatal errors, and throw_exception, which calls the handler.

void Parrot_init_exceptions

Create exception objects.

void Parrot_confess

A better version of assert() that gives a backtrace if possible.

void Parrot_print_backtrace

RT#48260: Not yet documented!!!

SEE ALSO ^

include/parrot/exceptions.h.


parrot