use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class _Sum method matchNC.
private static Void matchNC(Program p, ClassB topA, ClassB topB, NestedClass nca, List<Member> ms, NestedClass ncb, List<Ast.C> current) {
List<Ast.C> innerCurrent = new ArrayList<>(current);
innerCurrent.add(nca.getName());
ClassB newInner = normalizedSum(p, topA, topB, (ClassB) nca.getInner(), (ClassB) ncb.getInner(), innerCurrent);
Doc doc = nca.getDoc().sum(ncb.getDoc());
ms.add(nca.withInner(newInner).withDoc(doc));
return null;
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class Lib method navigate.
Lib navigate(List<Ast.C> cs) {
if (cs.isEmpty()) {
return this;
}
if (this.isBinded) {
//TODO: need from?
ClassB cb = this.inner.getClassB(cs);
return new Lib(true, cb, Collections.emptyList(), cb);
}
List<Ast.C> top = Collections.singletonList(cs.get(0));
List<Ast.C> tail = cs.subList(1, cs.size());
Lib nextStep = new Lib(false, root, Functions.push(path, cs.get(0)), inner.getClassB(top), this);
return nextStep.navigate(tail);
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class Type method refTo.
default default TypeRefTo refTo(PData pData) {
Path path = type().getPath();
Path whereP = Path.outer(0, locationLib().path);
path = From.fromP(path, whereP);
if (path.outerNumber() == 0) {
return new TypeRefTo.Lib(locationLib().root(), path);
}
Program p = pData.p.evilPush(locationLib().root().inner);
//will be evilPush
try {
ClassB cb = p.extractClassB(path);
//if(coreVisitors.IsCompiled.of(cb)){
if (cb.getPhase() != Phase.None) {
//norm,typed,coherent
return new TypeRefTo.Binded(path);
}
//TODO: borderline ok?
return new TypeRefTo.Unavailable();
} catch (ErrorMessage.PathMetaOrNonExistant pne) {
if (pne.isMeta()) {
return new TypeRefTo.Unavailable();
}
return new TypeRefTo.Missing();
}
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method isOkAsReturn.
private static void isOkAsReturn(Program p, Path csTop, Type ti) throws ClassUnfit, MethodUnfit {
Path pi = ti.getPath();
if (pi.equals(Path.Void())) {
return;
}
//We will need to generate a simpler returning expression
if (pi.equals(Path.Library())) {
return;
}
Path op = _pathForOutside(csTop.getCBar().size(), pi);
if (op == null) {
checkForInside(p.top(), csTop, pi);
return;
}
ClassB l = p.extractClassB(op);
boolean hasIt = hasFrom(l);
boolean phOk = Functions.isComplete(ti);
if (ti.getMdf() == Mdf.Class && !ti.equals(Type.classAny)) {
throw new RefactorErrors.MethodUnfit().msg("Return type can be 'class' only if is exactly 'class any'");
}
if (!hasIt) {
throw new RefactorErrors.ClassUnfit().msg("Class " + op + " has no method #from(binaryRepr)");
}
if (!phOk) {
//TODO: why this limitation?
throw new RefactorErrors.MethodUnfit().msg("Return type can not be fwd");
}
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method checkForInside.
private static void checkForInside(ClassB lTop, Path csTop, Path originalPath) throws ClassUnfit, MethodUnfit {
if (originalPath.isPrimitive()) {
throw new RefactorErrors.MethodUnfit().msg("Method signature not supported:\n parameters can not be Void/Any/fwd.\n" + "returns can not be Any/fwd\n" + "exceptions can not be Any/Void/Library");
}
Path cs = From.fromP(originalPath, csTop);
assert cs.outerNumber() == 0;
List<Ast.C> cBar = cs.getCBar();
ClassB lPointed = lTop.getClassB(cBar);
Doc d = lPointed.getDoc1();
if (d._getParameterForPlugin() == null || d._getParameterForPluginPart() == null) {
throw new RefactorErrors.ClassUnfit().msg("Class " + cBar + " doesnot have @pluginPart annotation");
}
}
Aggregations