NAME ^

src/exceptions.c - Exceptions

DESCRIPTION ^

Define the internal interpreter exceptions.

Functions ^

void internal_exception(int exitcode, const char *format, ...)

Exception handler.

void do_panic(Interp *interpreter, const char *message, const char *file, int line)

Panic handler.

void push_exception(Interp *interpreter, PMC *handler)

Add the exception handler on the stack.

void Parrot_push_action(Interp *interpreter, PMC *sub)

Push an action handler onto the control stack.

void Parrot_push_mark(Interp *interpreter, INTVAL mark)

Push a cleanup mark onto the control stack.

void Parrot_pop_mark(Interp *interpreter, INTVAL mark)

Pop items off the control stack up to the mark.

static PMC *find_exception_handler(Interp *interpreter, PMC *exception)

Find the exception handler for exception.

void pop_exception(Interp *interpreter)

Pops the topmost exception handler off the stack.

PMC *new_c_exception_handler(Interp *interpreter, Parrot_exception *jb)

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(Interp *interpreter, Parrot_exception *jb)

Pushes an new C exception handler onto the stack.

void *throw_exception(Interp *interpreter, PMC *exception, void *dest)

Throw the exception.

void *rethrow_exception(Interp *interpreter, PMC *exception)

Rethrow the exception.

void rethrow_c_exception(Interp *interpreter)

Return back to runloop, assumes exception is still in REG_PMC(5) and that this is called from within a handler setup with new_c_exception

static size_t dest2offset(Interp *interpreter, opcode_t *dest)

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

static opcode_t *create_exception(Interp *interpreter)

Create an exception.

size_t handle_exception(Interp *interpreter)

Handle an exception.

void new_internal_exception(Interp *interpreter)

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

void free_internal_exception(Interp *interpreter)

Place internal exception buffer back on the free list.

void do_exception(Interp *interpreter, exception_severity severity, long error)

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 real_exception(Interp *interpreter, void *ret_addr, int exitcode, const char *format, ...)

Unlike internal_exception() this throws a real exception.

void Parrot_init_exceptions(Interp *interpreter)

Create exception objects.

*/

void Parrot_init_exceptions(Interp *interpreter) { int i; PMC *ex;

    interpreter->exception_list = mem_sys_allocate(
            sizeof(PMC*) * (E_LAST_PYTHON_E + 1));
    for (i = 0; i <= E_LAST_PYTHON_E; ++i) {
        ex = pmc_new(interpreter, enum_class_Exception);
        interpreter->exception_list[i] = ex;
        VTABLE_set_integer_keyed_int(interpreter, ex, 1, i);
    }
}
/*

SEE ALSO ^

include/parrot/exceptions.h.


parrot