use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class ExtractCtxUpToX method visit.
public Ctx<Block> visit(MCall s) {
if (IsCtx.of(s.getInner())) {
return lift(s.getInner().accept(this), ctx -> s.withInner(ctx));
}
for (ExpCore ei : s.getEs()) {
if (!IsCtx.of(ei)) {
continue;
}
return lift(ei.accept(this), ctx -> {
List<ExpCore> es = new ArrayList<ExpCore>(s.getEs());
es.set(es.indexOf(ei), ctx);
return s.withEs(es);
});
}
throw Assertions.codeNotReachable();
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class ExtractCtxVal method visit.
public Ctx<Redex> visit(Using s) {
Ctx<Redex> res = checkRedex(s);
if (res != null) {
return res;
}
for (ExpCore ei : s.getEs()) {
if (IsValue.of(p, ei)) {
continue;
}
return lift(ei.accept(this), ctx -> {
List<ExpCore> es = new ArrayList<ExpCore>(s.getEs());
es.set(es.indexOf(ei), ctx);
return s.withEs(es);
});
}
return lift(s.getInner().accept(this), s::withInner);
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class TestShortPrograms method tp.
public static void tp(String... code) {
TestHelper.configureForTest();
FinalResult res0;
try {
res0 = facade.L42.runSlow(null, TestHelper.multiLine(code));
} catch (ErrorMessage msg) {
ErrorFormatter.topFormatErrorMessage(msg);
throw msg;
}
ClassB res = res0.getTopLevelProgram();
ClassB.NestedClass nc = (ClassB.NestedClass) res.getMs().get(res.getMs().size() - 1);
ExpCore ee2 = Desugar.of(Parser.parse(null, "{//@exitStatus\n//0\n\n}")).accept(new InjectionOnCore());
TestHelper.assertEqualExp(nc.getInner(), ee2);
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class TranslationTest method tester.
public void tester(String cbStr, String eStr, String nameRes) {
TestHelper.configureForTest();
Program p = runTypeSystem(cbStr);
ExpCore _e = Desugar.of(Parser.parse(null, eStr)).accept(new InjectionOnCore());
ExpCore e = newTypeSystem.TypeSystem.instance().topTypeExpVoid(p, _e);
Translator code = Resources.withPDo(new PData(p), () -> Translator.translateProgram(p, e));
System.out.println(code);
Object o = Resources.withPDo(new PData(p), () -> code.runMap());
Assert.assertEquals(o.getClass().getName(), nameRes);
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class EvilPushed method push.
default default Program push(Ast.C c) {
CtxL splitted = CtxL.split(this.top(), c);
ExpCore holeP = splitted.originalHole();
assert holeP instanceof ClassB;
return new PushedProgram((ClassB) holeP, splitted, this);
}
Aggregations