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);
}
}
}
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;
}
Aggregations