public void exceptionTest(int exc, Label end_of_exceptions,
TryExcept node, int index)
throws Exception {
for (int i = 0; i < node.getInternalHandlers().size(); i++) {
ExceptHandler handler = (ExceptHandler) node.getInternalHandlers().get(i);
//setline(name);
Label end_of_self = new Label();
if (handler.getInternalType() != null) {
code.aload(exc);
//get specific exception
visit(handler.getInternalType());
code.invokevirtual(p(PyException.class), "match", sig(Boolean.TYPE,
PyObject.class));
code.ifeq(end_of_self);
} else {
if (i != node.getInternalHandlers().size() - 1) {
throw new ParseException(
"default 'except:' must be last", handler);
}
}
if (handler.getInternalName() != null) {
code.aload(exc);
code.getfield(p(PyException.class), "value", ci(PyObject.class));
set(handler.getInternalName());
}
//do exception body
suite(handler.getInternalBody());
code.goto_(end_of_exceptions);
code.label(end_of_self);
}
code.aload(exc);
code.athrow();