use of abs.frontend.ast.Model in project abstools by abstools.
the class NavigatorUtilsTests method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
natureMock = mock(AbsNature.class);
natureMock.modelLock = new Object();
moduleDecl1 = mock(ModuleDecl.class);
moduleDecl2 = mock(ModuleDecl.class);
moduleDecl3 = mock(ModuleDecl.class);
moduleDecl4 = mock(ModuleDecl.class);
when(moduleDecl1.getName()).thenReturn("A");
when(moduleDecl2.getName()).thenReturn("A.A");
when(moduleDecl3.getName()).thenReturn("A.A.A");
when(moduleDecl4.getName()).thenReturn("A.A.A.A");
Model modelMock = mock(Model.class);
when(modelMock.getModuleDecls()).thenReturn(Arrays.asList(moduleDecl1, moduleDecl2, moduleDecl3, moduleDecl4));
when(natureMock.getCompleteModel()).thenReturn(modelMock);
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class InternalASTNodeTests method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
natureMock = mock(AbsNature.class);
natureMock.modelLock = new Object();
moduleDecl1 = mock(ModuleDecl.class);
moduleDecl2 = mock(ModuleDecl.class);
moduleDecl3 = mock(ModuleDecl.class);
moduleDecl4 = mock(ModuleDecl.class);
when(moduleDecl1.getName()).thenReturn("A");
when(moduleDecl2.getName()).thenReturn("A.A");
when(moduleDecl3.getName()).thenReturn("A.A.A");
when(moduleDecl4.getName()).thenReturn("A.A.A.A");
Model modelMock = mock(Model.class);
when(modelMock.getModuleDecls()).thenReturn(Arrays.asList(moduleDecl1, moduleDecl2, moduleDecl3, moduleDecl4));
when(natureMock.getCompleteModel()).thenReturn(modelMock);
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class MaudeCompiler method compile.
/**
* @param args
* @throws Exception
*/
public int compile(String[] args) throws Exception {
if (verbose)
System.out.println("Generating Maude code...");
final Model model = parse(args);
if (model.hasParserErrors() || model.hasErrors() || model.hasTypeErrors()) {
printErrorMessage();
return 1;
}
PrintStream stream = System.out;
if (outputfile != null) {
stream = new PrintStream(outputfile);
}
InputStream is = ClassLoader.getSystemResourceAsStream(RUNTIME_INTERPRETER_PATH);
if (is == null) {
throw new InternalBackendException("Could not locate abs-interpreter.maude");
}
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
stream.println("*** Generated " + dateFormat.format(new Date()));
ByteStreams.copy(is, stream);
model.generateMaude(stream, module, mainBlock, clocklimit, defaultResources);
if (verbose)
System.out.println("Finished. Start `maude " + outputfile.toString() + "' to run the model.");
return 0;
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class PrettyPrinterBackEnd method compile.
/**
* @param args
* @throws Exception
*/
public int compile(String[] args) throws Exception {
final Model model = parseFiles(parseArgs(args).toArray(new String[0]));
if (keepsugar) {
model.doAACrewrite = false;
model.doForEachRewrite = false;
}
analyzeFlattenAndRewriteModel(model);
if (!force && (model.hasParserErrors() || model.hasErrors() || model.hasTypeErrors())) {
printErrorMessage();
return 1;
}
final PrintStream stream;
final String loc;
if (outputfile != null) {
stream = new PrintStream(outputfile);
loc = outputfile.getAbsolutePath();
} else {
stream = System.out;
loc = "Standard Output Stream";
}
if (verbose) {
System.out.println("Output ABS model source code to " + loc + "...");
}
PrintWriter writer = new PrintWriter(stream, true);
ABSFormatter formatter = new DefaultABSFormatter(writer);
model.doPrettyPrint(writer, formatter);
return 0;
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class TraitTest method removeExistingMethodInClassSucc.
@Test
public void removeExistingMethodInClassSucc() {
Model model = assertParseOk("module M;" + "trait T = {Unit myMethod(){skip;}} " + "class C {uses T removes Unit myMethod();; }");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertNotNull(cls);
assertTrue(cls.getMethods().getNumChild() == 0);
model.applyTraits();
assertTrue(cls.getMethods().getNumChild() == 0);
}
Aggregations