use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.
the class AlternativeMethodTypes method mNoFwd.
static MethodType mNoFwd(MethodType mt) {
// Ts->T;Ps in methTypes(p,P,ms)
//(mNoFwd)-------------------------------------------------------------------
// noFwd Ts-> noFwd T;Ps in methTypes(p,P,ms)
List<Type> ts = Map.of(t -> noFwd(t), mt.getTs());
Type retT = noFwd(mt.getReturnType());
return mt.withReturnType(retT).withTs(ts);
}
use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.
the class AlternativeMethodTypes method types.
static List<MethodType> types(MethodType mt) {
List<MethodType> res = new ArrayList<>();
MethodType base = mBase(mt);
add(res, base);
MethodType mNoFwd = mNoFwd(base);
add(res, mNoFwd);
MethodType mImmFwd = _mImmFwd(base);
add(res, mImmFwd);
MethodType mRead = _mRead(base);
add(res, mRead);
add(res, _mC(base));
add(res, _mC(mNoFwd));
add(res, _mI(base));
if (mRead != null) {
add(res, _mI(mRead));
}
if (mImmFwd != null) {
add(res, mNoFwd(mImmFwd));
}
if (mt.getMdf() == Mdf.Mutable) {
add(res, _mVp(base, 0));
}
//later, 0 for mvp is the receiver so is ok to start from 1
{
int i = 0;
for (Type ti : base.getTs()) {
i += 1;
if (ti.getMdf() != Mdf.Mutable) {
continue;
}
//1 mType for each mut parameter
add(res, _mVp(base, i));
}
}
if (mt.getMdf() == Mdf.Mutable) {
add(res, _mVp(mNoFwd, 0));
}
{
int i = 0;
for (Type ti : mNoFwd.getTs()) {
i += 1;
if (ti.getMdf() != Mdf.Mutable) {
continue;
}
//1 mType for each mut parameter
add(res, _mVp(mNoFwd, i));
}
}
return res;
}
use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.
the class AlternativeMethodTypes method _mVp.
static MethodType _mVp(MethodType mt, int parNum) {
if (parNum > 0) {
return _mVpNoRec(mt, parNum - 1);
}
assert parNum == 0;
if (mt.getMdf() != Mdf.Mutable) {
return null;
}
Type retT = mt.getReturnType();
retT = _toLent(retT);
if (retT == null) {
return null;
}
List<Type> ts = Map.of(t -> mutToCapsule(t), mt.getTs());
MethodType res = mt.withReturnType(retT).withTs(ts).withMdf(Mdf.Lent);
if (WellFormednessCore.methodTypeWellFormed(res)) {
return res;
}
return null;
}
use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.
the class AlternativeMethodTypes method _mRead.
static MethodType _mRead(MethodType mt) {
//mutToCapsuleAndFwdToRead(Ts)->read P0;Ps in methTypes(p,P,ms)
if (!TypeManipulation.fwd_or_fwdP_in(mt.getTs())) {
return null;
}
Type retT = mt.getReturnType();
if (retT.getMdf() != Mdf.MutablePFwd) {
return null;
}
retT = retT.withMdf(Mdf.Readable);
List<Type> ts = Map.of(t -> mutToCapsuleAndFwdToRead(t), mt.getTs());
MethodType res = mt.withReturnType(retT).withTs(ts).withMdf(mutToCapsuleAndFwdToRead(mt.getMdf()));
if (WellFormednessCore.methodTypeWellFormed(res)) {
return res;
}
return null;
}
use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.
the class AlternativeMethodTypes method mBase.
static MethodType mBase(Program p, Path P, MethodSelector ms) {
//p(P)(ms).mh[from P]=refine? mdf0 method T m(T1 x1,..Tn xn) exception Ps
//T'=fwd% T if fwd_or_fwd%_in(Ts)
//otherwise T'=T
//(mBase)-------------------------------------------------------------------
//mdf0 P T1..Tn-> T';Ps in methTypes(p,P,ms) MethodWithType mwt = (MethodWithType) p.extractClassB(P)._getMember(ms);
MethodWithType mwt = (MethodWithType) p.extractClassB(P)._getMember(ms);
assert mwt != null;
MethodType mt = From.from(mwt.getMt(), P);
return mBase(mt);
}
Aggregations