Explorer: Remove PrintDepth and implement PrintIndent. (#3113)

This PR removes `PrintDepth` from statement and declaration.
Implements `PrintIndent` for better indented formatting along with
various changes to make printing of statements and declarations better.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Prabhat Sachdeva
2023-08-25 17:17:39 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 05e061fe96
commit 289d05813e
17 changed files with 322 additions and 300 deletions
+10 -2
View File
@@ -28,12 +28,16 @@ auto AnalyzeProgram(Nonnull<Arena*> arena, AST ast,
if (trace_stream->is_enabled()) {
trace_stream->Heading("source program");
llvm::ListSeparator sep("\n\n");
for (auto& declaration : ast.declarations) {
set_file_ctx.update_source_loc(declaration->source_loc());
if (trace_stream->is_enabled()) {
*trace_stream << *declaration;
*trace_stream << sep << *declaration;
}
}
if (trace_stream->is_enabled()) {
*trace_stream << "\n";
}
}
SourceLocation source_loc("<Main()>", 0, FileKind::Main);
@@ -71,12 +75,16 @@ auto AnalyzeProgram(Nonnull<Arena*> arena, AST ast,
set_prog_phase.update_phase(ProgramPhase::Declarations);
if (trace_stream->is_enabled()) {
trace_stream->Heading("printing declarations");
llvm::ListSeparator sep("\n\n");
for (auto& declaration : ast.declarations) {
set_file_ctx.update_source_loc(declaration->source_loc());
if (trace_stream->is_enabled()) {
*trace_stream << *declaration;
*trace_stream << sep << *declaration;
}
}
if (trace_stream->is_enabled()) {
*trace_stream << "\n";
}
}
return ast;
}