public String asJava() { try { return this.tryAsJava(); } catch (Throwable t) { ParseTree pt = ParseTree.getParseTree(this.context); pt.handleTypeResolveException(pt, this.getOriginalCode(), t, false); return UntranslatedExpression.createUntranslatedExpression(this.getOriginalCode(), context) .asJava(); } }
public JavaProgram createJavaProgram( List sourceFiles, String libraryPath, String mainClassname, String projectType, String policyType) throws Exception { // Debug.setOn(true); long l = Debug.getTime(); LibraryData libraryData = new LibraryData(new File(libraryPath), projectType, language, false); Library library = new Library(libraryData); Parser parser = Parser.createParser(this.language, sourceFiles, library, new TranslationPolicy(policyType)); long lll = Debug.getTime(); System.out.println("Library Loaded in " + (lll - l) + "ms"); ParseTree tree = parser.parse(); TranslationReport report = tree.getTranslationReport(); long ll = Debug.getTime(); System.out.println("Code parsed in " + (ll - lll) + "ms"); Debug.setOn(true); Translator tt = new Translator(this.language); JavaProgram jp = tt.createJavaProgram(tree, mainClassname, projectType); if (report.hasTypeResolveErrors() || report.hasTranslationWarnings()) { List errors = new ArrayList(); errors.addAll(report.getTypeResolveExceptions()); report.doReport(errors, report.getTranslationWarnings()); } l = Debug.getTime(); System.out.println("Translated in " + (l - ll) + "ms"); jp.setTypeResolved(!report.hasTypeResolveErrors()); // resolved if no errors return jp; }