use of claw.tatsu.xcodeml.backend.OmniBackendDriver in project claw-compiler by C2SM-RCM.
the class ClawX2T method run.
public static void run(final Configuration cfg, final List<Path> moduleIncludeDirs, final InputStream inXast, final OutputStream outReport, final OutputStream outputXast, final OutputStream outputSrc, final PrintStream outputErr, final String[] args) throws Exception {
if (cfg.getCurrentTarget() == Target.FPGA) {
throw new Exception("FPGA target is not supported");
}
// Setup translation context
if (outputErr != null) {
cfg.context().setErrorStream(outputErr);
}
for (Path xmodSrchPath : moduleIncludeDirs) {
cfg.context().getModuleCache().addSearchPath(xmodSrchPath.toString());
}
// Perform transformations
ClawTranslatorDriver translatorDriver = new ClawTranslatorDriver(cfg);
translatorDriver.analyze(inXast);
translatorDriver.transform();
if (outputXast != null) {
translatorDriver.getTranslationUnit().write(outputXast, ClawConstant.INDENT_OUTPUT);
}
translatorDriver.flush();
if (outReport != null) {
ClawTransformationReport report = new ClawTransformationReport(outReport);
report.generate(args, translatorDriver, cfg);
}
if (outputSrc != null) {
try {
OmniBackendDriver backend = new OmniBackendDriver(OmniBackendDriver.Lang.FORTRAN);
IXmOption xmOption = cfg.context().getXmOption();
backend.decompile(outputSrc, translatorDriver.getTranslationUnit().getDocument(), cfg.getUserMaxColumns(), xmOption.isSuppressLineDirective(), xmOption);
} catch (Exception e) {
throw new Exception("Failed to decompile XcodeML to Fortran", e);
}
}
}
Aggregations