use of programReduction.Program in project L42 by ElvisResearchGroup.
the class TestCoherentClass method testCoherence.
@Test
public void testCoherence() {
ClassB cb1 = (ClassB) (Parser.parse(null, e).accept(new InjectionOnCore()));
Program p = Program.emptyLibraryProgram();
MethodWithType mwt = (MethodWithType) cb1.getMs().get(0);
//boolean res=Functions.coherent(p, mdf, path, mwt);
//Assert.assertEquals(res,ok);
//TODO: disabled for now
}
use of programReduction.Program 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 programReduction.Program in project L42 by ElvisResearchGroup.
the class Resources method pKeys.
public static int[] pKeys() {
List<Integer> res = new ArrayList<>();
Program p = getP();
while (true) {
res.add(p.top().getUniqueId());
try {
p = p.pop();
} catch (RuntimeException rte) {
break;
}
}
return res.stream().mapToInt(Integer::intValue).toArray();
}
use of programReduction.Program in project L42 by ElvisResearchGroup.
the class Resources method fromHash.
public static Revertable fromHash(int hash, String path) {
return new platformSpecific.javaTranslation.Resources.Revertable() {
public ast.ExpCore revert() {
Program p = getP();
int dept = 0;
while (System.identityHashCode(p.top().getP()) != hash) {
dept++;
p = p.pop();
}
return ExpCore.EPath.wrap(ast.Ast.Path.parse("This" + dept + path));
}
};
}
use of programReduction.Program in project L42 by ElvisResearchGroup.
the class Resources method nameOf.
public static String nameOf(int level, List<Ast.C> cs) {
Program p = Resources.getP();
Position pos = p.get(level).getP();
assert pos != null;
assert pos != Position.noInfo;
//ok, all relevant positions existed together at the same moment.
int hc = System.identityHashCode(pos);
assert !pos.equals(Position.noInfo);
String res = "This" + hc;
//String res="This"+level;
for (Ast.C s : cs) {
res += "." + s;
}
return nameOf(res);
}
Aggregations