public static void createTryCatch(EvaluationContext context,
Collection<Statement> statements, Collection<CatchBlock> catchBlocks, InstList l) throws CompilerException {
Mark start_pc = new Mark() ;
Mark end_pc = new Mark() ;
l.add(new Nop(start_pc)) ;
for(Statement s: statements) {
context.compile(s,l) ;
}
l.add(new Nop(end_pc)) ;
Mark the_end = new Mark() ;
l.add(new Goto(the_end)) ;
for(CatchBlock cb: catchBlocks) {
final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),new FIFO<VarDecl>(cb.ex));
EvaluationContext newContext = context.setVars(vars) ;
Var v = (Var)newContext.getVar(cb.ex.name);
final String extype = cb.ex.type;
Mark handler = new Mark() ;
l.add(new ExceptionHandler(start_pc,end_pc,handler,context.fullyQualified(extype))) ;
l.add(new Nop(handler)) ;
l.add(new Store(v)) ;
for(Statement s1: cb.statements) {
newContext.compile(s1,l) ;
}
l.add(new Goto(the_end)) ;
}
l.add(new Nop(the_end)) ;
}