if(!tryBody.hasStatements()) {
if(_finally!=null && _finally.getBody()!=null)_finally.getBody().writeOut(bc);
return;
}
TryCatchFinallyVisitor tcfv=new TryCatchFinallyVisitor(new OnFinally() {
public void writeOut(BytecodeContext bc) throws BytecodeException {
/*GeneratorAdapter ga = bc.getAdapter();
if(fcf!=null && fcf.getAfterFinalGOTOLabel()!=null)
ASMUtil.visitLabel(ga,fcf.getFinalEntryLabel());
*/
if(_finally!=null) {
ExpressionUtil.visitLine(bc, _finally.getStart());
_finally.getBody().writeOut(bc);
}
/*if(fcf!=null){
Label l=fcf.getAfterFinalGOTOLabel();
if(l!=null)ga.visitJumpInsn(Opcodes.GOTO, l);
}*/
}
},getFlowControlFinal());
// Try
tcfv.visitTryBegin(bc);
tryBody.writeOut(bc);
int e=tcfv.visitTryEndCatchBeging(bc);
// if(e instanceof railo.runtime.exp.Abort) throw e;
Label abortEnd=new Label();
adapter.loadLocal(e);
// Abort.isAbort(t);
adapter.invokeStatic(Types.ABORT, TryCatchFinally.IS_ABORT);
//adapter.instanceOf(Types.ABORT);
adapter.ifZCmp(Opcodes.IFEQ, abortEnd);
adapter.loadLocal(e);
adapter.throwException();
adapter.visitLabel(abortEnd);
// PageExceptionImpl old=pc.getCatch();
int old=adapter.newLocal(Types.PAGE_EXCEPTION);
adapter.loadArg(0);
adapter.invokeVirtual(Types.PAGE_CONTEXT, GET_CATCH);
adapter.storeLocal(old);
// PageException pe=Caster.toPageEception(e);
int pe=adapter.newLocal(Types.PAGE_EXCEPTION);
adapter.loadLocal(e);
adapter.invokeStatic(Types.CASTER, TO_PAGE_EXCEPTION);
adapter.storeLocal(pe);
Iterator<Tag> it = catches.iterator();
Attribute attrType;
Expression type;
Label endAllIfs=new Label();
Tag tagElse=null;
while(it.hasNext()) {
tag=it.next();
Label endIf=new Label();
attrType = tag.getAttribute("type");
type=ANY;
if(attrType!=null)type=attrType.getValue();
if(type instanceof LitString && ((LitString)type).getString().equalsIgnoreCase("any")){
tagElse=tag;
continue;
}
ExpressionUtil.visitLine(bc, tag.getStart());
// if(pe.typeEqual(@type)
adapter.loadLocal(pe);
type.writeOut(bc, Expression.MODE_REF);
adapter.invokeVirtual(Types.PAGE_EXCEPTION, TYPE_EQUAL);
adapter.ifZCmp(Opcodes.IFEQ, endIf);
catchBody(bc,adapter,tag,pe,true,true);
adapter.visitJumpInsn(Opcodes.GOTO, endAllIfs);
adapter.visitLabel(endIf);
}
// else
if(tagElse!=null){
catchBody(bc, adapter, tagElse, pe, true,true);
}
else{
// pc.setCatch(pe,true);
adapter.loadArg(0);
adapter.loadLocal(pe);
adapter.push(false);
adapter.push(true);
adapter.invokeVirtual(Types.PAGE_CONTEXT, SET_CATCH3);
//throw pe;
adapter.loadLocal(pe);
adapter.throwException();
}
adapter.visitLabel(endAllIfs);
// PageExceptionImpl old=pc.getCatch();
adapter.loadArg(0);
adapter.loadLocal(old);
adapter.invokeVirtual(Types.PAGE_CONTEXT, SET_CATCH_PE);
tcfv.visitCatchEnd(bc);
}