use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class ErrorFormatter method whyIsNotExecutable.
public static String whyIsNotExecutable(Path path, Program p1) {
ClassB cb = p1.extractClassB(path);
String whyNot = whyIsNotExecutable(cb);
if (whyNot != null) {
return "The requested path is incomplete.\n " + ToFormattedText.of(path) + whyNot;
}
return "The requested path is incomplete since it refers to other incomplete classes in the program";
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class ErrorFormatter method topFormatErrorMessage.
@SuppressWarnings("unchecked")
public static void topFormatErrorMessage(ErrorMessage msg) {
//System.out.println(ErrorFormatter.formatError(msg).getErrorTxt());
L42.printDebug(formatError(Program.emptyLibraryProgram(), msg).getErrorTxt());
for (Field f : msg.getClass().getDeclaredFields()) {
f.setAccessible(true);
if (!f.getName().equals("p")) {
continue;
}
List<ClassB> program;
try {
program = (List<ClassB>) f.get(msg);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
}
if (program != null) {
for (ClassB cb : program) {
L42.printDebug(displayAbstractMethods(cb));
}
}
}
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class ErrorFormatter method printType.
private static void printType(int i, String prefix, ClassB top) {
System.out.print("This" + i + prefix + " :{\n");
printMembers(top);
System.out.print(" }\n");
for (Member m : top.getMs()) {
if (!(m instanceof NestedClass)) {
continue;
}
NestedClass nc = (NestedClass) m;
if (nc.getInner() instanceof ClassB) {
printType(i, "." + nc.getName(), (ClassB) nc.getInner());
}
}
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class ErrorFormatter method displayAbstractMethods.
//TODO: what was this for
@SuppressWarnings("unused")
private static void displayAbstractMethods(ClassB cb, StringBuilder result, String nesting) {
result.append("{\n");
for (Member m : cb.getMs()) {
m.match(nc -> {
if (!(nc.getInner() instanceof ClassB)) {
return null;
}
if (((ClassB) nc.getInner()).isInterface()) {
return null;
}
StringBuilder inner = new StringBuilder();
displayAbstractMethods((ClassB) nc.getInner(), inner, nesting + " ");
String innerStr = inner.toString();
if (!innerStr.contains("method")) {
return null;
}
result.append(nesting);
result.append(nc.getName());
result.append(":");
result.append(innerStr);
return null;
}, mi -> {
return null;
}, mt -> {
if (mt.get_inner().isPresent()) {
return null;
}
if (mt.getMt().getMdf() == Mdf.Class) {
return null;
}
result.append(nesting);
result.append(ToFormattedText.of(mt).replace("\n", "\n" + nesting));
result.append("\n");
return null;
});
}
result.append("}\n");
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class L42 method checkFinalError.
public static ErrorMessage.FinalResult checkFinalError(ClassB result) {
L42.setExecutionStage(ExecutionStage.Closing);
ClassB.NestedClass last = (ClassB.NestedClass) result.getMs().get(result.getMs().size() - 1);
if (!(last.getInner() instanceof ClassB)) {
finalErr(result, "The last class can not be completed");
}
ClassB lastC = (ClassB) last.getInner();
//TODO: booh what is the right kind? if(!(lastC.getH() instanceof Ast.TraitHeader)){finalErr(result,"The last class is not a Trait");}
if (!lastC.getMs().isEmpty()) {
finalErr(result, "The last class contains members");
}
String errCode = lastC.getDoc1().toString();
if (!errCode.startsWith("@exitStatus\n")) {
finalErr(result, "The last class is not an exitStatus class:" + errCode);
}
errCode = errCode.substring("@exitStatus\n".length());
int errCodeInt = 0;
try {
errCodeInt = Integer.parseInt(errCode.substring(0, errCode.length() - 1));
} catch (NumberFormatException e) {
finalErr(result, "The exitStatus is not a valid number: " + errCode);
}
if (errCodeInt > 0 && errCodeInt < 100) {
finalErr(result, "The exitStatus is reserved: " + errCodeInt);
}
return new ErrorMessage.FinalResult(errCodeInt, result);
}
Aggregations