use of org.abs_models.frontend.ast.AddAddExp in project abstools by abstools.
the class TimeoutThread method genCode.
/**
* Generates Erlang code in target directory, adding a last statement that
* prints the value of the `testresult' variable.
*
* @return a Module Name containing a Main Block
* @throws InternalBackendException
*/
public String genCode(Model model, File targetDir, boolean appendResultprinter) throws IOException, InterruptedException, InternalBackendException {
if (model.hasErrors()) {
Assert.fail(model.getErrors().getFirstError().getHelpMessage());
}
if (model.hasTypeErrors()) {
Assert.fail(model.getTypeErrors().getFirstError().getHelpMessage());
}
MainBlock mb = model.getMainBlock();
if (mb != null && appendResultprinter) {
// We search for this output in the `run' method below
mb.addStmt(new ExpressionStmt(new List<>(), new FnApp("ABS.StdLib.println", new List<>(new AddAddExp(new StringLiteral("RES="), new FnApp("ABS.StdLib.toString", new List<>(new VarUse("testresult"))))))));
}
new ErlangBackend().compile(model, targetDir, // use the following argument for silent compiler:
EnumSet.noneOf(ErlangBackend.CompileOptions.class));
if (mb == null)
return null;
else
return mb.getModuleDecl().getName();
}
Aggregations