use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class SmallStep method meta1.
protected ClassB meta1(Program p, ClassB cb, NestedClass m) {
log("---meta1--");
ExpCore e1 = m.getInner();
//get p'
try {
Program p1 = p.evilPush(cb);
ErrorFormatter.printType(p1);
//check p'
//Configuration.typeSystem.checkAll(p1);
//e1=Norm.of(p1,e1);
//check e1
//Configuration.typeSystem.checkMetaExpr(p1.getExecutableStar(),e1);
//run m.e1-->e2
ExpCore e2 = executeAtomicStep(new PData(p1), e1, m.getName());
//if(!(e2 instanceof ClassB)){Configuration.typeSystem.checkMetaExpr(p1.getExecutableStar(),e2);}//TODO: as assert
ClassB cbRes = cb.withMember(m.withInner(e2));
//replace cb[m.e2]
return cbRes;
} finally {
}
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class Abstract method toAbstract.
public static ClassB toAbstract(ClassB cb, List<Ast.C> path) {
Errors42.checkExistsPathMethod(cb, path, Optional.empty());
//check privacy coupled
ClassB cbClear = cb.onClassNavigateToPathAndDo(path, cbi -> clear(cbi));
Abstract.checkPrivacyCoupuled(cb, cbClear, path);
return cbClear;
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class Abstract method findUsage.
private static Set<PathMx> findUsage(List<PathMx> prMeth, ClassB cbClear) {
Set<PathMx> result = new HashSet<>();
for (PathMx pmx : prMeth) {
assert pmx.getPath().outerNumber() == 0;
UserForMethodResult res = Rename.userForMethod(Resources.getP(), /*wasEmpty*/
cbClear, pmx.getPath().getCBar(), pmx.getMs(), false);
result.addAll(res.asClient);
res.asThis.stream().map(e -> new PathMx(Path.outer(0), e)).forEach(result::add);
}
return result;
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class AddDocumentation method addDocumentationOnMethod.
public static ClassB addDocumentationOnMethod(Program p, ClassB cb, List<Ast.C> cs, MethodSelector sel, Doc doc) {
Errors42.checkExistsPathMethod(cb, cs, Optional.of(sel));
if (cs.isEmpty()) {
cb = auxAddDocOnMethod(p, cb, sel, doc);
} else {
Program p1 = p.evilPush(cb);
if (cs.size() > 1) {
p1 = p1.navigate(cs.subList(0, cs.size() - 1));
}
Program p2 = p1;
cb = cb.onClassNavigateToPathAndDo(cs, cbi -> auxAddDocOnMethod(p2, cbi, sel, doc));
}
return cb;
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class _Aux method onClassNavigateToPathAndDo.
static ClassB onClassNavigateToPathAndDo(ClassB cb, List<Ast.C> cs, Function<ClassB, ClassB> op) {
if (cs.isEmpty()) {
return op.apply(cb);
}
List<Member> newMs = new ArrayList<>(cb.getMs());
Ast.C nName = cs.get(0);
int index = getIndex(newMs, nName);
checkIndex(index);
NestedClass nc = (NestedClass) newMs.get(index);
if (cs.size() > 1) {
nc = nc.withInner(onClassNavigateToPathAndDo(wrapCast(nc.getInner()), cs.subList(1, cs.size()), op));
newMs.set(index, nc);
return cb.withMs(newMs);
}
assert cs.size() == 1;
ClassB newCb = op.apply(wrapCast(nc.getInner()));
newMs.set(index, nc.withInner(newCb));
return cb.withMs(newMs);
}
Aggregations