Search in sources :

Example 1 with ClawTranslatorDriver

use of claw.wani.x2t.translator.ClawTranslatorDriver 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);
        }
    }
}
Also used : Path(java.nio.file.Path) OmniBackendDriver(claw.tatsu.xcodeml.backend.OmniBackendDriver) IXmOption(xcodeml.util.IXmOption) ClawTransformationReport(claw.wani.report.ClawTransformationReport) ClawTranslatorDriver(claw.wani.x2t.translator.ClawTranslatorDriver) IOException(java.io.IOException)

Aggregations

OmniBackendDriver (claw.tatsu.xcodeml.backend.OmniBackendDriver)1 ClawTransformationReport (claw.wani.report.ClawTransformationReport)1 ClawTranslatorDriver (claw.wani.x2t.translator.ClawTranslatorDriver)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 IXmOption (xcodeml.util.IXmOption)1