Explorer: Add methods to trace for line prefixes (#3076)

Defines methods into `TraceStream` for adding line prefixes. Instead of
directly using string literals.

Example usage,
```
trace_stream_->Start() << "declaring ... " << ... ;
```
will result in,
```
->> declaring ... 
```
This commit is contained in:
Prabhat Sachdeva
2023-08-09 19:05:19 +00:00
committed by GitHub
parent a67aeb5724
commit 0bcba9d05e
19 changed files with 710 additions and 682 deletions
+4 -4
View File
@@ -450,7 +450,7 @@ auto Interpreter::EvalRecursively(std::unique_ptr<Action> action)
CARBON_RETURN_IF_ERROR(Step());
}
if (trace_stream_->is_enabled()) {
*trace_stream_ << "--- recursive eval done\n";
trace_stream_->End() << "recursive eval done\n";
}
Nonnull<const Value*> result =
cast<RecursiveAction>(todo_.CurrentAction()).results()[0];
@@ -886,7 +886,7 @@ auto Interpreter::CallFunction(const CallExpression& call,
std::optional<AllocationId> location_received)
-> ErrorOr<Success> {
if (trace_stream_->is_enabled()) {
*trace_stream_ << "calling function: " << *fun << "\n";
trace_stream_->Call() << "calling function: " << *fun << "\n";
}
switch (fun->kind()) {
case Value::Kind::AlternativeConstructorValue: {
@@ -2484,8 +2484,8 @@ auto Interpreter::Step() -> ErrorOr<Success> {
Action& act = todo_.CurrentAction();
if (trace_stream_->is_enabled()) {
*trace_stream_ << "--- step " << act << " (" << act.source_loc()
<< ") --->\n";
trace_stream_->Start() << "step " << act << " (" << act.source_loc()
<< ") --->\n";
}
auto error_builder = [&] {