public static List<TryCatchBlock> copyTryCatches(BasicBlockReader block, Program target) { List<TryCatchBlock> result = new ArrayList<>(); for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) { TryCatchBlock tryCatchCopy = new TryCatchBlock(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(target.basicBlockAt(tryCatch.getHandler().getIndex())); result.add(tryCatchCopy); } return result; }
private void parseCatch() throws IOException, ListingParseException { TryCatchBlock tryCatch = new TryCatchBlock(); if (lexer.getToken() == ListingToken.IDENTIFIER && !lexer.getTokenValue().equals("goto")) { tryCatch.setExceptionType((String) lexer.getTokenValue()); lexer.nextToken(); } expectKeyword("goto"); tryCatch.setHandler(expectBlock()); currentBlock.getTryCatchBlocks().add(tryCatch); }
tryCatch.setExceptionType(symbolTable.at(typeIndex)); tryCatch.setHandler(program.basicBlockAt(data.readShort()));
tryCatch.setExceptionType(referenceCache.getCached(tryCatchNode.type.replace('/', '.'))); tryCatch.setHandler(getBasicBlock(labelIndexes.get(tryCatchNode.handler.getLabel()))); tryCatch.getHandler().setExceptionVariable(program.variableAt(minLocal + method.maxLocals)); block.getTryCatchBlocks().add(tryCatch);
public void transform(BasicBlock block) { Instruction lastInsn = block.getLastInstruction(); if (lastInsn != null) { lastInsn.acceptVisitor(this); } for (Phi phi : block.getPhis()) { for (Incoming incoming : phi.getIncomings()) { incoming.setSource(map(incoming.getSource())); } } for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { tryCatch.setHandler(map(tryCatch.getHandler())); } }
TryCatchBlock tryCatch = new TryCatchBlock(); tryCatch.setExceptionType(templateTryCatch.getExceptionType()); tryCatch.setHandler(substitutor.block(templateTryCatch.getHandler())); targetBlock.getTryCatchBlocks().add(tryCatch);
private Program generateLaunchProgram(MethodHolder method, ClassHierarchy hierarchy) { ProgramEmitter pe = ProgramEmitter.create(method, hierarchy); pe.getField(TestEntryPoint.class, "testCase", Object.class) .cast(ValueType.object(testMethod.getClassName())) .invokeSpecial(testMethod); MethodReader testMethodReader = hierarchy.getClassSource().resolve(testMethod); AnnotationReader testAnnotation = testMethodReader.getAnnotations().get(JUNIT4_TEST); AnnotationValue throwsValue = testAnnotation != null ? testAnnotation.getValue("expected") : null; if (throwsValue != null) { BasicBlock handler = pe.getProgram().createBasicBlock(); TryCatchBlock tryCatch = new TryCatchBlock(); tryCatch.setExceptionType(((ValueType.Object) throwsValue.getJavaClass()).getClassName()); tryCatch.setHandler(handler); pe.getBlock().getTryCatchBlocks().add(tryCatch); BasicBlock nextBlock = pe.getProgram().createBasicBlock(); pe.jump(nextBlock); pe.enter(nextBlock); pe.construct(AssertionError.class, pe.constant("Expected exception not thrown")).raise(); pe.enter(handler); pe.exit(); } else { pe.exit(); } return pe.getProgram(); } }
int handler = tryCatch.getHandler().getIndex(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(program.basicBlockAt(copiedNodes.getOrDefault(handler, handler))); targetBlock.getTryCatchBlocks().add(tryCatchCopy);
public static List<TryCatchBlock> copyTryCatches(BasicBlockReader block, Program target) { List<TryCatchBlock> result = new ArrayList<>(); for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) { TryCatchBlock tryCatchCopy = new TryCatchBlock(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(target.basicBlockAt(tryCatch.getHandler().getIndex())); result.add(tryCatchCopy); } return result; }
private void parseCatch() throws IOException, ListingParseException { TryCatchBlock tryCatch = new TryCatchBlock(); if (lexer.getToken() == ListingToken.IDENTIFIER && !lexer.getTokenValue().equals("goto")) { tryCatch.setExceptionType((String) lexer.getTokenValue()); lexer.nextToken(); } expectKeyword("goto"); tryCatch.setHandler(expectBlock()); currentBlock.getTryCatchBlocks().add(tryCatch); }
tryCatch.setExceptionType(symbolTable.at(typeIndex)); tryCatch.setHandler(program.basicBlockAt(data.readShort()));
tryCatch.setExceptionType(tryCatchNode.type.replace('/', '.')); tryCatch.setHandler(getBasicBlock(labelIndexes.get(tryCatchNode.handler.getLabel()))); tryCatch.getHandler().setExceptionVariable(program.variableAt(minLocal + method.maxLocals)); block.getTryCatchBlocks().add(tryCatch);
public void transform(BasicBlock block) { Instruction lastInsn = block.getLastInstruction(); if (lastInsn != null) { lastInsn.acceptVisitor(this); } for (Phi phi : block.getPhis()) { for (Incoming incoming : phi.getIncomings()) { incoming.setSource(map(incoming.getSource())); } } for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { tryCatch.setHandler(map(tryCatch.getHandler())); } }
TryCatchBlock tryCatch = new TryCatchBlock(); tryCatch.setExceptionType(templateTryCatch.getExceptionType()); tryCatch.setHandler(substitutor.block(templateTryCatch.getHandler())); targetBlock.getTryCatchBlocks().add(tryCatch);
TryCatchBlock tryCatch = new TryCatchBlock(); tryCatch.setExceptionType(((ValueType.Object) throwsValue.getJavaClass()).getClassName()); tryCatch.setHandler(handler); pe.getBlock().getTryCatchBlocks().add(tryCatch);
int handler = tryCatch.getHandler().getIndex(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(program.basicBlockAt(copiedNodes.getOrDefault(handler, handler))); targetBlock.getTryCatchBlocks().add(tryCatchCopy);