Search in sources :

Example 61 with Type

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

the class TsOperations method tsPath.

default default TOut tsPath(TIn in, ExpCore.EPath s) {
    //D |- P~>P:class P <= T | emptyTr
    //D.p|-class P <= T
    Type t = new Type(Mdf.Class, s.getInner(), Doc.empty());
    assert s.getInner().isPrimitive() || in.p.extractClassB(s.getInner()) != null;
    ErrorKind subErr = TypeSystem.subtype(in.p, t, in.expected);
    if (subErr == null) {
        return new TOk(in, s, t);
    }
    TErr out = new TErr(in, "----", t, subErr);
    return out;
}
Also used : Type(ast.Ast.Type)

Example 62 with Type

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

the class TsOperations method tsVoid.

default default TOut tsVoid(TIn in, _void s) {
    //D |- void~> void:imm Void <= T | emptyTr
    //D.p|-imm Void <= T
    Type t = Path.Void().toImmNT();
    ErrorKind subErr = TypeSystem.subtype(in.p, t, in.expected);
    if (subErr == null) {
        return new TOk(in, s, t);
    }
    TErr out = new TErr(in, "misplaced void constant", t, subErr);
    return out;
}
Also used : Type(ast.Ast.Type)

Example 63 with Type

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

the class TsOperations method tsUpdateVar.

default default TOut tsUpdateVar(TIn in, UpdateVar s) {
    //     not fwd_or_fwd%_in(D.G(x).T)
    if (!in.gVar(s.getVar())) {
        assert false;
    /*TODO: return TErr locked var to improve*/
    }
    ErrorKind subErr = TypeSystem.subtype(in.p, Path.Void().toImmNT(), in.expected);
    if (subErr != null) {
        //strange exp like Foo(a:=b)
        assert false;
    }
    Type expected = in.g(s.getVar());
    if (TypeManipulation.fwd_or_fwdP_in(expected.getMdf())) {
        //can it even happen or is blocked by well formedness before?
        assert false;
    }
    TOut innerT = type(in.withE(s.getInner(), expected));
    if (!innerT.isOk()) {
        return innerT;
    }
    TOk ok = innerT.toOk();
    ok = ok.withAC(s.withInner(ok.annotated), Path.Void().toImmNT());
    return ok;
}
Also used : Type(ast.Ast.Type)

Example 64 with Type

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

the class DesugarVars method _computeTypeForClassBForVar.

public Type _computeTypeForClassBForVar(VarDecXE varDec) {
    assert varDec.getT().isPresent() : " it is now required by the stricted syntax";
    Type t = varDec.getT().get();
    t = t.withPath(computeTypeForClassBForVar(t.getPath()));
    return t;
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType)

Example 65 with Type

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

the class DesugarW method with_C_A.

private Expression with_C_A(Position pos, List<String> xs, With.On on0, Expression continuation) {
    List<String> ys = new ArrayList<String>();
    for (String x : xs) {
        ys.add(Functions.freshName(x, usedVars));
    }
    //(
    List<VarDec> decs = new ArrayList<>();
    //TODO:?? now is very strange and requires the mdf to propagate it to the locally introduced var?
    //casts: every cast is a block content e+catch
    {
        int i = -1;
        for (Type ti : on0.getTs()) {
            i += 1;
            String xi = xs.get(i);
            String yi = ys.get(i);
            decs.add(castT(pos, ti, yi, xi));
        }
    }
    //catch exception Void recursive call
    Catch k = Desugar.getK(pos, SignalKind.Exception, "", Type.immVoid, continuation);
    //main expression with 'T' renaming
    Expression e0 = on0.getInner();
    {
        int i = -1;
        for (Type ti : on0.getTs()) {
            i += 1;
            String xi = xs.get(i);
            String yi = ys.get(i);
            e0 = renameT(e0, new Expression.X(pos, xi), ti, new Expression.X(pos, yi));
        }
    }
    BlockContent content = new BlockContent(decs, Collections.singletonList(k));
    List<BlockContent> contents = new ArrayList<BlockContent>();
    contents.add(content);
    contents.add(Desugar.getBlockContent(e0));
    //void)
    return new RoundBlock(pos, Doc.empty(), Expression._void.instance, contents);
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.Expression.ClassB.MethodWithType) Expression(ast.Expression) Catch(ast.Expression.Catch) VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) BlockContent(ast.Expression.BlockContent) RoundBlock(ast.Expression.RoundBlock) X(ast.Expression.X)

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