use of ast.Expression.MCall in project L42 by ElvisResearchGroup.
the class Desugar method cfNameK.
//private static final Doc consistentDoc=Doc.factory("@consistent\n");
/* public static List<Member> cfType(ConcreteHeader h,Doc doc){
//doc=Doc.factory("@private");
List<Member> result=new ArrayList<Member>();
MethodWithType k = cfMutK(doc,h);
Mdf nameMdf=mdfForNamedK(h);
if(nameMdf==Mdf.Lent){k=cfLentK(k);}
MethodWithType kOut =cfNameK(doc, nameMdf, h, k.getMs());
result.add(k);
result.add(kOut);
//cfType1(h,doc, result);
for(FieldDec f:h.getFs()){
Doc fDoc=doc.sum(f.getDoc());
cfSetter(h.getP(),f,fDoc,result);
cfExposer(h.getP(),f,fDoc,result);
cfGetter(h.getP(),f,fDoc,result);
}
return result;
}
*/
private static MethodWithType cfNameK(Doc doc, Mdf mdf, ast.Ast.ConcreteHeader h, MethodSelector called) {
List<Type> ts = new ArrayList<Type>();
for (FieldDec fi : h.getFs()) {
Type ti = fi.getT();
ts.add(ti.withDoc(ti.getDoc().sum(fi.getDoc())));
}
MethodSelector ms = called.withName(h.getName());
Type resT = new ast.Ast.Type(mdf, ast.Ast.Path.outer(0), Doc.empty());
MethodType mt = new MethodType(false, ast.Ast.Mdf.Class, ts, resT, Collections.emptyList());
Parameters ps = new Parameters(Optional.empty(), called.getNames(), called.getNames().stream().map(n -> new X(Position.noInfo, n)).collect(Collectors.toList()));
MCall body = new MCall(new Expression.EPath(h.getP(), Path.outer(0)), called.nameToS(), Doc.empty(), ps, h.getP());
return new MethodWithType(doc, ms, mt, Optional.of(body), h.getP());
}
use of ast.Expression.MCall 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.Expression.MCall in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public Expression visit(If s) {
if (!s.get_else().isPresent()) {
return visit(s.with_else(Optional.of(Expression._void.instance)));
}
Position p = s.getP();
if (!(s.getCond() instanceof Ast.Atom)) {
String x = Functions.freshName("cond", usedVars);
return visit(getBlock(p, x, s.getCond(), s.withCond(new X(p, x))));
}
MCall check = getMCall(p, s.getCond(), "#checkTrue", getPs());
Expression.Catch k = getK(p, SignalKind.Exception, "", Type.immVoid, s.get_else().get());
return visit(getBlock(p, check, Collections.singletonList(k), s.getThen()));
}
Aggregations