Search in sources :

Example 1 with IXmOption

use of xcodeml.util.IXmOption 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)

Example 2 with IXmOption

use of xcodeml.util.IXmOption in project claw-compiler by C2SM-RCM.

the class ClawX2T method createCfg.

public static Configuration createCfg(ConfigurationOptions opts) throws Exception {
    // Set decompiler options
    IXmOption xmOption = new XmOptionLocal();
    if (opts.suppressPreprocLineDirectives()) {
        xmOption.setIsSuppressLineDirective(true);
    }
    if (opts.showDebugOutput()) {
        xmOption.setDebugOutput(true);
    }
    if (opts.addParenToBinaryOpts()) {
        xmOption.setAddPar(true);
    }
    // Prepare configuration
    final Context transContext = new Context(System.err, xmOption);
    final Configuration cfg = Configuration.load(opts.configDirPath(), opts.configFilePath(), opts.modelConfigFilePath(), opts.targetPlatform(), opts.accDirectiveLanguage(), opts.maxFortranLineLength(), transContext, opts.transSetPaths());
    for (String keyValue : opts.cfgKeysOverrides()) {
        String key = keyValue.substring(0, keyValue.indexOf(":"));
        String value = keyValue.substring(keyValue.indexOf(":") + 1);
        cfg.overrideConfigurationParameter(key, value);
    }
    if (opts.exitOnPureFunction()) {
        cfg.setForcePure();
    }
    return cfg;
}
Also used : Context(claw.tatsu.common.Context) IXmOption(xcodeml.util.IXmOption) Configuration(claw.wani.x2t.configuration.Configuration) XmOptionLocal(xcodeml.util.XmOptionLocal)

Aggregations

IXmOption (xcodeml.util.IXmOption)2 Context (claw.tatsu.common.Context)1 OmniBackendDriver (claw.tatsu.xcodeml.backend.OmniBackendDriver)1 ClawTransformationReport (claw.wani.report.ClawTransformationReport)1 Configuration (claw.wani.x2t.configuration.Configuration)1 ClawTranslatorDriver (claw.wani.x2t.translator.ClawTranslatorDriver)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 XmOptionLocal (xcodeml.util.XmOptionLocal)1