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); }
int typeIndex = data.readInt(); if (typeIndex >= 0) { tryCatch.setExceptionType(symbolTable.at(typeIndex));
public void rename(Program program) { for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock basicBlock = program.basicBlockAt(i); for (Instruction insn : basicBlock) { insn.acceptVisitor(this); } for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) { if (tryCatch.getExceptionType() != null) { tryCatch.setExceptionType(classNameMapper.map(tryCatch.getExceptionType())); } } } }
TryCatchBlock tryCatch = new TryCatchBlock(); if (tryCatchNode.type != null) { tryCatch.setExceptionType(referenceCache.getCached(tryCatchNode.type.replace('/', '.')));
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(); } }
TryCatchBlock tryCatchCopy = new TryCatchBlock(); 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); }
int typeIndex = data.readInt(); if (typeIndex >= 0) { tryCatch.setExceptionType(symbolTable.at(typeIndex));
public void rename(Program program) { for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock basicBlock = program.basicBlockAt(i); for (Instruction insn : basicBlock) { insn.acceptVisitor(this); } for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) { if (tryCatch.getExceptionType() != null) { tryCatch.setExceptionType(classNameMapper.map(tryCatch.getExceptionType())); } } } }
TryCatchBlock tryCatch = new TryCatchBlock(); if (tryCatchNode.type != null) { tryCatch.setExceptionType(tryCatchNode.type.replace('/', '.'));
tryCatch.setExceptionType(templateTryCatch.getExceptionType()); tryCatch.setHandler(substitutor.block(templateTryCatch.getHandler())); targetBlock.getTryCatchBlocks().add(tryCatch);
BasicBlock handler = pe.getProgram().createBasicBlock(); TryCatchBlock tryCatch = new TryCatchBlock(); tryCatch.setExceptionType(((ValueType.Object) throwsValue.getJavaClass()).getClassName()); tryCatch.setHandler(handler); pe.getBlock().getTryCatchBlocks().add(tryCatch);
TryCatchBlock tryCatchCopy = new TryCatchBlock(); int handler = tryCatch.getHandler().getIndex(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(program.basicBlockAt(copiedNodes.getOrDefault(handler, handler))); targetBlock.getTryCatchBlocks().add(tryCatchCopy);