use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class IncrementalModelBuilder method getStdLibCompilationUnit.
private CompilationUnit getStdLibCompilationUnit() {
CompilationUnit stdLib;
File bundle;
try {
stdLib = new Main().getStdLib();
bundle = FileLocator.getBundleFile(Platform.getBundle(ABSFRONTEND_PLUGIN_ID));
} catch (IOException e) {
Activator.logException(e);
// Your plugin is probably busted.
return null;
} catch (InternalBackendException e) {
Activator.logException(e);
// Your plugin is probably busted.
return null;
}
File src = new File(bundle, stdLib.getFileName());
if (!src.exists()) {
src = new File(bundle, "src/" + stdLib.getFileName());
}
stdLib.setName(src.getAbsolutePath());
return stdLib;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class ErlangBackend method compile.
public static void compile(Model m, File destDir, EnumSet<CompileOptions> options) throws IOException, InterruptedException, InternalBackendException {
int version = getErlangVersion();
if (version < minErlangVersion) {
String message = "ABS requires at least erlang version " + Integer.toString(minErlangVersion) + ", installed version is " + Integer.toString(version);
throw new InternalBackendException(message);
}
ErlApp erlApp = new ErlApp(destDir);
m.generateErlangCode(erlApp, options);
erlApp.close();
String[] rebarProgram = new String[] { "escript", "../bin/rebar", "compile" };
Process p = Runtime.getRuntime().exec(rebarProgram, null, new File(destDir, "absmodel"));
if (options.contains(CompileOptions.VERBOSE))
IOUtils.copy(p.getInputStream(), System.out);
else
IOUtils.copy(p.getInputStream(), new NullOutputStream());
p.waitFor();
if (p.exitValue() != 0) {
String message = "Compilation of generated erlang code failed with exit value " + p.exitValue();
if (!options.contains(CompileOptions.VERBOSE))
message = message + "\n (use -v for detailed compiler output)";
throw new InternalBackendException(message);
// TODO: consider removing the generated code here. For now,
// let's leave it in place for diagnosis.
} else {
if (options.contains(CompileOptions.VERBOSE)) {
System.out.println();
System.out.println("Finished. \"gen/erl/run\" to start the model.");
System.out.println(" (\"gen/erl/run --help\" for more options)");
}
}
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class ErlangBackend method parseArgs.
@Override
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-erlang")) {
// nothing to do
} else if (arg.equals("-d")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Please provide an output directory");
} else {
destDir = new File(restArgs.get(i));
}
} else if (arg.equals("-cover")) {
compileOptions.add(CompileOptions.COVERAGE);
} else {
remainingArgs.add(arg);
}
}
// KLUDGE
if (verbose)
compileOptions.add(CompileOptions.VERBOSE);
// KLUDGE
if (debug)
compileOptions.add(CompileOptions.DEBUG);
return remainingArgs;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class JavaBackend method parseArgs.
@Override
public List<String> parseArgs(String[] args) throws InternalBackendException {
List<String> restArgs = super.parseArgs(args);
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < restArgs.size(); i++) {
String arg = restArgs.get(i);
if (arg.equals("-d")) {
i++;
if (i == restArgs.size()) {
throw new InternalBackendException("Destination directory name not given after '-d'");
} else {
destDir = new File(args[i]);
}
} else if (arg.equals("-sourceonly")) {
this.sourceOnly = true;
} else if (arg.equals("-dynamic")) {
this.untypedJavaGen = true;
} else if (arg.equals("-no-debuginfo")) {
this.includeDebug = false;
} else if (arg.equals("-debuginfo")) {
this.includeDebug = true;
} else if (arg.equals("-java")) {
// nothing to do
} else {
remainingArgs.add(arg);
}
}
return remainingArgs;
}
use of abs.backend.common.InternalBackendException in project abstools by abstools.
the class Main method mainMethod.
public int mainMethod(final String... args) {
int result = 0;
try {
java.util.List<String> argslist = Arrays.asList(args);
if (argslist.contains("-help") || argslist.contains("-h") || argslist.contains("--help")) {
printUsage();
} else if (argslist.contains("-version") || argslist.contains("--version")) {
printVersion();
} else if (argslist.contains("-maude")) {
result = abs.backend.maude.MaudeCompiler.doMain(args);
} else if (argslist.contains("-java")) {
result = abs.backend.java.JavaBackend.doMain(args);
} else if (argslist.contains("-erlang")) {
result = abs.backend.erlang.ErlangBackend.doMain(args);
} else if (argslist.contains("-prolog")) {
result = abs.backend.prolog.PrologBackend.doMain(args);
} else if (argslist.contains("-coreabs")) {
result = abs.backend.coreabs.CoreAbsBackend.doMain(args);
} else if (argslist.contains("-prettyprint")) {
result = abs.backend.prettyprint.PrettyPrinterBackEnd.doMain(args);
} else if (argslist.contains("-outline")) {
result = abs.backend.outline.OutlinePrinterBackEnd.doMain(args);
} else {
Model m = parse(args);
if (m.hasParserErrors() || m.hasErrors() || m.hasTypeErrors()) {
printErrorMessage();
result = 1;
}
}
} catch (InternalBackendException e) {
// don't print stack trace here
printError(e.getMessage());
result = 1;
} catch (Exception e) {
if (e.getMessage() == null) {
e.printStackTrace();
}
assert e.getMessage() != null : e.toString();
printError(e.getMessage());
result = 1;
}
return result;
}
Aggregations