Search in sources :

Example 81 with Type

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

the class InjectionOnCore method visit.

public ExpCore visit(Expression.RoundBlock s) {
    Doc doc = s.getDoc();
    assert s.getContents().size() <= 1 : s.getContents();
    List<Dec> decs = new ArrayList<Dec>();
    List<ExpCore.Block.On> ons = new ArrayList<ExpCore.Block.On>();
    ExpCore inner = s.getInner().accept(this);
    if (s.getContents().size() == 1) {
        Expression.BlockContent c = s.getContents().get(0);
        for (Ast.VarDec d : c.getDecs()) {
            assert d instanceof Ast.VarDecXE : d;
            Ast.VarDecXE sugarDec = (Ast.VarDecXE) d;
            //assert sugarDec.getT().isPresent() :sugarDec;
            Optional<Type> t = sugarDec.getT();
            String x = sugarDec.getX();
            ExpCore e = sugarDec.getInner().accept(this);
            decs.add(new Dec(sugarDec.isVar(), t, x, e));
        }
        //END FOR DECS
        ;
        for (Catch k : c.get_catch()) {
            assert k instanceof Expression.Catch1;
            Expression.Catch1 k1 = (Expression.Catch1) k;
            SignalKind kind = k1.getKind();
            String x = k1.getX();
            assert x.length() >= 1;
            ons.add(new ExpCore.Block.On(kind, x, k1.getT(), lift(k1.getInner()), k1.getP()));
        }
        return new Block(doc, decs, inner, ons, s.getP());
    }
    return new Block(doc, decs, inner, Collections.emptyList(), s.getP());
}
Also used : ExpCore(ast.ExpCore) Ast(ast.Ast) Catch(ast.Expression.Catch) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Expression(ast.Expression) Doc(ast.Ast.Doc) Block(ast.ExpCore.Block) SignalKind(ast.Ast.SignalKind)

Aggregations

Type (ast.Ast.Type)81 MethodType (ast.Ast.MethodType)50 MethodWithType (ast.ExpCore.ClassB.MethodWithType)28 MethodWithType (ast.Expression.ClassB.MethodWithType)24 ArrayList (java.util.ArrayList)24 Mdf (ast.Ast.Mdf)16 Expression (ast.Expression)15 Path (ast.Ast.Path)13 Doc (ast.Ast.Doc)11 Ast (ast.Ast)10 MethodSelector (ast.Ast.MethodSelector)10 HashMap (java.util.HashMap)10 MethodSelectorX (ast.Ast.MethodSelectorX)8 VarDecXE (ast.Ast.VarDecXE)8 ExpCore (ast.ExpCore)8 Catch (ast.Expression.Catch)8 X (ast.Expression.X)8 VarDec (ast.Ast.VarDec)7 Block (ast.ExpCore.Block)7 List (java.util.List)7