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;
}
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);
}
}
}
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);
}
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;
}
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;
}
}
Aggregations