@Override public final KernelTry try_(final KernelTry t) { new ExceptionSerialBlock(getExecutor(), t); return t; }
@Override public KernelFinally finally_(KernelFinally block) { ExceptionSerialBlock serial = getSerial(); if (serial.getFinally() != null) { throw new ASMSupportException("Already exists finally block."); } getSerial().appendEpisode(block); return block; }
private List<KernelReturn> fetchAllBreakStack(InstructionBlockNode block, List<KernelReturn> container) { if (container == null) { container = new ArrayList<>(); } for (InstructionNode executor : block.getChildren()) { if (executor instanceof KernelReturn) { container.add((KernelReturn) executor); } else if (executor instanceof InstructionBlockNode && !(executor instanceof ImplicitCatch)) { fetchAllBreakStack((InstructionBlockNode) executor, container); } } return container; }
public ExceptionSerialBlock(KernelProgramBlock parent, KernelTry tryBlock) { super(parent); this.tryBlock = tryBlock; initEpisode(tryBlock); getChildren().add(tryBlock); }
tryBlock, getSerialEnd()); if (!c.isFinish()) { OperatorFactory.newOperator(GOTO.class, new Class[] { KernelProgramBlock.class, Label.class }, c, getSerialEnd()); addAnyExceptionCatchRange(tryBlock.getStart()); insertFinallyBeforeReturn(tryBlock); addAnyExceptionCatchRange(tryBlock.getEnd()); addAnyExceptionCatchRange(tryBlock.getStart()); insertFinallyBeforeReturn(tryBlock); insertFinallyBeforeReturn(c); addAnyExceptionCatchRange(finallyStart); new Class[] { KernelProgramBlock.class, Label.class }, c, getSerialEnd()); addAnyExceptionCatchRange(finallyEnd); addAnyExceptionCatchRange(catches.get(catches.size() - 1).getEnd()); Label start = anyCatchRange.get(i++); Label end = anyCatchRange.get(i++); this.addTreCatchInfo(start, end, implicitCatch.getStart(), targetParent.getType(AnyException.class));
void appendEpisode(KernelCatch catchBlock) { initEpisode(catchBlock); if (catches == null) { catches = new ArrayList<>(); getChildren().addAfter(tryBlock, catchBlock); } else { KernelCatch previous = catches.get(catches.size() - 1); IClass exceptionType = catchBlock.getExceptionType(); if (exceptionType != null && exceptionType.isChildOrEqual(previous.getExceptionType())) { throw new ASMSupportException("Unreachable catch block for " + exceptionType + ". It is already handled by the catch block for " + exceptionType); } getChildren().addAfter(previous, catchBlock); } catches.add(catchBlock); // Add Exception Table: addTreCatchInfo(tryBlock.getStart(), tryBlock.getEnd(), catchBlock.getStart(), catchBlock.getExceptionType()); }
List<KernelReturn> returns = fetchAllBreakStack(block, null); addAnyExceptionCatchRange(startLbl); addAnyExceptionCatchRange(endLbl);
void appendEpisode(KernelFinally finallyBlock) { if (this.finallyBlock != null) { throw new ASMSupportException("Finally block already exists."); } initEpisode(finallyBlock); this.finallyBlock = finallyBlock; // add implicit catch block; implicitCatch = new ImplicitCatch(); implicitCatch.setParent(targetParent); getChildren().setTail(implicitCatch); getChildren().setTail(finallyBlock); }
@Override public KernelCatch catch_(KernelCatch catchBlock) { ExceptionSerialBlock serial = getSerial(); if (serial.getFinally() != null) { throw new ASMSupportException("Exists finally block. please create catch before finally block"); } getSerial().appendEpisode(catchBlock); return catchBlock; }
@Override public KernelFinally finally_(KernelFinally block) { ExceptionSerialBlock serial = getSerial(); if (serial.getFinally() != null) { throw new ASMSupportException("Already exists finally block."); } getSerial().appendEpisode(block); return block; }
@Override public KernelCatch catch_(KernelCatch catchBlock) { ExceptionSerialBlock serial = getSerial(); if (serial.getFinally() != null) { throw new ASMSupportException("Exists finally block. please create catch before finally block"); } getSerial().appendEpisode(catchBlock); return catchBlock; }