mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-03 07:29:37 +00:00
137053f093
- Activate with option -rrig or -reportrig.
58 lines
2.0 KiB
Java
58 lines
2.0 KiB
Java
package dk.camelot64.kickc.passes.reports;
|
|
|
|
import dk.camelot64.kickc.model.InternalError;
|
|
import dk.camelot64.kickc.model.Program;
|
|
|
|
import java.io.FileOutputStream;
|
|
import java.io.OutputStreamWriter;
|
|
import java.nio.file.Path;
|
|
|
|
/**
|
|
* Base class for compiler reports generated in separate files in the compiler output directory.
|
|
*/
|
|
public abstract class Report {
|
|
|
|
final protected Program program;
|
|
protected String pass;
|
|
protected String extension;
|
|
|
|
public String configureReport() {
|
|
StringBuilder report = new StringBuilder();
|
|
report.append("---\n");
|
|
report.append("config:\n");
|
|
report.append(" theme: dark\n");
|
|
report.append(" flowchart:\n");
|
|
report.append(" wrappingWidth: 800\n");
|
|
report.append(" nodeSpacing : 40\n");
|
|
report.append(" rankSpacing : 40\n");
|
|
report.append(" titleTopMargin : 40\n");
|
|
report.append(" padding : 10\n");
|
|
report.append(" htmlLabels: false\n");
|
|
report.append("---\n");
|
|
return report.toString();
|
|
}
|
|
|
|
abstract String generateReport(Program program);
|
|
|
|
Report(Program program, String pass, String extension) {
|
|
this.program = program;
|
|
this.pass = pass;
|
|
this.extension = extension;
|
|
};
|
|
|
|
public void generateReport() {
|
|
Path reportPath = program.getOutputFileManager().getMermaidOutputFile(pass, extension);
|
|
System.out.println("Generating report " + reportPath);
|
|
try {
|
|
FileOutputStream reportOutputStream = new FileOutputStream(reportPath.toFile());
|
|
OutputStreamWriter reportWriter = new OutputStreamWriter(reportOutputStream);
|
|
String reportDiagramString = generateReport(this.program);
|
|
reportWriter.write(reportDiagramString);
|
|
reportWriter.close();
|
|
reportOutputStream.close();
|
|
} catch(Exception e) {
|
|
throw new InternalError("Error generating report " + reportPath, e);
|
|
}
|
|
}
|
|
}
|