Search in sources :

Example 36 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class TestHelper method getClassB.

public static ClassB getClassB(String source, String e1) {
    Expression code1 = Parser.parse("GeneratedByTestHelper_" + source, e1);
    auxiliaryGrammar.WellFormedness.checkAll(code1);
    Expression code2 = Desugar.of(code1);
    assert auxiliaryGrammar.WellFormedness.checkAll(code2);
    ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
    assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
    return code3;
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) ClassB(ast.ExpCore.ClassB) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 37 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class TestAddKs method test.

@Test
public void test() {
    TestHelper.configureForTest();
    ClassB cb1 = getClassB("cb1", _cb1);
    ClassB expected = getClassB("expected", _expected);
    if (!isError) {
        ClassB res = MakeKs.makeKs(cb1, Collections.emptyList(), Arrays.asList(_fields), _mutK, _lentK, _readK, _immK, true);
        TestHelper.assertEqualExp(expected, res);
    } else {
        try {
            MakeKs.makeKs(cb1, Collections.emptyList(), Arrays.asList(_fields), _mutK, _lentK, _readK, _immK, true);
            fail("error expected");
        } catch (Resources.Error err) {
            ClassB res = (ClassB) err.unbox;
            TestHelper.assertEqualExp(expected, res);
        }
    }
}
Also used : Resources(platformSpecific.javaTranslation.Resources) TestHelper.getClassB(helpers.TestHelper.getClassB) ClassB(ast.ExpCore.ClassB) Test(org.junit.Test)

Example 38 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class TestPush method test.

@Test
public void test() {
    ClassB cb1 = getClassB(e1);
    ClassB cb2 = getClassB(e2);
    ClassB res = Push.pushOne(cb1, C.of(e3));
    TestHelper.assertEqualExp(res, cb2);
}
Also used : ClassB(ast.ExpCore.ClassB) TestHelper.getClassB(helpers.TestHelper.getClassB) Test(org.junit.Test)

Example 39 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class RenameAlsoDefinition method potentiallyRenameMethodImplementedHeader.

private MethodWithType potentiallyRenameMethodImplementedHeader(MethodWithType mi) {
    assert mi.getMt().isRefine();
    ClassB currentCb = this.getLocator().getLastCb();
    Program ep = p;
    for (ClassB cbi : this.getLocator().getCbs()) {
        ep = ep.evilPush(cbi);
    }
    //List<Path> supers = Program.getAllSupertypes(ep, currentCb);
    Path origin = Functions.originDecOf(ep, mi.getMs(), currentCb);
    Locator original = this.getLocator().copy();
    boolean isOut = original.moveInPath(origin);
    if (isOut) {
        return mi;
    }
    for (Locator pMx : maps.selectors) {
        assert pMx.kind() == Kind.Method;
        MethodSelector s = pMx.getLastMember().match(nc -> {
            throw Assertions.codeNotReachable();
        }, mimpl -> mimpl.getS(), mt -> mt.getMs());
        if (!mi.getMs().equals(s)) {
            continue;
        }
        Locator renamed = pMx.copy();
        renamed.toFormerNodeLocator();
        if (!original.equals(renamed)) {
            return mi;
        }
        MethodSelector ms2 = (MethodSelector) pMx.getAnnotation();
        return mi.withMs(ms2);
    }
    return mi;
}
Also used : Path(ast.Ast.Path) Locator(auxiliaryGrammar.Locator) MethodSelector(ast.Ast.MethodSelector) Program(programReduction.Program) ClassB(ast.ExpCore.ClassB)

Example 40 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Executor method stepStar.

public static ExpCore stepStar(Executor executer, ExpCore e) {
    final Program emptyP = Program.emptyLibraryProgram();
    int iteration = 0;
    dbgRecordNext(e);
    executer.log("--------------------" + (iteration += 1));
    //TestHelper.dbgCompact(e);
    try {
        while (true) {
            assert coreVisitors.CheckNoVarDeclaredTwice.of((ClassB) e);
            e = NormalizeBlocks.of(e);
            e = executer.step(new PData(emptyP), e);
            dbgRecordNext(e);
            assert coreVisitors.CheckNoVarDeclaredTwice.of((ClassB) e);
            executer.log("--------------------" + (iteration += 1));
        //TestHelper.dbgCompact(e);
        }
    }//catch(ErrorMessage.NormalForm mess){ return mess.getE();}
     catch (ErrorMessage.CtxExtractImpossible mess) {
        assert e instanceof ClassB;
        if (!L42.trustPluginsAndFinalProgram) {
            ClassB ct = (ClassB) e;
            Program p1 = emptyP.evilPush(ct);
            //I think this is all old code?
            assert false;
        //Configuration.typeSystem.checkCt( emptyP, ct);
        /*if(!p1.checkComplete()){//also check is star
        throw new ErrorMessage.MalformedFinalResult(ct,
          "Some class can not be completely typed as is still incomplete or refers to incomplete classes"
            +ErrorFormatter.reportPlaceOfMetaError(p1,ct)
            );
        }*/
        }
        return e;
    }
}
Also used : Program(programReduction.Program) ErrorMessage(ast.ErrorMessage) PData(facade.PData) ClassB(ast.ExpCore.ClassB)

Aggregations

ClassB (ast.ExpCore.ClassB)107 ArrayList (java.util.ArrayList)33 Path (ast.Ast.Path)30 ExpCore (ast.ExpCore)25 Member (ast.ExpCore.ClassB.Member)25 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)20 Program (programReduction.Program)20 Ast (ast.Ast)19 MethodWithType (ast.ExpCore.ClassB.MethodWithType)19 MethodSelector (ast.Ast.MethodSelector)18 NestedClass (ast.ExpCore.ClassB.NestedClass)18 List (java.util.List)17 ActionType (platformSpecific.fakeInternet.ActionType)16 Doc (ast.Ast.Doc)12 Type (ast.Ast.Type)12 ErrorMessage (ast.ErrorMessage)12 Optional (java.util.Optional)10 C (ast.Ast.C)9 MethodType (ast.Ast.MethodType)8 Phase (ast.ExpCore.ClassB.Phase)8