This commit is contained in:
Joel Dice
2007-10-02 18:22:48 -06:00
parent 68e382ca8d
commit f7058f8fd6
4 changed files with 460 additions and 340 deletions

View File

@ -682,6 +682,47 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
}
}
ExceptionHandler*
findExceptionHandler(Thread* t, object method)
{
object eht = codeExceptionHandlerTable(t, methodCode(t, method));
if (eht) {
for (unsigned i = 0; i < exceptionHandlerTableLength(t, eht); ++i) {
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
if (frameIp(t, frame) - 1 >= exceptionHandlerStart(eh)
and frameIp(t, frame) - 1 < exceptionHandlerEnd(eh))
{
object catchType = 0;
if (exceptionHandlerCatchType(eh)) {
object e = t->exception;
exception = 0;
PROTECT(t, e);
PROTECT(t, eht);
catchType = resolveClass
(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1);
if (catchType) {
eh = exceptionHandlerTableBody(t, eht, i);
exception = e;
} else {
// can't find what we're supposed to catch - move on.
continue;
}
}
if (catchType == 0 or instanceOf(t, catchType, t->exception)) {
return eh;
}
}
}
}
return 0;
}
object
interpret(Thread* t)
{