use of platformSpecific.javaTranslation.Translator 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 platformSpecific.javaTranslation.Translator in project L42 by ElvisResearchGroup.
the class CompiledStep method executeAtomicStep.
@Override
protected ExpCore executeAtomicStep(PData p1, ExpCore _e1, Ast.C nestedName) {
if (!IsCompiled.of(_e1)) {
return step(p1, _e1);
}
return Resources.withPDo(p1, () -> {
ExpCore e1 = NormalizeBlocks.of(_e1);
if (e1 instanceof ExpCore.Signal) {
throw new ErrorMessage.CtxExtractImpossible(e1, null);
}
Translator code = Timer.record("Translator.translateProgram", () -> Translator.translateProgram(p1.p, e1));
try {
L42.compilationRounds++;
System.out.println("Compilation Iteration-- " + nestedName + ":" + L42.compilationRounds + "");
Timer.activate("code.runMap");
Object o = code.runMap();
Timer.deactivate("code.runMap");
System.out.println("Compilation Iteration complete-- " + nestedName + ":" + L42.compilationRounds + "");
assert o instanceof ClassB;
return (ClassB) o;
} catch (Resources.Error err) {
Resources.cacheMessage(err);
return EncodingHelper.wrapResource(err);
} catch (Resources.Exception err) {
Resources.cacheMessage(err);
return EncodingHelper.wrapResource(err);
} catch (Resources.Return err) {
//it can happen if other stuff is wrong, in this way we can see the error.
Resources.cacheMessage(err);
return EncodingHelper.wrapResource(err);
}
});
}
Aggregations