Search in sources :

Example 6 with Parameters

use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.

the class Desugar method visit1Step.

public MCall visit1Step(Literal s) {
    //(b=r.builder() b.a() b.b() b.c() .... b)
    List<VarDec> vd = new ArrayList<>();
    Expression k = getMCall(s.getP(), s.getReceiver(), "#builder", getPs());
    String x = Functions.freshName("b", usedVars);
    X b = new X(s.getP(), x);
    vd.add(new VarDecXE(false, Optional.empty(), x, k));
    for (char ch : s.getInner().toCharArray()) {
        String name = Character.toString(ch);
        if (!Character.isAlphabetic(ch) && !Character.isDigit(ch)) {
            name = desugarSymbol(name);
        }
        vd.add(new VarDecE(getMCall(s.getP(), b, "#" + name, getPs())));
    }
    Expression inner = getBlock(s.getP(), vd, b);
    Parameters ps = new Parameters(Optional.empty(), Collections.singletonList("builder"), Collections.singletonList(inner));
    return getMCall(s.getP(), s.getReceiver(), "#from", ps);
}
Also used : Parameters(ast.Ast.Parameters) Expression(ast.Expression) VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) X(ast.Expression.X) MethodSelectorX(ast.Ast.MethodSelectorX) VarDecE(ast.Ast.VarDecE) VarDecXE(ast.Ast.VarDecXE)

Example 7 with Parameters

use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.

the class Desugar method visit.

public Expression visit(Using s) {
    Type aux = this.t;
    this.t = Type.immVoid;
    Parameters ps = liftPs(s.getPs());
    this.t = aux;
    return new Using(liftP(s.getPath()), s.getName(), s.getDocs(), ps, lift(s.getInner()));
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) MethodType(ast.Ast.MethodType) Parameters(ast.Ast.Parameters) Using(ast.Expression.Using)

Example 8 with Parameters

use of ast.Ast.Parameters 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());
}
Also used : MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) Parameters(ast.Ast.Parameters) ArrayList(java.util.ArrayList) MethodWithType(ast.Expression.ClassB.MethodWithType) Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) MethodType(ast.Ast.MethodType) FieldDec(ast.Ast.FieldDec) Expression(ast.Expression) MCall(ast.Expression.MCall) X(ast.Expression.X) MethodSelectorX(ast.Ast.MethodSelectorX)

Aggregations

Parameters (ast.Ast.Parameters)8 Expression (ast.Expression)6 ArrayList (java.util.ArrayList)6 X (ast.Expression.X)4 MethodSelectorX (ast.Ast.MethodSelectorX)3 VarDec (ast.Ast.VarDec)3 VarDecE (ast.Ast.VarDecE)3 VarDecXE (ast.Ast.VarDecXE)3 MethodType (ast.Ast.MethodType)2 Type (ast.Ast.Type)2 MethodWithType (ast.Expression.ClassB.MethodWithType)2 Doc (ast.Ast.Doc)1 FieldDec (ast.Ast.FieldDec)1 MethodSelector (ast.Ast.MethodSelector)1 Path (ast.Ast.Path)1 MCall (ast.Expression.MCall)1 SquareCall (ast.Expression.SquareCall)1 Using (ast.Expression.Using)1