NAME ^

src/exceptions.c - Exceptions

DESCRIPTION ^

Define the internal interpreter exceptions.

Functions ^

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.

do_panic

Panic handler.

push_exception

Add the exception handler on the stack.

Parrot_push_action

Push an action handler onto the dynamic environment.

Parrot_push_mark

Push a cleanup mark onto the dynamic environment.

Parrot_pop_mark

Pop items off the dynamic environment up to the mark.

find_exception_handler

Find the exception handler for exception.

pop_exception

Pops the topmost exception handler off the stack.

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.

push_new_c_exception_handler

Pushes an new C exception handler onto the stack.

throw_exception

Throw the exception.

rethrow_exception

Rethrow the exception.

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.

dest2offset

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

create_exception

Create an exception.

handle_exception

Handle an exception.

new_internal_exception

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

free_internal_exception

Place internal exception buffer back on the free list.

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.

*/

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);
}
/*

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.

Parrot_init_exceptions

Create exception objects.

Parrot_confess

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

SEE ALSO ^

include/parrot/exceptions.h.


parrot