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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations