use of ast.Ast.Position in project L42 by ElvisResearchGroup.
the class L42 method runSlow.
public static ErrorMessage.FinalResult runSlow(String fileName, String code) {
try {
L42.setExecutionStage(ExecutionStage.Parsing);
Expression code1 = Parser.parse(fileName, code);
assert code1 instanceof Expression.ClassB || code1 instanceof Expression.ClassReuse;
L42.setExecutionStage(ExecutionStage.CheckingWellFormedness);
auxiliaryGrammar.WellFormedness.checkAll(code1);
L42.setExecutionStage(ExecutionStage.Desugaring);
Expression code2 = Desugar.of(code1);
assert auxiliaryGrammar.WellFormedness.checkAll(code2);
ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
// L42.usedNames.addAll(CollectDeclaredVarsAndCheckNoDeclaredTwice.of(code2));
//L42.usedNames.addAll(CollectDeclaredClassNamesAndMethodNames.of(code2));
L42.setExecutionStage(ExecutionStage.MetaExecution);
//ClassB result= (ClassB)Executor.stepStar(exe,code3);
//Refresh of position identities, it is used to generate correct Java code.
code3 = (ClassB) code3.accept(new CloneVisitor() {
@Override
public ExpCore visit(ClassB cb) {
Position p = cb.getP();
cb = cb.withP(new Position(p.getFile(), p.getLine1(), p.getPos1(), p.getLine2(), p.getPos2(), p.get_next()));
return super.visit(cb);
}
});
//ClassB result= Configuration.reduction.of(code3);
ClassB result = ProgramReduction.allSteps(code3);
//System.out.println("--------------------------");
return checkFinalError(result);
} finally {
L42.setExecutionStage(ExecutionStage.None);
}
}
use of ast.Ast.Position in project L42 by ElvisResearchGroup.
the class InjectionOnSugar method visit.
@Override
public Expression visit(MCall s) {
ast.Expression receiver = lift(s.getInner());
String name = s.getS().nameToS();
Doc docs = s.getDoc();
List<String> xs = s.getS().getNames();
List<ast.ExpCore> es1 = s.getEs();
List<ast.Expression> es = new ArrayList<ast.Expression>();
for (ast.ExpCore e : es1) {
es.add(lift(e));
}
ast.Ast.Parameters ps = new ast.Ast.Parameters(Optional.<ast.Expression>empty(), xs, es);
Position pos = s.getP();
return new Expression.MCall(receiver, name, docs, ps, pos);
}
use of ast.Ast.Position in project L42 by ElvisResearchGroup.
the class DesugarVars method getDecForVar.
private VarDecXE getDecForVar(Ast.C cName, VarDecXE varDec) {
Type nt = new Type(Mdf.Mutable, Path.outer(0).pushC(cName), Doc.empty());
Position pos = Desugar.getPosition(varDec.getInner());
MCall right = new MCall(new Expression.EPath(pos, nt.getPath()), "#apply", Doc.empty(), Desugar.getPs("inner", new X(pos, varDec.getX())), pos);
String nameZ = Functions.freshName(nt.getPath(), usedVars);
//usedVars.add(nameZ);
return new VarDecXE(false, Optional.of(nt), nameZ, right);
}
use of ast.Ast.Position in project L42 by ElvisResearchGroup.
the class Resources method nameOf.
public static String nameOf(int level, List<Ast.C> cs) {
Program p = Resources.getP();
Position pos = p.get(level).getP();
assert pos != null;
assert pos != Position.noInfo;
//ok, all relevant positions existed together at the same moment.
int hc = System.identityHashCode(pos);
assert !pos.equals(Position.noInfo);
String res = "This" + hc;
//String res="This"+level;
for (Ast.C s : cs) {
res += "." + s;
}
return nameOf(res);
}
use of ast.Ast.Position in project L42 by ElvisResearchGroup.
the class CollapsePositions method accumulateSinglePos.
public static Position accumulateSinglePos(Position p) {
if (p.get_next() == null) {
return p;
}
Position p2 = accumulateSinglePos(p.get_next());
assert p2.get_next() == null;
Position res = accumulatePos(p.with_next(null), p2);
assert res.get_next() == null;
return res;
}
Aggregations