Search in sources :

Example 1 with NormImpossible

use of ast.ErrorMessage.NormImpossible in project L42 by ElvisResearchGroup.

the class MethodPathCloneVisitor method visit.

public ExpCore visit(MCall s) {
    Program ep = p;
    for (ClassB cbi : this.getLocator().getCbs()) {
        if (cbi != null) {
            ep = ep.evilPush(cbi);
        }
    }
    MethodSelector ms = s.getS();
    Path guessed = null;
    try {
        TIn in = TIn.top(Phase.Typed, ep, s.getInner());
        in = in.withG(varEnv.entrySet().stream().collect(Collectors.toMap(me -> me.getKey(), me -> new java.util.AbstractMap.SimpleEntry<>(false, me.getValue()))));
        Type tGuessed = newTypeSystem.GuessTypeCore._of(in.p, in, s.getInner());
        if (tGuessed == null) {
            return super.visit(s);
        }
        guessed = tGuessed.getPath();
        assert guessed != null;
    } catch (NormImpossible ignored) {
        return super.visit(s);
    }
    MethodSelector ms2 = visitMS(ms, guessed);
    if (ms2.equals(ms)) {
        return super.visit(s);
    }
    s = new MCall(s.getInner(), ms2, s.getDoc(), s.getEs(), s.getP());
    return super.visit(s);
}
Also used : Path(ast.Ast.Path) From(coreVisitors.From) GuessTypeCore(newTypeSystem.GuessTypeCore) Program(programReduction.Program) Ast(ast.Ast) MCall(ast.ExpCore.MCall) Map(tools.Map) Type(ast.Ast.Type) Configuration(facade.Configuration) HashMap(java.util.HashMap) Assertions(tools.Assertions) MethodWithType(ast.ExpCore.ClassB.MethodWithType) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) ClassB(ast.ExpCore.ClassB) NormImpossible(ast.ErrorMessage.NormImpossible) Norm(programReduction.Norm) On(ast.ExpCore.Block.On) Path(ast.Ast.Path) Doc(ast.Ast.Doc) Phase(ast.ExpCore.ClassB.Phase) MethodSelectorX(ast.Ast.MethodSelectorX) ExpCore(ast.ExpCore) Member(ast.ExpCore.ClassB.Member) Collectors(java.util.stream.Collectors) Block(ast.ExpCore.Block) Functions(auxiliaryGrammar.Functions) List(java.util.List) TIn(newTypeSystem.TIn) Optional(java.util.Optional) Dec(ast.ExpCore.Block.Dec) Collections(java.util.Collections) MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) MethodSelector(ast.Ast.MethodSelector) Type(ast.Ast.Type) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Program(programReduction.Program) MCall(ast.ExpCore.MCall) TIn(newTypeSystem.TIn) NormImpossible(ast.ErrorMessage.NormImpossible) ClassB(ast.ExpCore.ClassB)

Aggregations

Ast (ast.Ast)1 Doc (ast.Ast.Doc)1 MethodSelector (ast.Ast.MethodSelector)1 MethodSelectorX (ast.Ast.MethodSelectorX)1 Path (ast.Ast.Path)1 Type (ast.Ast.Type)1 NormImpossible (ast.ErrorMessage.NormImpossible)1 ExpCore (ast.ExpCore)1 Block (ast.ExpCore.Block)1 Dec (ast.ExpCore.Block.Dec)1 On (ast.ExpCore.Block.On)1 ClassB (ast.ExpCore.ClassB)1 Member (ast.ExpCore.ClassB.Member)1 MethodImplemented (ast.ExpCore.ClassB.MethodImplemented)1 MethodWithType (ast.ExpCore.ClassB.MethodWithType)1 Phase (ast.ExpCore.ClassB.Phase)1 MCall (ast.ExpCore.MCall)1 Functions (auxiliaryGrammar.Functions)1 From (coreVisitors.From)1 Configuration (facade.Configuration)1