Search in sources :

Example 16 with Program

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
}
Also used : Program(programReduction.Program) MethodWithType(ast.ExpCore.ClassB.MethodWithType) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore) Test(org.junit.Test)

Example 17 with Program

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);
}
Also used : ExpCore(ast.ExpCore) Program(programReduction.Program) Translator(platformSpecific.javaTranslation.Translator) PData(facade.PData) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 18 with Program

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();
}
Also used : Program(programReduction.Program) CloneVisitorWithProgram(coreVisitors.CloneVisitorWithProgram) ArrayList(java.util.ArrayList)

Example 19 with Program

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));
        }
    };
}
Also used : Program(programReduction.Program) CloneVisitorWithProgram(coreVisitors.CloneVisitorWithProgram)

Example 20 with Program

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);
}
Also used : Program(programReduction.Program) CloneVisitorWithProgram(coreVisitors.CloneVisitorWithProgram) Ast(ast.Ast) Position(ast.Ast.Position) C(ast.Ast.C)

Aggregations

Program (programReduction.Program)25 ClassB (ast.ExpCore.ClassB)16 MethodWithType (ast.ExpCore.ClassB.MethodWithType)8 Path (ast.Ast.Path)6 ExpCore (ast.ExpCore)6 ArrayList (java.util.ArrayList)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 MethodSelector (ast.Ast.MethodSelector)5 Type (ast.Ast.Type)5 Functions (auxiliaryGrammar.Functions)5 PData (facade.PData)5 List (java.util.List)5 Optional (java.util.Optional)5 Member (ast.ExpCore.ClassB.Member)4 CloneVisitorWithProgram (coreVisitors.CloneVisitorWithProgram)4 Collectors (java.util.stream.Collectors)4 Doc (ast.Ast.Doc)3 Mdf (ast.Ast.Mdf)3 ErrorMessage (ast.ErrorMessage)3