Search in sources :

Example 1 with LocationTypeExtension

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);
    }
}
Also used : SemanticConditionList(org.abs_models.frontend.analyser.SemanticConditionList) LocationTypeExtension(org.abs_models.frontend.typechecker.locationtypes.LocationTypeExtension) Model(org.abs_models.frontend.ast.Model) IOException(java.io.IOException) WrongProgramArgumentException(org.abs_models.common.WrongProgramArgumentException) InternalBackendException(org.abs_models.backend.common.InternalBackendException) DeltaModellingException(org.abs_models.frontend.delta.DeltaModellingException)

Aggregations

IOException (java.io.IOException)1 InternalBackendException (org.abs_models.backend.common.InternalBackendException)1 WrongProgramArgumentException (org.abs_models.common.WrongProgramArgumentException)1 SemanticConditionList (org.abs_models.frontend.analyser.SemanticConditionList)1 Model (org.abs_models.frontend.ast.Model)1 DeltaModellingException (org.abs_models.frontend.delta.DeltaModellingException)1 LocationTypeExtension (org.abs_models.frontend.typechecker.locationtypes.LocationTypeExtension)1