use of abs.frontend.ast.Model in project abstools by abstools.
the class CaseStudyTypeChecking method assertParseFilesOk.
protected Model assertParseFilesOk(String srcFolder, Config... config) throws IOException, WrongProgramArgumentException, InternalBackendException {
File srcFolderF = new File(srcFolder);
assertTrue(srcFolder, srcFolderF.exists());
Main main = new Main();
main.setWithStdLib(isSet(WITH_STD_LIB, config));
Model m = main.parseFiles(findAbsFiles(srcFolderF).toArray(new String[0]));
if (m != null) {
m.evaluateAllProductDeclarations();
if (m.hasParserErrors())
Assert.fail(m.getParserErrors().get(0).getMessage());
int numSemErrs = m.getErrors().getErrorCount();
StringBuffer errs = new StringBuffer("Semantic errors: " + numSemErrs + "\n");
if (numSemErrs > 0) {
for (SemanticCondition error : m.getErrors()) errs = errs.append(error.getHelpMessage() + "\n");
fail("Failed to parse: " + srcFolder + "\n" + errs.toString());
} else if (isSet(TYPE_CHECK, config)) {
SemanticConditionList l = m.typeCheck();
if (l.containsErrors()) {
for (SemanticCondition error : l) errs = errs.append(error.getHelpMessage() + "\n");
fail("Failed to typecheck: " + srcFolder + "\n" + errs.toString());
}
}
}
return m;
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class ExamplesTypeChecking method parse.
@Override
protected Model parse(String input) throws Exception {
Model m = assertTypeCheckFileOk(input, true);
if (product != null) {
m.collapseTraitModifiers();
m.flattenForProduct(product);
final SemanticConditionList errors = m.getErrors();
if (errors.containsErrors())
onError(errors.getFirstError().getMessage());
m.typeCheck(errors);
if (errors.containsErrors())
onError(errors.getFirstError().getMessage());
}
return m;
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class LocationTypeTests method testAwaitFailRewriteOff.
@Test
public void testAwaitFailRewriteOff() {
LocationType lt = LocationType.INFER;
Model.doAACrewrite = false;
Model m = assertParseOkStdLib("interface T { Unit foo(); } class C { T t = null; Unit bar() { await t!foo(); }}");
// This line is essential to trigger the NPE!
assertFalse(m.hasErrors());
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(m);
ltie.setDefaultType(lt);
ltie.setLocationTypingPrecision(LocationTypingPrecision.CLASS_LOCAL_FAR);
m.registerTypeSystemExtension(ltie);
m.getErrors();
SemanticConditionList e = m.typeCheck();
Model.doAACrewrite = true;
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class LocationTypeTests method testInferenceRetypeChecking.
@Test
public void testInferenceRetypeChecking() {
String code = "interface I { Unit m(); } { [Far] I i; I j; i = j; j.m(); }";
Model m = assertParseOkStdLib(code);
LocationTypeExtension te = new LocationTypeExtension(m);
m.registerTypeSystemExtension(te);
SemanticConditionList e = m.typeCheck();
m.typeCheck(new SemanticConditionList());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class NegativeTypeCheckerTests method negTestError.
@Test
public void negTestError() {
Model m = assertParseOkStdLib(" { Bool b = !5; }");
assertEquals(ErrorMessage.EXPECTED_TYPE, m.typeCheck().getFirstError().msg);
}
Aggregations