use of org.abs_models.frontend.typechecker.locationtypes.LocationTypeExtension in project abstools by abstools.
the class ABSTest method assertParse.
protected static Model assertParse(String s, Config... config) {
String preamble = "module UnitTest; export *; ";
preamble = preamble + " import * from ABS.StdLib;";
if (!isSet(WITHOUT_MODULE_NAME, config))
s = preamble + s;
try {
Model p = parseString(s);
if (isSet(WITHOUT_DESUGARING_AFTER_TYPECHECK, config)) {
p.doAACrewrite = false;
p.doForEachRewrite = false;
}
if (isSet(EXPECT_PARSE_ERROR, config)) {
if (!p.hasParserErrors())
fail("Expected to find parse error");
} else {
if (p.hasParserErrors()) {
fail("Failed to parse: " + s + "\n" + p.getParserErrors().get(0).getMessage());
} else {
// make ProductDecl.getProduct() not return null
p.evaluateAllProductDeclarations();
if (isSet(TYPE_CHECK, config)) {
// copy other choice parts of Main.analyzeFlattenAndRewriteModel
p.flattenTraitOnly();
p.collapseTraitModifiers();
p.expandPartialFunctions();
p.expandForeachLoops();
p.expandAwaitAsyncCalls();
if (isSet(WITH_LOC_INF, config)) {
LocationTypeExtension lte = new LocationTypeExtension(p);
p.registerTypeSystemExtension(lte);
}
SemanticConditionList l = p.typeCheck();
if (isSet(EXPECT_TYPE_ERROR, config)) {
if (!l.containsErrors()) {
fail("Expected type errors, but none appeared");
}
} else {
if (l.containsErrors()) {
fail("Failed to typecheck: " + s + "\n" + l.getFirstError().getMessage());
}
}
}
}
}
return p;
} catch (Exception t) {
// TODO: remove
throw new RuntimeException(t);
}
}
Aggregations