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);
}
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;
}
}
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;
}
}
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);
}
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);
}
Aggregations