use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class GuessTypeCore method visit.
@Override
public Type visit(MCall s) {
Type former = s.getInner().accept(this);
if (former == null) {
return null;
}
Path path = former.getPath();
assert path != null;
List<MethodSelectorX> msl = new ArrayList<>();
MethodSelectorX msx = new MethodSelectorX(s.getS(), "");
msl.add(msx);
MethodWithType meth = (MethodWithType) p.extractClassB(path)._getMember(s.getS());
if (meth == null) {
return null;
}
return (Type) From.fromT(meth.getMt().getReturnType(), path);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class TIn method toRead.
//onlyMutOrImm(G)={x:G(x) | G(x) only mut or imm}
public This toRead() {
//toRead(G)(x)=toRead(G(x)) //thus undefined where toRead undefined
Map<String, Map.Entry<Boolean, Type>> newG = new HashMap<>(g);
for (String xi : gDom()) {
Type ti = g(xi);
assert ti != null;
ti = TypeManipulation._toRead(ti);
if (ti == null) {
continue;
}
newG.put(xi, p(false, ti));
}
return this.withG(newG);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class TIn method freshGFromMt.
public TIn freshGFromMt(MethodWithType mwt) {
MethodType mt = mwt.getMt();
assert mwt.get_inner().isPresent();
Map<String, Map.Entry<Boolean, Type>> newG = new HashMap<>(g);
newG.put("this", p(false, new Type(mt.getMdf(), Path.outer(0), Doc.empty())));
{
int i = -1;
for (String x : mwt.getMs().getNames()) {
i += 1;
Type ntx = mt.getTs().get(i);
newG.put(x, p(false, ntx));
}
}
return new TIn(Phase.Typed, this.p, mwt.getInner(), TypeManipulation.fwdP(mt.getReturnType()), newG);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class TOkK method trCapture.
public This trCapture(Program p, On k) {
//(Ts;Ps).capture(catch return P x e)={T| T in Ts, not p|-T.P<=P};Ps
if (k.getKind() == SignalKind.Error) {
return self();
}
This result = trClean();
if (k.getKind() == SignalKind.Exception) {
result.exceptions = new ArrayList<>();
for (Path pi : exceptions) {
if (null != TypeSystem.subtype(p, pi, k.getT().getPath())) {
result.exceptions.add(pi);
}
}
}
//otherwise, is return
result.returns = new ArrayList<>();
for (Type ti : returns) {
if (null != TypeSystem.subtype(p, ti.getPath(), k.getT().getPath())) {
result.returns.add(ti);
}
}
return result;
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class TsBlock method promotionMakesSense.
default default boolean promotionMakesSense(TIn in, TErr tErr) {
Type expected = in.expected;
Type obtained = tErr._computed;
if (expected == null || obtained == null) {
return false;
}
if (null != TypeSystem.subtype(in.p, obtained.getPath(), expected.getPath())) {
return false;
}
Mdf eM = expected.getMdf();
Mdf oM = obtained.getMdf();
boolean acceptableEM = eM == Mdf.Capsule || eM == Mdf.Immutable || eM == Mdf.ImmutableFwd || eM == Mdf.ImmutablePFwd;
return acceptableEM && oM == Mdf.Mutable;
}
Aggregations