Search in sources :

Example 1 with Program

use of programReduction.Program in project L42 by ElvisResearchGroup.

the class TranslationTest method runTypeSystem.

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

Example 2 with Program

use of programReduction.Program in project L42 by ElvisResearchGroup.

the class MethodPathCloneVisitor method visit.

public ClassB.MethodWithType visit(ClassB.MethodWithType mt) {
    HashMap<String, Ast.Type> aux = this.varEnv;
    Program ep = p;
    for (ClassB cbi : this.getLocator().getCbs()) {
        ep = ep.evilPush(cbi);
    }
    this.varEnv = getVarEnvOf(ep, mt.getMs(), this.getLastCb());
    try {
        return super.visit(mt);
    } finally {
        this.varEnv = aux;
    }
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Program(programReduction.Program) ClassB(ast.ExpCore.ClassB)

Example 3 with Program

use of programReduction.Program in project L42 by ElvisResearchGroup.

the class MethodPathCloneVisitor method visit.

public ClassB.MethodImplemented visit(ClassB.MethodImplemented mi) {
    HashMap<String, Ast.Type> aux = this.varEnv;
    Program ep = p;
    for (ClassB cbi : this.getLocator().getCbs()) {
        ep = ep.evilPush(cbi);
    }
    this.varEnv = getVarEnvOf(ep, mi.getS(), this.getLastCb());
    try {
        return super.visit(mi);
    } finally {
        this.varEnv = aux;
    }
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Program(programReduction.Program) ClassB(ast.ExpCore.ClassB)

Example 4 with Program

use of programReduction.Program 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)

Example 5 with Program

use of programReduction.Program in project L42 by ElvisResearchGroup.

the class Translator method addP.

public static void addP(int level, Program p, Map<String, ClassB> map, Program original) {
    add(level, Collections.emptyList(), p.top(), map, original);
    Program popped;
    try {
        popped = p.pop();
    } catch (EmptyProgram ep) {
        return;
    }
    addP(level + 1, popped, map, original);
}
Also used : Program(programReduction.Program) EmptyProgram(programReduction.Program.EmptyProgram) EmptyProgram(programReduction.Program.EmptyProgram)

Aggregations

Program (programReduction.Program)25 ClassB (ast.ExpCore.ClassB)16 MethodWithType (ast.ExpCore.ClassB.MethodWithType)8 Path (ast.Ast.Path)6 ExpCore (ast.ExpCore)6 ArrayList (java.util.ArrayList)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 MethodSelector (ast.Ast.MethodSelector)5 Type (ast.Ast.Type)5 Functions (auxiliaryGrammar.Functions)5 PData (facade.PData)5 List (java.util.List)5 Optional (java.util.Optional)5 Member (ast.ExpCore.ClassB.Member)4 CloneVisitorWithProgram (coreVisitors.CloneVisitorWithProgram)4 Collectors (java.util.stream.Collectors)4 Doc (ast.Ast.Doc)3 Mdf (ast.Ast.Mdf)3 ErrorMessage (ast.ErrorMessage)3