Search in sources :

Example 41 with ExpCore

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();
}
Also used : ExpCore(ast.ExpCore) ArrayList(java.util.ArrayList)

Example 42 with ExpCore

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);
}
Also used : ExpCore(ast.ExpCore) Assertions(tools.Assertions) Functions(auxiliaryGrammar.Functions) Redex(ast.Redex) ArrayList(java.util.ArrayList)

Example 43 with ExpCore

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);
}
Also used : ExpCore(ast.ExpCore) FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 44 with ExpCore

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

Example 45 with ExpCore

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);
}
Also used : ExpCore(ast.ExpCore) ClassB(ast.ExpCore.ClassB)

Aggregations

ExpCore (ast.ExpCore)62 ArrayList (java.util.ArrayList)25 ClassB (ast.ExpCore.ClassB)18 Member (ast.ExpCore.ClassB.Member)11 MethodWithType (ast.ExpCore.ClassB.MethodWithType)10 Expression (ast.Expression)10 Block (ast.ExpCore.Block)9 MethodType (ast.Ast.MethodType)8 Doc (ast.Ast.Doc)7 Path (ast.Ast.Path)7 Assertions (tools.Assertions)7 MethodSelector (ast.Ast.MethodSelector)6 Position (ast.Ast.Position)6 Program (programReduction.Program)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Type (ast.Ast.Type)5 ErrorMessage (ast.ErrorMessage)5 CloneVisitor (coreVisitors.CloneVisitor)5 List (java.util.List)5