use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class TranslateClass method getMethods.
private static void getMethods(Program p, ClassB ct, StringBuilder res, boolean isInterface) {
for (Member m : ct.getMs()) {
assert m instanceof MethodWithType;
MethodWithType mt = (MethodWithType) m;
if (!isInterface && !mt.get_inner().isPresent()) {
continue;
}
//if(mt.getMt().getMdf()!=Ast.Mdf.NormType){continue;}
getMethod(p, mt, res);
}
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class RetainOnlyAndRenameAs method liftMembers.
public List<Member> liftMembers(List<Member> s) {
if (!path.isEmpty()) {
Ast.C name = path.get(0);
List<Member> result = new ArrayList<>();
Optional<Member> mOpt = Functions.getIfInDom(s, name);
if (!mOpt.isPresent()) {
throw new Resources.Error(EncodingHelper.wrapStringU("RenamedNestedClassNotExistant:" + name));
}
//retain only
result.add(mOpt.get());
return Map.of(this::liftM, result);
}
//rename as
List<Member> result = new ArrayList<>();
Optional<Member> mOpt = Functions.getIfInDom(s, ms1);
if (mOpt.isPresent()) {
Member m = mOpt.get();
m = m.match(nc -> {
throw Assertions.codeNotReachable();
}, mi -> {
throw Assertions.codeNotReachable();
}, //mi->mi.withS(ms2).withInner(renameParameterAsVars(mi.getInner(),ms1,ms2)),
mt -> mt.withMs(ms2).with_inner(Map.of(eMt -> renameParameterAsVars(eMt, ms1, ms2), mt.get_inner())));
result.add(m);
}
return result;
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class Locator method getClassNamesPath.
public List<Ast.C> getClassNamesPath() {
int size = this.size();
//assert path.get(path.size()-1)==null;
List<Ast.C> sPath = new ArrayList<>();
for (Member m : this.ms) {
m.match(nc -> sPath.add(nc.getName()), mi -> sPath.add(null), mt -> sPath.add(null));
}
if (size > 0 && cbs.get(size - 1) == null) {
sPath.remove(sPath.size() - 1);
}
return sPath;
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class Locator method prefixOf.
public boolean prefixOf(Locator nl) {
int size = nl.size();
if (this.size() < size) {
return false;
}
for (int i = 0; i < size; i++) {
int indexC = this.indexes.get(i);
int indexPos = nl.indexes.get(i);
assert i != size - 1 || indexPos == 0 : "" + i + " " + size + " " + indexPos;
if (i != size - 1 && indexC != indexPos) {
return false;
}
Member ci = this.ms.get(i);
Member nli = nl.ms.get(i);
if (ci == nli) {
continue;
}
if (ci.getClass() != nli.getClass()) {
return false;
}
if (!(ci instanceof ClassB.NestedClass)) {
return false;
}
Ast.C nci = ((ClassB.NestedClass) ci).getName();
Ast.C nnli = ((ClassB.NestedClass) nli).getName();
if (!nci.equals(nnli)) {
return false;
}
//is ok to not check classBs?
}
return true;
}
use of ast.ExpCore.ClassB.Member in project L42 by ElvisResearchGroup.
the class ErrorFormatter method whyIsNotExecutable.
private static String whyIsNotExecutable(ClassB cb) {
/*if(cb.getH() instanceof Ast.TraitHeader){
return "\n The requested path is a trait";
}*/
for (Member m : cb.getMs()) {
if (!(m instanceof MethodWithType)) {
continue;
}
/*MethodWithType mt=(MethodWithType)m;
if (!mt.getInner().isPresent() && !mt.isFieldGenerated()){
return "\n The method "+mt.getMs()+" of the requested path is abstract";
}*/
}
for (Member m : cb.getMs()) {
if (!(m instanceof NestedClass)) {
continue;
}
NestedClass nc = (NestedClass) m;
if (!(nc.getInner() instanceof ClassB)) {
return "\n The nested class " + nc.getName() + " of the requested path is not compiled yet";
}
String nestedRes = whyIsNotExecutable((ClassB) nc.getInner());
if (nestedRes != null) {
return "." + nc.getName() + nestedRes;
}
}
return null;
}
Aggregations