use of programReduction.Program in project L42 by ElvisResearchGroup.
the class Executor method meta1Prop.
protected ClassB meta1Prop(Program p, ClassB cb, NestedClass m) {
log("---meta1Prop--");
//get cb-->ct
//get p'
Program p1 = p.evilPush(cb);
//extract e
ExpCore e = m.getInner();
//extract cb
Ctx<ClassB> ctxC = ExtractCtxCompiled.of(e);
//run cb1-->cb2
ClassB cb2 = (ClassB) step(new PData(p1), ctxC.hole);
ExpCore e2 = ReplaceCtx.of(ctxC.ctx, cb2);
//compose cb with new member
return cb.withMember(m.withInner(e2));
}
use of programReduction.Program in project L42 by ElvisResearchGroup.
the class TestHelper method getProgram.
public static Program getProgram(/*List<Path> paths,*/
String[] code) {
Program p0 = Program.emptyLibraryProgram();
Integer outerCount = code.length;
for (String s : code) {
Expression e = Parser.parse("This" + outerCount, s);
--outerCount;
ClassB ec = (ClassB) Desugar.of(e).accept(new InjectionOnCore());
p0 = p0.evilPush(ec);
}
return p0;
}
use of programReduction.Program 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 programReduction.Program 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;
}
}
use of programReduction.Program in project L42 by ElvisResearchGroup.
the class TestLibrary method test.
@Test()
public void test() {
Program p = TestProgram.p(sProg);
ClassB cb1Pre = (ClassB) Desugar.of(Parser.parse(null, s1)).accept(new InjectionOnCore());
cb1Pre = new programReduction.Norm().norm(p.evilPush(cb1Pre));
TOut out;
try {
out = TypeSystem.instance().type(TIn.top(Phase.Coherent, p, cb1Pre));
} catch (NotOkToStar coh) {
assert s2 == ErrorKind.LibraryNotCoherent;
return;
}
if (s2 instanceof ErrorKind) {
assert !out.isOk();
ErrorKind kind = out.toError().kind;
assert kind == s2;
} else {
assert out.isOk() : "";
ClassB cb1 = (ClassB) out.toOk().annotated;
ClassB cbExpected = s2 == sameAsFormer ? cb1Pre : (ClassB) Desugar.of(Parser.parse(null, (String) s2)).accept(new InjectionOnCore());
TestHelper.assertEqualExp(cb1, cbExpected);
}
}
Aggregations