auditReport function
The report printed by ball audit <input.ball.json> for a program with
default options (all functions analyzed, termination check on). Reuses the
shared capability + termination analyzers so the native verb and this
function are a single implementation.
Returns the exact byte sequence the native verb appends to stdout: the capability report, then — only when termination warnings exist — a blank line and the termination report.
Implementation
String auditReport(Program program) {
final report = analyzeCapabilities(program);
// String concatenation (not StringBuffer) so this verb self-hosts on the
// compiled TS/C++/Rust CLIs. `formatCapabilityReport` already ends in `\n`;
// the extra `\n` reproduces the enclosing `writeln`.
var out = '${formatCapabilityReport(report)}\n';
final termWarnings = analyzeTermination(program);
if (termWarnings.isNotEmpty) {
out = '$out\n${formatTerminationReport(termWarnings)}\n';
}
return out;
}