Search in sources :

Example 61 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Functions method encapsulateIn.

public static ClassB.NestedClass encapsulateIn(List<Ast.C> cBar, ClassB elem, Doc doc) {
    //on the call side as in "redirectDefinition"
    assert !cBar.isEmpty();
    List<Ast.C> cBar2 = cBar.subList(1, cBar.size());
    if (cBar2.isEmpty()) {
        return new ClassB.NestedClass(doc, cBar.get(0), elem, null);
    }
    List<Member> ms = new ArrayList<>();
    ms.add(encapsulateIn(cBar2, elem, doc));
    ClassB cb = ClassB.membersClass(ms, Position.noInfo, elem.getPhase());
    return new ClassB.NestedClass(Doc.empty(), cBar.get(0), cb, null);
}
Also used : C(ast.Ast.C) ArrayList(java.util.ArrayList) ClassB(ast.ExpCore.ClassB)

Example 62 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Functions method originDecOf.

public static Path originDecOf(Program p, MethodSelector ms, ClassB cb) /*normalized*/
{
    assert cb.getPhase().subtypeEq(Phase.Norm);
    for (Path pi : cb.getSuperPaths()) {
        ClassB cbi = p.extractClassB(pi);
        MethodWithType m = (MethodWithType) cbi._getMember(ms);
        if (m != null && !m.getMt().isRefine()) {
            return pi;
        }
    }
    throw Assertions.codeNotReachable();
}
Also used : Path(ast.Ast.Path) ClassB(ast.ExpCore.ClassB)

Example 63 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class TestTypeSystemOk method runTypeSystem.

static ClassB runTypeSystem(String scb1) {
    TestHelper.configureForTest();
    ClassB cb1 = (ClassB) Desugar.of(Parser.parse(null, scb1)).accept(new InjectionOnCore());
    Program p = Program.emptyLibraryProgram();
    return TypeSystem.instance().topTypeLib(Phase.Coherent, p.evilPush(cb1));
}
Also used : Program(programReduction.Program) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 64 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class TestCloneWithPath method test.

@Test
public void test() {
    TestHelper.configureForTest();
    ClassB cb1 = getClassB("cb1", _cb1);
    ClassB expected = getClassB("expected", _expected);
    ClassB result = (ClassB) cb1.accept(new PathAnnotateClass());
    TestHelper.assertEqualExp(expected, result);
}
Also used : PathAnnotateClass(coreVisitors.PathAnnotateClass) TestHelper.getClassB(helpers.TestHelper.getClassB) ClassB(ast.ExpCore.ClassB) Test(org.junit.Test)

Example 65 with ClassB

use of ast.ExpCore.ClassB 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)

Aggregations

ClassB (ast.ExpCore.ClassB)107 ArrayList (java.util.ArrayList)33 Path (ast.Ast.Path)30 ExpCore (ast.ExpCore)25 Member (ast.ExpCore.ClassB.Member)25 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)20 Program (programReduction.Program)20 Ast (ast.Ast)19 MethodWithType (ast.ExpCore.ClassB.MethodWithType)19 MethodSelector (ast.Ast.MethodSelector)18 NestedClass (ast.ExpCore.ClassB.NestedClass)18 List (java.util.List)17 ActionType (platformSpecific.fakeInternet.ActionType)16 Doc (ast.Ast.Doc)12 Type (ast.Ast.Type)12 ErrorMessage (ast.ErrorMessage)12 Optional (java.util.Optional)10 C (ast.Ast.C)9 MethodType (ast.Ast.MethodType)8 Phase (ast.ExpCore.ClassB.Phase)8