Search in sources :

Example 91 with ClassB

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

the class SmallStep method meta1.

protected ClassB meta1(Program p, ClassB cb, NestedClass m) {
    log("---meta1--");
    ExpCore e1 = m.getInner();
    //get p'
    try {
        Program p1 = p.evilPush(cb);
        ErrorFormatter.printType(p1);
        //check p'
        //Configuration.typeSystem.checkAll(p1);
        //e1=Norm.of(p1,e1);
        //check e1
        //Configuration.typeSystem.checkMetaExpr(p1.getExecutableStar(),e1);
        //run m.e1-->e2
        ExpCore e2 = executeAtomicStep(new PData(p1), e1, m.getName());
        //if(!(e2 instanceof ClassB)){Configuration.typeSystem.checkMetaExpr(p1.getExecutableStar(),e2);}//TODO: as assert
        ClassB cbRes = cb.withMember(m.withInner(e2));
        //replace cb[m.e2]
        return cbRes;
    } finally {
    }
}
Also used : ExpCore(ast.ExpCore) Program(programReduction.Program) PData(facade.PData) ClassB(ast.ExpCore.ClassB)

Example 92 with ClassB

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

the class Abstract method toAbstract.

public static ClassB toAbstract(ClassB cb, List<Ast.C> path) {
    Errors42.checkExistsPathMethod(cb, path, Optional.empty());
    //check privacy coupled
    ClassB cbClear = cb.onClassNavigateToPathAndDo(path, cbi -> clear(cbi));
    Abstract.checkPrivacyCoupuled(cb, cbClear, path);
    return cbClear;
}
Also used : ClassB(ast.ExpCore.ClassB)

Example 93 with ClassB

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

the class Abstract method findUsage.

private static Set<PathMx> findUsage(List<PathMx> prMeth, ClassB cbClear) {
    Set<PathMx> result = new HashSet<>();
    for (PathMx pmx : prMeth) {
        assert pmx.getPath().outerNumber() == 0;
        UserForMethodResult res = Rename.userForMethod(Resources.getP(), /*wasEmpty*/
        cbClear, pmx.getPath().getCBar(), pmx.getMs(), false);
        result.addAll(res.asClient);
        res.asThis.stream().map(e -> new PathMx(Path.outer(0), e)).forEach(result::add);
    }
    return result;
}
Also used : PathMx(ast.Util.PathMx) Resources(platformSpecific.javaTranslation.Resources) Program(programReduction.Program) Ast(ast.Ast) PathMetaOrNonExistant(ast.ErrorMessage.PathMetaOrNonExistant) ErrorMessage(ast.ErrorMessage) MethodWithType(ast.ExpCore.ClassB.MethodWithType) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IsUsed(is.L42.connected.withSafeOperators.ExtractInfo.IsUsed) ClassB(ast.ExpCore.ClassB) PathMwt(ast.Util.PathMwt) UserForMethodResult(is.L42.connected.withSafeOperators.Rename.UserForMethodResult) NestedClass(ast.ExpCore.ClassB.NestedClass) Path(ast.Ast.Path) Doc(ast.Ast.Doc) Set(java.util.Set) ExpCore(ast.ExpCore) Member(ast.ExpCore.ClassB.Member) Functions(auxiliaryGrammar.Functions) List(java.util.List) PathMx(ast.Util.PathMx) Optional(java.util.Optional) Collections(java.util.Collections) MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) UserForMethodResult(is.L42.connected.withSafeOperators.Rename.UserForMethodResult) HashSet(java.util.HashSet)

Example 94 with ClassB

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

the class AddDocumentation method addDocumentationOnMethod.

public static ClassB addDocumentationOnMethod(Program p, ClassB cb, List<Ast.C> cs, MethodSelector sel, Doc doc) {
    Errors42.checkExistsPathMethod(cb, cs, Optional.of(sel));
    if (cs.isEmpty()) {
        cb = auxAddDocOnMethod(p, cb, sel, doc);
    } else {
        Program p1 = p.evilPush(cb);
        if (cs.size() > 1) {
            p1 = p1.navigate(cs.subList(0, cs.size() - 1));
        }
        Program p2 = p1;
        cb = cb.onClassNavigateToPathAndDo(cs, cbi -> auxAddDocOnMethod(p2, cbi, sel, doc));
    }
    return cb;
}
Also used : Resources(platformSpecific.javaTranslation.Resources) Program(programReduction.Program) Ast(ast.Ast) Doc(ast.Ast.Doc) InvalidMwtAsState(ast.Util.InvalidMwtAsState) Configuration(facade.Configuration) Assertions(tools.Assertions) Member(ast.ExpCore.ClassB.Member) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Collectors(java.util.stream.Collectors) MethodSelector(ast.Ast.MethodSelector) Functions(auxiliaryGrammar.Functions) ArrayList(java.util.ArrayList) List(java.util.List) ClassB(ast.ExpCore.ClassB) Optional(java.util.Optional) Mdf(ast.Ast.Mdf) Program(programReduction.Program)

Example 95 with ClassB

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

the class _Aux method onClassNavigateToPathAndDo.

static ClassB onClassNavigateToPathAndDo(ClassB cb, List<Ast.C> cs, Function<ClassB, ClassB> op) {
    if (cs.isEmpty()) {
        return op.apply(cb);
    }
    List<Member> newMs = new ArrayList<>(cb.getMs());
    Ast.C nName = cs.get(0);
    int index = getIndex(newMs, nName);
    checkIndex(index);
    NestedClass nc = (NestedClass) newMs.get(index);
    if (cs.size() > 1) {
        nc = nc.withInner(onClassNavigateToPathAndDo(wrapCast(nc.getInner()), cs.subList(1, cs.size()), op));
        newMs.set(index, nc);
        return cb.withMs(newMs);
    }
    assert cs.size() == 1;
    ClassB newCb = op.apply(wrapCast(nc.getInner()));
    newMs.set(index, nc.withInner(newCb));
    return cb.withMs(newMs);
}
Also used : Ast(ast.Ast) ArrayList(java.util.ArrayList) NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

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