use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class Test212_or_170_MethodTypes method recLeft.
MethodType recLeft(MethodType mt) {
List<Type> newTs = mt.getTs().subList(1, mt.getTs().size());
Mdf mdf = mt.getTs().get(0).getMdf();
if (TypeManipulation.fwd_or_fwdP_in(mdf)) {
return null;
}
return mt.withMdf(mdf).withTs(newTs);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class Test212_or_170_MethodTypes method test1.
@Test
public void test1() {
assert dataSet.size() == 170 : dataSet.size();
//Lent,ImmutableFwd->ImmutablePFwd
Type _t = Path.Any().toImmNT();
MethodType proto = new MethodType(true, Mdf.Capsule, Arrays.asList(_t.withMdf(Mdf.Mutable), _t.withMdf(Mdf.ImmutableFwd)), _t.withMdf(Mdf.ImmutablePFwd), Collections.emptyList());
proto = _mVp(proto, 1);
System.out.println(mtToS(proto));
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class SumMethods method mtU.
static MethodType mtU(int index, MethodType mt1, MethodType mt2) {
Mdf mdfU = mdfU(mt1.getMdf(), mt2.getMdf());
if (mdfU == null) {
return null;
}
Type removed = mt2.getTs().get(index);
boolean isRemovedPh = !Functions.isComplete(removed);
List<Type> totTypes;
if (isRemovedPh) {
totTypes = new ArrayList<>(mt1.getTs());
} else {
totTypes = mt1.getTs().stream().map(t -> TypeManipulation.noFwd(t)).collect(Collectors.toList());
}
totTypes.addAll(mt2.getTs());
int toRemove = mt1.getTs().size() + index;
totTypes.remove(toRemove);
List<Type> exU = new ArrayList<>(mt1.getExceptions());
exU.addAll(mt2.getExceptions());
MethodType mtU = new MethodType(false, mdfU, totTypes, mt2.getReturnType(), exU);
return mtU;
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class Redirect method redirectOkMember.
private static void redirectOkMember(List<PathSPath> ambiguities, List<SPathSPath> exceptions, Member mi, Member miGet, PathSPath current) {
if (mi instanceof NestedClass) {
assert miGet instanceof NestedClass;
assert ((NestedClass) mi).getName().equals(((NestedClass) miGet).getName());
Path src = current.getPath().pushC(((NestedClass) mi).getName());
Path dest = current.getPathsSet().iterator().next().pushC(((NestedClass) mi).getName());
plusEqual(ambiguities, src, Arrays.asList(dest));
return;
}
assert mi.getClass().equals(miGet.getClass());
assert mi instanceof MethodWithType : mi;
MethodWithType mwtSrc = (MethodWithType) mi;
MethodWithType mwtDest = (MethodWithType) miGet;
//this is what happens in p.method
mwtSrc = From.from(mwtSrc, current.getPath());
mwtDest = From.from(mwtDest, current.getPathsSet().iterator().next());
assert mwtSrc.getMs().equals(mwtDest.getMs());
boolean thisMdfOk = mwtSrc.getMt().getMdf().equals(mwtDest.getMt().getMdf());
boolean retOk = redirectOkT(ambiguities, mwtSrc.getMt().getReturnType(), mwtDest.getMt().getReturnType());
List<Integer> parWrong = new ArrayList<Integer>();
{
int i = -1;
for (Type tSrc : mwtSrc.getMt().getTs()) {
i += 1;
Type tDest = mwtDest.getMt().getTs().get(i);
if (!redirectOkT(ambiguities, tSrc, tDest)) {
parWrong.add(i);
}
;
}
}
boolean excOk = plusEqualAndExc(ambiguities, exceptions, current.getPath(), mwtSrc, mwtDest);
if (thisMdfOk && retOk && excOk && parWrong.isEmpty()) {
return;
}
throw Errors42.errorMethodClash(current.getPath().getCBar(), mwtSrc, mwtDest, excOk, parWrong, retOk, thisMdfOk, false);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class ToAst method parseType.
private Type parseType(TContext t) {
if (t.concreteT() != null) {
ConcreteTContext tt = t.concreteT();
Doc d = parseDoc(tt.docsOpt());
Ast.Type nt = new Ast.Type(Mdf.fromString((tt.Mdf() == null) ? "" : nameK(tt.Mdf())), Ast.Path.sugarParse(nameU(tt.Path())), d);
if (tt.Ph() == null) {
return nt;
}
return Functions.toPh(nt);
}
if (t.historicalT() != null) {
HistoricalTContext tt = t.historicalT();
Doc d = parseDoc(tt.docsOpt());
Path p = ast.Ast.Path.sugarParse(nameU(tt.Path()));
List<MethodSelectorX> mss = new ArrayList<MethodSelectorX>();
for (HistoricalSeqContext ms : tt.historicalSeq()) {
mss.add(parseMethSelectorX(ms));
}
//return new ast.Ast.HistoricType(p,mss,d);
throw Assertions.codeNotReachable();
}
throw Assertions.codeNotReachable();
}
Aggregations