Search in sources :

Example 1 with MethodImplemented

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

the class UsedPaths method usedInnerM.

private static Paths usedInnerM(Member m, Phase phase0) {
    if (m instanceof NestedClass) {
        NestedClass nc = (NestedClass) m;
        return usedInnerL((ClassB) nc.getInner(), Collections.emptyList(), phase0).pop();
    }
    List<Path> result1;
    List<ClassB> l1n = Collections.emptyList();
    if (m instanceof MethodWithType) {
        MethodWithType mwt = (MethodWithType) m;
        result1 = CollectPaths0.of(mwt);
        if (phase0 == Phase.Typed && mwt.get_inner().isPresent()) {
            l1n = CollectClassBs0.of(m.getInner());
        }
    } else {
        assert m instanceof MethodImplemented;
        result1 = CollectPaths0.of(m.getInner());
    }
    Paths result2 = Paths.reorganize(result1);
    Paths acc = Paths.empty();
    for (ClassB li : l1n) {
        acc = acc.union(usedInnerL(li, Collections.emptyList(), phase0));
    }
    return result2.union(acc.pop());
}
Also used : Path(ast.Ast.Path) MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) NestedClass(ast.ExpCore.ClassB.NestedClass) MethodWithType(ast.ExpCore.ClassB.MethodWithType) ClassB(ast.ExpCore.ClassB)

Example 2 with MethodImplemented

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

the class SumMethods method checkConflict.

private static void checkConflict(List<Ast.C> path, MethodSelector mRes, ClassB pathCb, MethodWithType mwtU) {
    /*for(PathMwt e:pathCb.getStage().getInherited()){
      if(e.getMwt().getMs().equals(mRes)){//method declared in an interface and not implemented
        MethodWithType mtConflict=e.getMwt();
        mtConflict=From.from(mtConflict, From.fromP(e.getOriginal(),Path.outer(0,path)));
        Errors42.checkMethodClash(path, mwtU,mtConflict,false);
        }
    }*/
    //unneded for normalized classb
    Optional<Member> optConflict = Functions.getIfInDom(pathCb.getMs(), mRes);
    if (optConflict.isPresent()) {
        if (optConflict.get() instanceof MethodImplemented) {
            throw Errors42.errorMethodClash(path, mwtU, optConflict.get(), true, Collections.emptyList(), true, true, false);
        }
        MethodWithType mwtC = (MethodWithType) optConflict.get();
        Errors42.checkMethodClash(path, mwtU, mwtC, false);
    }
}
Also used : MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Member(ast.ExpCore.ClassB.Member)

Example 3 with MethodImplemented

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

the class _Sum method matchMt.

private static Void matchMt(List<Ast.C> pathForError, MethodWithType mwta, List<Member> ms, Member mb) {
    if (mb instanceof MethodImplemented) {
        throw Errors42.errorMethodClash(pathForError, mwta, mb, false, Collections.emptyList(), false, false, false);
    }
    MethodWithType mwtb = (MethodWithType) mb;
    Errors42.checkMethodClash(pathForError, mwta, mwtb, false);
    ms.add(_Sum.sumMethod(mwta, mwtb));
    return null;
}
Also used : MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) MethodWithType(ast.ExpCore.ClassB.MethodWithType)

Example 4 with MethodImplemented

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

the class _Aux method isConsistent.

static boolean isConsistent(ClassB cb) {
    int countWalkBy = 0;
    HashSet<String> keys = new HashSet<String>();
    for (Member m : cb.getMs()) {
        if (m instanceof MethodWithType) {
            MethodWithType mwt = (MethodWithType) m;
            String key = mwt.getMs().toString();
            assert !keys.contains(key);
            keys.add(key);
        //assert mwt.getMt().getTDocs().size() == mwt.getMt().getTs().size();
        }
        if (m instanceof NestedClass) {
            NestedClass nc = (NestedClass) m;
            String key = nc.getName().toString();
            assert !keys.contains(key);
            keys.add(key);
            if (nc.getInner() instanceof ExpCore.WalkBy) {
                countWalkBy += 1;
            }
        }
        if (m instanceof MethodImplemented) {
            MethodImplemented mi = (MethodImplemented) m;
            String key = mi.getS().toString();
            assert !keys.contains(key);
            keys.add(key);
        }
    }
    //     || ((cb.getPhase()!=ast.ExpCore.ClassB.Phase.None && !cb.getUniqueId().isEmpty()) );
    assert countWalkBy <= 1 : cb;
    return true;
}
Also used : MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) NestedClass(ast.ExpCore.ClassB.NestedClass) ToString(lombok.ToString) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Member(ast.ExpCore.ClassB.Member) HashSet(java.util.HashSet)

Example 5 with MethodImplemented

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

the class MethodPathCloneVisitor method getMt.

private Ast.MethodType getMt(Program p, MethodSelector s, ClassB cb) {
    assert p.top() == cb;
    Optional<Member> mOpt = Functions.getIfInDom(cb.getMs(), s);
    assert mOpt.isPresent();
    if (mOpt.get() instanceof MethodWithType) {
        return ((MethodWithType) mOpt.get()).getMt();
    }
    assert mOpt.get() instanceof MethodImplemented;
    MethodWithType mwt = (MethodWithType) cb._getMember(s);
    return mwt.getMt();
}
Also used : MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Member(ast.ExpCore.ClassB.Member)

Aggregations

MethodImplemented (ast.ExpCore.ClassB.MethodImplemented)5 MethodWithType (ast.ExpCore.ClassB.MethodWithType)5 Member (ast.ExpCore.ClassB.Member)3 NestedClass (ast.ExpCore.ClassB.NestedClass)2 Path (ast.Ast.Path)1 ClassB (ast.ExpCore.ClassB)1 HashSet (java.util.HashSet)1 ToString (lombok.ToString)1