From 0bcba9d05e7bb6b99b8a840888914ee94590d5a1 Mon Sep 17 00:00:00 2001 From: Prabhat Sachdeva Date: Thu, 10 Aug 2023 00:35:19 +0530 Subject: [PATCH] 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 ... ``` --- explorer/ast/static_scope.cpp | 22 +- explorer/common/trace_stream.h | 21 +- explorer/interpreter/action_stack.h | 8 +- explorer/interpreter/heap.cpp | 17 +- explorer/interpreter/impl_scope.cpp | 2 +- explorer/interpreter/interpreter.cpp | 8 +- explorer/interpreter/resolve_control_flow.cpp | 30 +- explorer/interpreter/resolve_names.cpp | 20 +- explorer/interpreter/resolve_unformed.cpp | 15 +- explorer/interpreter/type_checker.cpp | 285 ++++----- explorer/testdata/trace/context_all.carbon | 6 +- explorer/testdata/trace/context_main.carbon | 206 +++---- .../testdata/trace/context_prelude.carbon | 2 +- explorer/testdata/trace/phase_all.carbon | 544 +++++++++--------- .../phase_control_flow_resolution.carbon | 2 +- .../testdata/trace/phase_execution.carbon | 96 ++-- .../trace/phase_name_resolution.carbon | 32 +- .../testdata/trace/phase_type_checking.carbon | 68 +-- ...phase_unformed_variables_resolution.carbon | 8 +- 19 files changed, 710 insertions(+), 682 deletions(-) diff --git a/explorer/ast/static_scope.cpp b/explorer/ast/static_scope.cpp index c1910db6965f..d9f050848dff 100644 --- a/explorer/ast/static_scope.cpp +++ b/explorer/ast/static_scope.cpp @@ -27,9 +27,9 @@ auto StaticScope::Add(std::string_view name, ValueNodeView entity, } } else { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- declared `" << name << "` as `" << entity - << "` in `" << PrintAsID(*this) << "` (" - << entity.base().source_loc() << ")\n"; + trace_stream_->Result() + << "declared `" << name << "` as `" << entity << "` in `" + << PrintAsID(*this) << "` (" << entity.base().source_loc() << ")\n"; } } return Success(); @@ -57,9 +57,9 @@ void StaticScope::MarkDeclared(std::string_view name) { if (it->second.status == NameStatus::KnownButNotDeclared) { it->second.status = NameStatus::DeclaredButNotUsable; if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- marked `" << name - << "` declared but not usable in `" << PrintAsID(*this) - << "`\n"; + trace_stream_->Result() + << "marked `" << name << "` declared but not usable in `" + << PrintAsID(*this) << "`\n"; } } } @@ -69,8 +69,8 @@ void StaticScope::MarkUsable(std::string_view name) { CARBON_CHECK(it != declared_names_.end()) << name << " not found"; it->second.status = NameStatus::Usable; if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- marked `" << name << "` usable in `" - << PrintAsID(*this) << "`\n"; + trace_stream_->Result() + << "marked `" << name << "` usable in `" << PrintAsID(*this) << "`\n"; } } @@ -130,9 +130,9 @@ auto StaticScope::TryResolveHere(std::string_view name, auto exit_scope_function = llvm::make_scope_exit([&]() { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- resolved `" << name << "` as `" - << it->second.entity << "` in `" << PrintAsID(*this) - << "` (" << source_loc << ")\n"; + trace_stream_->Result() + << "resolved `" << name << "` as `" << it->second.entity << "` in `" + << PrintAsID(*this) << "` (" << source_loc << ")\n"; } }); diff --git a/explorer/common/trace_stream.h b/explorer/common/trace_stream.h index fc47f802e6bf..3fa498d1d9ec 100644 --- a/explorer/common/trace_stream.h +++ b/explorer/common/trace_stream.h @@ -103,11 +103,30 @@ class TraceStream { // Outputs a trace message. Requires is_enabled. template auto operator<<(T&& message) const -> llvm::raw_ostream& { - CARBON_CHECK(is_enabled()); + CARBON_CHECK(is_enabled() && stream_); **stream_ << message; return **stream_; } + // These functions can be used for adding line prefixes in the trace output. + auto Indent() const -> llvm::raw_ostream& { return *this << " "; } + auto Start() const -> llvm::raw_ostream& { return *this << "->> "; } + auto End() const -> llvm::raw_ostream& { return *this << "<<- "; } + auto Call() const -> llvm::raw_ostream& { return *this << "-() "; } + auto Match() const -> llvm::raw_ostream& { return *this << "=== "; } + auto Result() const -> llvm::raw_ostream& { return *this << "==> "; } + auto Add() const -> llvm::raw_ostream& { return *this << " + "; } + auto Remove() const -> llvm::raw_ostream& { return *this << " - "; } + auto Read() const -> llvm::raw_ostream& { return *this << "<-- "; } + auto Write() const -> llvm::raw_ostream& { return *this << "--> "; } + auto Allocate() const -> llvm::raw_ostream& { return *this << "++# "; } + auto Deallocate() const -> llvm::raw_ostream& { return *this << "--# "; } + auto Substitute() const -> llvm::raw_ostream& { return *this << "->+ "; } + auto Push() const -> llvm::raw_ostream& { return *this << ">[] "; } + auto Pop() const -> llvm::raw_ostream& { return *this << "<[] "; } + auto Not() const -> llvm::raw_ostream& { return *this << "-!- "; } + auto Skip() const -> llvm::raw_ostream& { return *this << ">>> "; } + private: bool in_prelude_ = false; ProgramPhase current_phase_ = ProgramPhase::Unknown; diff --git a/explorer/interpreter/action_stack.h b/explorer/interpreter/action_stack.h index d300802660d0..587c7c19d823 100644 --- a/explorer/interpreter/action_stack.h +++ b/explorer/interpreter/action_stack.h @@ -112,16 +112,16 @@ class ActionStack { auto Pop() -> std::unique_ptr { auto popped_action = todo_.Pop(); if (trace_stream_->is_enabled()) { - *trace_stream_ << "(-) stack-pop: " << *popped_action << " (" - << popped_action->source_loc() << ")\n"; + trace_stream_->Pop() << "stack-pop: " << *popped_action << " (" + << popped_action->source_loc() << ")\n"; } return popped_action; } void Push(std::unique_ptr action) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "(+) stack-push: " << *action << " (" - << action->source_loc() << ")\n"; + trace_stream_->Push() + << "stack-push: " << *action << " (" << action->source_loc() << ")\n"; } todo_.Push(std::move(action)); } diff --git a/explorer/interpreter/heap.cpp b/explorer/interpreter/heap.cpp index c9279e534d03..92975e39f233 100644 --- a/explorer/interpreter/heap.cpp +++ b/explorer/interpreter/heap.cpp @@ -32,8 +32,9 @@ auto Heap::AllocateValue(Nonnull v) -> AllocationId { bound_values_.push_back(llvm::DenseMap{}); if (trace_stream_->is_enabled()) { - *trace_stream_ << "(+) memory-alloc: #" << a.index_ << " `" << *v << "`" - << (is_uninitialized ? " uninitialized" : "") << "\n"; + trace_stream_->Allocate() + << "memory-alloc: #" << a.index_ << " `" << *v << "`" + << (is_uninitialized ? " uninitialized" : "") << "\n"; } return a; @@ -48,8 +49,8 @@ auto Heap::Read(const Address& a, SourceLocation source_loc) const value->GetElement(arena_, a.element_path_, source_loc, value); if (trace_stream_->is_enabled()) { - *trace_stream_ << "+++ memory-read: #" << a.allocation_.index_ << " `" - << **read_value << "`\n"; + trace_stream_->Read() << "memory-read: #" << a.allocation_.index_ << " `" + << **read_value << "`\n"; } return read_value; @@ -83,8 +84,8 @@ auto Heap::Write(const Address& a, Nonnull v, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "+++ memory-write: #" << a.allocation_.index_ << " `" - << *values_[a.allocation_.index_] << "`\n"; + trace_stream_->Write() << "memory-write: #" << a.allocation_.index_ << " `" + << *values_[a.allocation_.index_] << "`\n"; } return Success(); @@ -120,8 +121,8 @@ auto Heap::Deallocate(AllocationId allocation) -> ErrorOr { } if (trace_stream_->is_enabled()) { - *trace_stream_ << "(-) memory-dealloc: #" << allocation.index_ << " `" - << *values_[allocation.index_] << "`\n"; + trace_stream_->Deallocate() << "memory-dealloc: #" << allocation.index_ + << " `" << *values_[allocation.index_] << "`\n"; } return Success(); diff --git a/explorer/interpreter/impl_scope.cpp b/explorer/interpreter/impl_scope.cpp index 6470d7237d8f..18543dc4b12f 100644 --- a/explorer/interpreter/impl_scope.cpp +++ b/explorer/interpreter/impl_scope.cpp @@ -416,7 +416,7 @@ auto ImplScope::TryResolveInterfaceHere( // TODO: Add indentation when printing the parents. void ImplScope::Print(llvm::raw_ostream& out) const { llvm::ListSeparator sep(",\n "); - out << " + " + out << " " << "["; for (const ImplFact& impl : impl_facts_) { out << sep << "`" << *(impl.type) << "` as `" << *(impl.interface) << "`"; diff --git a/explorer/interpreter/interpreter.cpp b/explorer/interpreter/interpreter.cpp index 2f8d2a4d3141..b9066b4cf7d3 100644 --- a/explorer/interpreter/interpreter.cpp +++ b/explorer/interpreter/interpreter.cpp @@ -450,7 +450,7 @@ auto Interpreter::EvalRecursively(std::unique_ptr 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 result = cast(todo_.CurrentAction()).results()[0]; @@ -886,7 +886,7 @@ auto Interpreter::CallFunction(const CallExpression& call, std::optional location_received) -> ErrorOr { 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 { 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 = [&] { diff --git a/explorer/interpreter/resolve_control_flow.cpp b/explorer/interpreter/resolve_control_flow.cpp index 2ad9e6a1c788..94e722d55860 100644 --- a/explorer/interpreter/resolve_control_flow.cpp +++ b/explorer/interpreter/resolve_control_flow.cpp @@ -77,9 +77,10 @@ static auto ResolveControlFlow(Nonnull trace_stream, } if (trace_stream->is_enabled()) { - *trace_stream << "--- flow-resolved return statement `" << *statement - << "` in `" << PrintAsID(*((*function)->declaration)) - << "` (" << statement->source_loc() << ")\n"; + trace_stream->Result() + << "flow-resolved return statement `" << *statement << "` in `" + << PrintAsID(*((*function)->declaration)) << "` (" + << statement->source_loc() << ")\n"; } return Success(); @@ -92,8 +93,9 @@ static auto ResolveControlFlow(Nonnull trace_stream, cast(*statement).set_loop(*loop); if (trace_stream->is_enabled()) { - *trace_stream << "--- flow-resolved break statement `" << *statement - << "` for `" << PrintAsID(**loop) << "`\n"; + trace_stream->Result() + << "flow-resolved break statement `" << *statement << "` for `" + << PrintAsID(**loop) << "`\n"; } return Success(); @@ -105,9 +107,9 @@ static auto ResolveControlFlow(Nonnull trace_stream, cast(*statement).set_loop(*loop); if (trace_stream->is_enabled()) { - *trace_stream << "--- flow-resolved continue statement `" << *statement - << "` in `" << PrintAsID(**loop) << "` (" - << statement->source_loc() << ")\n"; + trace_stream->Result() + << "flow-resolved continue statement `" << *statement << "` in `" + << PrintAsID(**loop) << "` (" << statement->source_loc() << ")\n"; } return Success(); @@ -134,9 +136,9 @@ static auto ResolveControlFlow(Nonnull trace_stream, trace_stream, &cast(*statement).body(), statement, function)); if (trace_stream->is_enabled()) { - *trace_stream << "--- flow-resolved for statement `" - << PrintAsID(*statement) << "` (" - << statement->source_loc() << ")\n"; + trace_stream->Result() + << "flow-resolved for statement `" << PrintAsID(*statement) << "` (" + << statement->source_loc() << ")\n"; } return Success(); @@ -146,9 +148,9 @@ static auto ResolveControlFlow(Nonnull trace_stream, trace_stream, &cast(*statement).body(), statement, function)); if (trace_stream->is_enabled()) { - *trace_stream << "--- flow-resolved while statement `" - << PrintAsID(*statement) << "` (" - << statement->source_loc() << ")\n"; + trace_stream->Result() + << "flow-resolved while statement `" << PrintAsID(*statement) + << "` (" << statement->source_loc() << ")\n"; } return Success(); diff --git a/explorer/interpreter/resolve_names.cpp b/explorer/interpreter/resolve_names.cpp index 6897b8129ebd..02f62a38eae9 100644 --- a/explorer/interpreter/resolve_names.cpp +++ b/explorer/interpreter/resolve_names.cpp @@ -577,8 +577,8 @@ auto NameResolver::ResolveNamesImpl(Statement& statement, StaticScope& enclosing_scope) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "** resolving stmt `" << PrintAsID(statement) << "` (" - << statement.source_loc() << ")\n"; + trace_stream_->Start() << "resolving stmt `" << PrintAsID(statement) + << "` (" << statement.source_loc() << ")\n"; } switch (statement.kind()) { case StatementKind::ExpressionStatement: @@ -690,9 +690,8 @@ auto NameResolver::ResolveNamesImpl(Statement& statement, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "** finished resolving stmt `"; - statement.PrintID(trace_stream_->stream()); - *trace_stream_ << "` (" << statement.source_loc() << ")\n"; + trace_stream_->End() << "finished resolving stmt `" << PrintAsID(statement) + << "` (" << statement.source_loc() << ")\n"; } return Success(); @@ -732,9 +731,8 @@ auto NameResolver::ResolveNamesImpl(Declaration& declaration, ResolveFunctionBodies bodies) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "** resolving decl `"; - declaration.PrintID(trace_stream_->stream()); - *trace_stream_ << "` (" << declaration.source_loc() << ")\n"; + trace_stream_->Start() << "resolving decl `" << PrintAsID(declaration) + << "` (" << declaration.source_loc() << ")\n"; } switch (declaration.kind()) { @@ -951,9 +949,9 @@ auto NameResolver::ResolveNamesImpl(Declaration& declaration, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "** finished resolving decl `"; - declaration.PrintID(trace_stream_->stream()); - *trace_stream_ << "` (" << declaration.source_loc() << ")\n"; + trace_stream_->End() << "finished resolving decl `" + << PrintAsID(declaration) << "` (" + << declaration.source_loc() << ")\n"; } return Success(); diff --git a/explorer/interpreter/resolve_unformed.cpp b/explorer/interpreter/resolve_unformed.cpp index c53f142877ef..ab2e248c8eb7 100644 --- a/explorer/interpreter/resolve_unformed.cpp +++ b/explorer/interpreter/resolve_unformed.cpp @@ -70,8 +70,8 @@ auto FlowFacts::TakeAction(Nonnull node, ActionType action, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- " << action_type_string(action) << " `" << name - << "` (" << source_loc << ")\n"; + trace_stream_->Result() << action_type_string(action) << " `" << name + << "` (" << source_loc << ")\n"; } return Success(); @@ -255,8 +255,9 @@ static auto ResolveUnformedImpl(Nonnull trace_stream, FlowFacts::ActionType action) -> ErrorOr { if (trace_stream->is_enabled()) { - *trace_stream << "*** resolving-unformed in stmt `" << PrintAsID(*statement) - << "` (" << statement->source_loc() << ")\n"; + trace_stream->Start() << "resolving-unformed in stmt `" + << PrintAsID(*statement) << "` (" + << statement->source_loc() << ")\n"; } switch (statement->kind()) { case StatementKind::Block: { @@ -407,9 +408,9 @@ static auto ResolveUnformed(Nonnull trace_stream, SetFileContext set_file_ctx(*trace_stream, declaration->source_loc()); if (trace_stream->is_enabled()) { - *trace_stream << "*** resolving-unformed in decl `" - << PrintAsID(*declaration) << "` (" - << declaration->source_loc() << ")\n"; + trace_stream->Start() << "resolving-unformed in decl `" + << PrintAsID(*declaration) << "` (" + << declaration->source_loc() << ")\n"; } switch (declaration->kind()) { // Checks formed/unformed state intraprocedurally. diff --git a/explorer/interpreter/type_checker.cpp b/explorer/interpreter/type_checker.cpp index 0deb8f6f1379..49968d5b4522 100644 --- a/explorer/interpreter/type_checker.cpp +++ b/explorer/interpreter/type_checker.cpp @@ -586,8 +586,8 @@ auto TypeChecker::BuildBuiltinConversion(Nonnull source, Nonnull source_type = &source->static_type(); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** building builtin conversion from `" << *source_type - << "` to `" << *destination << "`\n"; + trace_stream_->Start() << "building builtin conversion from `" + << *source_type << "` to `" << *destination << "`\n"; } // Build a simple conversion that the interpreter can perform directly. @@ -822,10 +822,10 @@ auto TypeChecker::ImplicitlyConvert(std::string_view context, destination = destination_constraint; if (trace_stream_->is_enabled()) { - *trace_stream_ << "converting type `" << *converted_value - << "` to constraint `" << *destination_constraint - << "` for " << context << " in scope:\n" - << impl_scope << "\n"; + trace_stream_->Start() + << "converting type `" << *converted_value << "` to constraint `" + << *destination_constraint << "` for " << context << " in scope:\n" + << impl_scope << "\n"; } // Note, we discard the witness. We don't actually need it in order to // perform the conversion, but we do want to know it exists. @@ -899,8 +899,8 @@ auto TypeChecker::IsIntrinsicConstraintSatisfied( constraint.arguments[0], impl_scope, /*allow_user_defined_conversions=*/true)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- `" << constraint << "` evaluated to `" - << convertible << "`\n"; + trace_stream_->Result() + << "`" << constraint << "` evaluated to `" << convertible << "`\n"; } return convertible; } @@ -1023,7 +1023,7 @@ class TypeChecker::ArgumentDeduction { deduced_bindings_in_order_(bindings_to_deduce), trace_stream_(trace_stream) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** performing argument deduction for bindings: ["; + trace_stream_->Start() << "performing argument deduction for bindings: ["; llvm::ListSeparator sep; for (const auto* binding : bindings_to_deduce) { *trace_stream_ << sep << "`" << *binding << "`"; @@ -1097,7 +1097,8 @@ auto TypeChecker::ArgumentDeduction::Deduce(Nonnull param, bool allow_implicit_conversion) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** deducing `" << *param << "` from `" << *arg << "`\n"; + trace_stream_->Start() << "deducing `" << *param << "` from `" << *arg + << "`\n"; } // If param is the name of a variable we're deducing, then deduce it. @@ -1427,8 +1428,8 @@ auto TypeChecker::ArgumentDeduction::Finish( CARBON_ASSIGN_OR_RETURN(Nonnull value, type_checker.InterpExp(arg)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- evaluated generic parameter `" << *binding - << "` as `" << *value << "`\n"; + trace_stream_->Result() << "evaluated generic parameter `" << *binding + << "` as `" << *value << "`\n"; } // Find a witness for the binding if needed. @@ -1478,7 +1479,7 @@ auto TypeChecker::ArgumentDeduction::Finish( } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--> deduction succeeded with results: ["; + trace_stream_->Result() << "deduction succeeded with results: ["; llvm::ListSeparator sep; for (const auto& [binding, val] : bindings.args()) { *trace_stream_ << sep << "`" << *binding << "` = `" << *val << "`"; @@ -1650,8 +1651,8 @@ class TypeChecker::ConstraintTypeBuilder { const Bindings& bindings, bool add_lookup_contexts) -> ErrorOr { if (type_checker.trace_stream_->is_enabled()) { - *type_checker.trace_stream_ - << "*** merging `" << *constraint << "` into constraint with `" + type_checker.trace_stream_->Start() + << "merging `" << *constraint << "` into constraint with `" << *constraint->self_binding() << "` ~> `" << *self << "`\n"; } @@ -1907,9 +1908,9 @@ class TypeChecker::ConstraintTypeBuilder { std::deque> rewrite_queue; for (auto& rewrite : rewrite_constraints_) { if (type_checker.trace_stream_->is_enabled()) { - *type_checker.trace_stream_ << "--- initial rewrite of `" - << *rewrite.constant << "` is `" - << *rewrite.converted_replacement << "`\n"; + type_checker.trace_stream_->End() + << "initial rewrite of `" << *rewrite.constant << "` is `" + << *rewrite.converted_replacement << "`\n"; } rewrite_queue.push_back(&rewrite); } @@ -1946,9 +1947,9 @@ class TypeChecker::ConstraintTypeBuilder { if (!ValueEqual(rebuilt, rewrite->converted_replacement, std::nullopt)) { if (type_checker.trace_stream_->is_enabled()) { - *type_checker.trace_stream_ << "--- rewrote rewrite of `" - << *rewrite->constant << "` to `" - << *rebuilt << "`\n"; + type_checker.trace_stream_->End() + << "rewrote rewrite of `" << *rewrite->constant << "` to `" + << *rebuilt << "`\n"; } rewrite->converted_replacement = rebuilt; // Now we've rewritten this rewrite, we might find more rewrites apply @@ -1956,8 +1957,8 @@ class TypeChecker::ConstraintTypeBuilder { rewrite_queue.push_back(rewrite); } else { if (type_checker.trace_stream_->is_enabled()) { - *type_checker.trace_stream_ - << "--- rewrite of `" << *rewrite->constant << "` converged to `" + type_checker.trace_stream_->End() + << "rewrite of `" << *rewrite->constant << "` converged to `" << *rebuilt << "`\n"; } } @@ -2107,7 +2108,7 @@ auto TypeChecker::Substitute(const Bindings& bindings, CARBON_ASSIGN_OR_RETURN(const auto* result, SubstituteImpl(bindings, type)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "->+ substitution of ["; + trace_stream_->Substitute() << "substitution of ["; llvm::ListSeparator sep(", "); for (const auto& [name, value] : bindings.args()) { *trace_stream_ << sep << "`" << *name << "` -> `" << *value << "`"; @@ -2144,8 +2145,8 @@ class TypeChecker::SubstituteTransform if (it == bindings_.args().end()) { if (const auto* trace_stream = type_checker_->trace_stream_; trace_stream->is_enabled()) { - *trace_stream << "--- substitution: no value for binding `" << *var_type - << "`, leaving alone\n"; + trace_stream->End() << "substitution: no value for binding `" + << *var_type << "`, leaving alone\n"; } return var_type; } else { @@ -2160,8 +2161,8 @@ class TypeChecker::SubstituteTransform if (it == bindings_.witnesses().end()) { if (const auto* trace_stream = type_checker_->trace_stream_; trace_stream->is_enabled()) { - *trace_stream << "--- substitution: no value for binding `" << *witness - << "`, leaving alone\n"; + trace_stream->End() << "substitution: no value for binding `" + << *witness << "`, leaving alone\n"; } return witness; } else { @@ -2287,9 +2288,10 @@ class TypeChecker::SubstituteTransform } if (const auto* trace_stream = type_checker_->trace_stream_; trace_stream->is_enabled()) { - *trace_stream << "--- substitution: self of constraint `" << *constraint - << "` is substituted, new type of type is `" - << *type_of_type << "`\n"; + trace_stream->End() + << "substitution: self of constraint `" << *constraint + << "` is substituted, new type of type is `" << *type_of_type + << "`\n"; } // TODO: Should we keep any part of the old constraint -- rewrites, // equality constraints, etc? @@ -2304,8 +2306,8 @@ class TypeChecker::SubstituteTransform Nonnull new_constraint = std::move(builder).Build(); if (const auto* trace_stream = type_checker_->trace_stream_; trace_stream->is_enabled()) { - *trace_stream << "--- substitution: " << *constraint << " => " - << *new_constraint << "\n"; + trace_stream->End() << "substitution: " << *constraint << " => " + << *new_constraint << "\n"; } return new_constraint; } @@ -2353,7 +2355,7 @@ auto TypeChecker::RefineWitness(Nonnull witness, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--x could not refine `" << *witness << "`\n"; + trace_stream_->Not() << "could not refine `" << *witness << "`\n"; } return witness; } @@ -2377,10 +2379,10 @@ auto TypeChecker::MatchImpl(const InterfaceType& iface, if (trace_stream_->is_enabled()) { *trace_stream_ << "\n========\tMatch Impl\t========\n"; - *trace_stream_ << "*** looking for `" << *impl_type << "` as `" << iface - << "`\n"; - *trace_stream_ << "*** checking `" << *impl.type << "` as `" - << *impl.interface << "` (" << source_loc << ")\n"; + trace_stream_->Start() << "looking for `" << *impl_type << "` as `" << iface + << "`\n"; + trace_stream_->Start() << "checking `" << *impl.type << "` as `" + << *impl.interface << "` (" << source_loc << ")\n"; } ArgumentDeduction deduction(source_loc, "match", impl.deduced, trace_stream_); @@ -2389,7 +2391,7 @@ auto TypeChecker::MatchImpl(const InterfaceType& iface, /*allow_implicit_conversion=*/false); !e.ok()) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--! type does not match: " << e.error() << "\n"; + trace_stream_->Not() << "type does not match: " << e.error() << "\n"; } return {std::nullopt}; } @@ -2398,7 +2400,7 @@ auto TypeChecker::MatchImpl(const InterfaceType& iface, impl.interface, &iface, /*allow_implicit_conversion=*/false); !e.ok()) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--! interface does not match: " << e.error() << "\n"; + trace_stream_->Not() << "interface does not match: " << e.error() << "\n"; } return {std::nullopt}; } @@ -2414,13 +2416,13 @@ auto TypeChecker::MatchImpl(const InterfaceType& iface, /*diagnose_deduction_failure=*/false)); if (!bindings_or_error) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--! impl does not match\n"; + trace_stream_->Not() << "impl does not match\n"; } return {std::nullopt}; } else { if (trace_stream_->is_enabled()) { - *trace_stream_ << "==> matched with `" << *impl.type << "` as `" - << *impl.interface << "`\n\n"; + trace_stream_->Result() << "matched with `" << *impl.type << "` as `" + << *impl.interface << "`\n\n"; } CARBON_ASSIGN_OR_RETURN( const auto* subst_witness, @@ -2773,13 +2775,13 @@ auto TypeChecker::TypeCheckExpImpl(Nonnull e, const ImplScope& impl_scope) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking " << e->kind() << " `" << *e << "` (" - << e->source_loc() << ")\n"; + trace_stream_->Start() << "checking " << e->kind() << " `" << *e << "` (" + << e->source_loc() << ")\n"; } if (e->is_type_checked()) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- expression `" << *e - << "` has already been type-checked\n"; + trace_stream_->End() << "expression `" << *e + << "` has already been type-checked\n"; } return Success(); } @@ -3626,10 +3628,10 @@ auto TypeChecker::TypeCheckExpImpl(Nonnull e, case Value::Kind::FunctionType: { const auto& fun_t = cast(call.function().static_type()); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking call to function of type `" << fun_t - << "` with arguments of type `" - << call.argument().static_type() << "` (" - << call.source_loc() << ")\n"; + trace_stream_->Start() + << "checking call to function of type `" << fun_t + << "` with arguments of type `" << call.argument().static_type() + << "` (" << call.source_loc() << ")\n"; } CARBON_RETURN_IF_ERROR(DeduceCallBindings( call, &fun_t.parameters(), fun_t.generic_parameters(), @@ -4271,7 +4273,7 @@ auto TypeChecker::TypeCheckPattern( std::optional> expected, ImplScope& impl_scope, ExpressionCategory enclosing_expression_category) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking " << p->kind() << " `" << *p << "`"; + trace_stream_->Start() << "checking " << p->kind() << " `" << *p << "`"; if (expected) { *trace_stream_ << ", expecting `" << **expected << "`"; } @@ -4398,8 +4400,9 @@ auto TypeChecker::TypeCheckPattern( expected_field_type, impl_scope, enclosing_expression_category)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking tuple pattern field `" - << *field << "` (" << field->source_loc() << ")\n"; + trace_stream_->Start() + << "finished checking tuple pattern field `" << *field << "` (" + << field->source_loc() << ")\n"; } field_types.push_back(&field->static_type()); field_patterns.push_back(&field->value()); @@ -4529,14 +4532,14 @@ auto TypeChecker::TypeCheckGenericBinding(GenericBinding& binding, builder.AddAndSubstitute(*this, constraint, symbolic_value, witness, Bindings(), /*add_lookup_contexts=*/true)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** resolving constraint type for `" << binding - << "` from `" << *constraint << "`\n"; + trace_stream_->Start() << "resolving constraint type for `" << binding + << "` from `" << *constraint << "`\n"; } CARBON_RETURN_IF_ERROR( builder.Resolve(*this, binding.type().source_loc(), impl_scope)); type = std::move(builder).Build(); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- resolved constraint type is `" << *type << "`\n"; + trace_stream_->End() << "resolved constraint type is `" << *type << "`\n"; } BringImplBindingIntoScope(impl_binding, impl_scope); @@ -4579,8 +4582,8 @@ auto TypeChecker::TypeCheckStmt(Nonnull s, const ImplScope& impl_scope) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking " << s->kind() << " `" << PrintAsID(*s) - << "` (" << s->source_loc() << ")\n"; + trace_stream_->Start() << "checking " << s->kind() << " `" << PrintAsID(*s) + << "` (" << s->source_loc() << ")\n"; } switch (s->kind()) { case StatementKind::Match: { @@ -4896,8 +4899,8 @@ auto TypeChecker::DeclareCallableDeclaration(Nonnull f, const auto name = GetName(*f); CARBON_CHECK(name) << "Unexpected missing name for `" << *f << "`."; if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** declaring function `" << *name << "` (" - << f->source_loc() << ")\n"; + trace_stream_->Start() << "declaring function `" << *name << "` (" + << f->source_loc() << ")\n"; } ImplScope function_scope(scope_info.innermost_scope); std::vector> all_bindings = @@ -5014,9 +5017,9 @@ auto TypeChecker::DeclareCallableDeclaration(Nonnull f, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished declaring function `" << *name - << "` of type `" << f->static_type() << "` (" - << f->source_loc() << ")\n"; + trace_stream_->Start() << "finished declaring function `" << *name + << "` of type `" << f->static_type() << "` (" + << f->source_loc() << ")\n"; } return Success(); } @@ -5027,8 +5030,8 @@ auto TypeChecker::TypeCheckCallableDeclaration(Nonnull f, auto name = GetName(*f); CARBON_CHECK(name) << "Unexpected missing name for `" << *f << "`."; if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking function `" << *name << "` (" - << f->source_loc() << ")\n"; + trace_stream_->Start() << "checking function `" << *name << "` (" + << f->source_loc() << ")\n"; } // If f->return_term().is_auto(), the function body was already // type checked in DeclareFunctionDeclaration. @@ -5038,8 +5041,8 @@ auto TypeChecker::TypeCheckCallableDeclaration(Nonnull f, BringImplBindingsIntoScope( cast(f->static_type()).impl_bindings(), function_scope); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << PrintAsID(*f) << "` (" - << f->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << PrintAsID(*f) + << "` (" << f->source_loc() << ")\n"; *trace_stream_ << function_scope; } CARBON_RETURN_IF_ERROR(TypeCheckStmt(*f->body(), function_scope)); @@ -5049,8 +5052,8 @@ auto TypeChecker::TypeCheckCallableDeclaration(Nonnull f, } } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking function `" << *name << "` (" - << f->source_loc() << ")\n"; + trace_stream_->Start() << "finished checking function `" << *name << "` (" + << f->source_loc() << ")\n"; } return Success(); } @@ -5059,8 +5062,8 @@ auto TypeChecker::DeclareClassDeclaration(Nonnull class_decl, const ScopeInfo& scope_info) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** declaring class `" << class_decl->name() << "` (" - << class_decl->source_loc() << ")\n"; + trace_stream_->Start() << "declaring class `" << class_decl->name() << "` (" + << class_decl->source_loc() << ")\n"; } Nonnull self = class_decl->self(); ImplScope class_scope(scope_info.innermost_scope); @@ -5144,8 +5147,8 @@ auto TypeChecker::DeclareClassDeclaration(Nonnull class_decl, std::nullopt, class_scope, ExpressionCategory::Value)); CollectAndNumberGenericBindingsInPattern(type_params, bindings); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << class_decl->name() - << "` (" << class_decl->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << class_decl->name() + << "` (" << class_decl->source_loc() << ")\n"; *trace_stream_ << class_scope; } } @@ -5257,8 +5260,8 @@ auto TypeChecker::DeclareClassDeclaration(Nonnull class_decl, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished declaring class `" << class_decl->name() - << "` (" << class_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished declaring class `" << class_decl->name() + << "` (" << class_decl->source_loc() << ")\n"; } return Success(); } @@ -5267,16 +5270,16 @@ auto TypeChecker::TypeCheckClassDeclaration( Nonnull class_decl, const ImplScope& impl_scope) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking class `" << class_decl->name() << "` (" - << class_decl->source_loc() << ")\n"; + trace_stream_->Start() << "checking class `" << class_decl->name() << "` (" + << class_decl->source_loc() << ")\n"; } ImplScope class_scope(&impl_scope); if (class_decl->type_params().has_value()) { BringPatternImplBindingsIntoScope(*class_decl->type_params(), class_scope); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << class_decl->name() - << "` (" << class_decl->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << class_decl->name() + << "` (" << class_decl->source_loc() << ")\n"; *trace_stream_ << class_scope; } auto [it, inserted] = @@ -5288,8 +5291,8 @@ auto TypeChecker::TypeCheckClassDeclaration( CARBON_RETURN_IF_ERROR(CollectMember(class_decl, m)); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking class `" << class_decl->name() - << "` (" << class_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished checking class `" << class_decl->name() + << "` (" << class_decl->source_loc() << ")\n"; } return Success(); } @@ -5299,8 +5302,8 @@ auto TypeChecker::DeclareMixinDeclaration(Nonnull mixin_decl, const ScopeInfo& scope_info) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** declaring mixin `" << mixin_decl->name() << "` (" - << mixin_decl->source_loc() << ")\n"; + trace_stream_->Start() << "declaring mixin `" << mixin_decl->name() << "` (" + << mixin_decl->source_loc() << ")\n"; } ImplScope mixin_scope(scope_info.innermost_scope); @@ -5309,8 +5312,8 @@ auto TypeChecker::DeclareMixinDeclaration(Nonnull mixin_decl, *mixin_decl->params(), PatternRequirements::Irrefutable, std::nullopt, mixin_scope, ExpressionCategory::Value)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << mixin_decl->name() - << "` (" << mixin_decl->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << mixin_decl->name() + << "` (" << mixin_decl->source_loc() << ")\n"; *trace_stream_ << mixin_scope; } @@ -5336,8 +5339,8 @@ auto TypeChecker::DeclareMixinDeclaration(Nonnull mixin_decl, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished declaring mixin `" << mixin_decl->name() - << "` (" << mixin_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished declaring mixin `" << mixin_decl->name() + << "` (" << mixin_decl->source_loc() << ")\n"; } return Success(); } @@ -5356,22 +5359,22 @@ auto TypeChecker::TypeCheckMixinDeclaration( if (!inserted) { // This declaration has already been type checked before if (trace_stream_->is_enabled()) { - *trace_stream_ << ">>> skipped checking mixin `" << mixin_decl->name() - << "` (" << mixin_decl->source_loc() << ")\n"; + trace_stream_->Skip() << "skipped checking mixin `" << mixin_decl->name() + << "` (" << mixin_decl->source_loc() << ")\n"; } return Success(); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking mixin `" << mixin_decl->name() << "` (" - << mixin_decl->source_loc() << ")\n"; + trace_stream_->Start() << "checking mixin `" << mixin_decl->name() << "` (" + << mixin_decl->source_loc() << ")\n"; } ImplScope mixin_scope(&impl_scope); if (mixin_decl->params().has_value()) { BringPatternImplBindingsIntoScope(*mixin_decl->params(), mixin_scope); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << mixin_decl->name() - << "` (" << mixin_decl->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << mixin_decl->name() + << "` (" << mixin_decl->source_loc() << ")\n"; *trace_stream_ << mixin_scope; } for (Nonnull m : mixin_decl->members()) { @@ -5379,8 +5382,8 @@ auto TypeChecker::TypeCheckMixinDeclaration( CARBON_RETURN_IF_ERROR(CollectMember(mixin_decl, m)); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking mixin `" << mixin_decl->name() - << "` (" << mixin_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished checking mixin `" << mixin_decl->name() + << "` (" << mixin_decl->source_loc() << ")\n"; } return Success(); } @@ -5395,8 +5398,9 @@ auto TypeChecker::TypeCheckMixDeclaration( std::optional> enclosing_decl) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking MixDeclaration `" << PrintAsID(*mix_decl) - << "` (" << mix_decl->source_loc() << ")\n"; + trace_stream_->Start() << "checking MixDeclaration `" + << PrintAsID(*mix_decl) << "` (" + << mix_decl->source_loc() << ")\n"; } // TODO(darshal): Check if the imports (interface mentioned in the 'for' // clause) of the mixin being mixed are being impl'd in the enclosed @@ -5416,8 +5420,8 @@ auto TypeChecker::TypeCheckMixDeclaration( } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking `" << PrintAsID(*mix_decl) << "` (" - << mix_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished checking `" << PrintAsID(*mix_decl) + << "` (" << mix_decl->source_loc() << ")\n"; } return Success(); @@ -5432,8 +5436,8 @@ auto TypeChecker::DeclareConstraintTypeDeclaration( bool is_interface = isa(constraint_decl); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** declaring `" << PrintAsID(*constraint_decl) << "` (" - << constraint_decl->source_loc() << ")\n"; + trace_stream_->Start() << "declaring `" << PrintAsID(*constraint_decl) + << "` (" << constraint_decl->source_loc() << ")\n"; } ImplScope constraint_scope(scope_info.innermost_scope); @@ -5444,9 +5448,9 @@ auto TypeChecker::DeclareConstraintTypeDeclaration( *constraint_decl->params(), PatternRequirements::Irrefutable, std::nullopt, constraint_scope, ExpressionCategory::Value)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" - << PrintAsID(*constraint_decl) << "` (" - << constraint_decl->source_loc() << ")\n"; + trace_stream_->Result() + << "impl declarations for `" << PrintAsID(*constraint_decl) << "` (" + << constraint_decl->source_loc() << ")\n"; *trace_stream_ << constraint_scope; } CollectAndNumberGenericBindingsInPattern(*constraint_decl->params(), @@ -5618,8 +5622,9 @@ auto TypeChecker::DeclareConstraintTypeDeclaration( constraint_decl->set_constraint_type(std::move(builder).Build()); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished declaring `" << PrintAsID(*constraint_decl) - << "` (" << constraint_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished declaring `" + << PrintAsID(*constraint_decl) << "` (" + << constraint_decl->source_loc() << ")\n"; } return Success(); } @@ -5628,8 +5633,8 @@ auto TypeChecker::TypeCheckConstraintTypeDeclaration( Nonnull constraint_decl, const ImplScope& impl_scope) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking `" << PrintAsID(*constraint_decl) << "` (" - << constraint_decl->source_loc() << ")\n"; + trace_stream_->Start() << "checking `" << PrintAsID(*constraint_decl) + << "` (" << constraint_decl->source_loc() << ")\n"; } ImplScope constraint_scope(&impl_scope); if (constraint_decl->params().has_value()) { @@ -5637,9 +5642,9 @@ auto TypeChecker::TypeCheckConstraintTypeDeclaration( constraint_scope); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" - << PrintAsID(*constraint_decl) << "` (" - << constraint_decl->source_loc() << ")\n"; + trace_stream_->Result() + << "impl declarations for `" << PrintAsID(*constraint_decl) << "` (" + << constraint_decl->source_loc() << ")\n"; *trace_stream_ << constraint_scope; } for (Nonnull m : constraint_decl->members()) { @@ -5647,8 +5652,8 @@ auto TypeChecker::TypeCheckConstraintTypeDeclaration( TypeCheckDeclaration(m, constraint_scope, constraint_decl)); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking `" << PrintAsID(*constraint_decl) - << "` (" << constraint_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished checking `" << PrintAsID(*constraint_decl) + << "` (" << constraint_decl->source_loc() << ")\n"; } return Success(); } @@ -5768,9 +5773,9 @@ auto TypeChecker::CheckAndAddImplBindings( if (!deduced_bindings.empty()) { sort_key = TypeStructureSortKey::ForImpl(impl_type, iface_type); if (trace_stream_->is_enabled()) { - *trace_stream_ << "type structure sort key for `impl " << *impl_type - << " as " << *iface_type << "` is " << sort_key - << "\n"; + trace_stream_->End() + << "type structure sort key for `impl " << *impl_type << " as " + << *iface_type << "` is " << sort_key << "\n"; } } @@ -5798,8 +5803,8 @@ auto TypeChecker::DeclareImplDeclaration(Nonnull impl_decl, bool is_template_instantiation) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** declaring `" << PrintAsID(*impl_decl) << "` (" - << impl_decl->source_loc() << ")\n"; + trace_stream_->Start() << "declaring `" << PrintAsID(*impl_decl) << "` (" + << impl_decl->source_loc() << ")\n"; } if (!IsTemplateSaturated(impl_decl->deduced_parameters())) { @@ -5869,17 +5874,17 @@ auto TypeChecker::DeclareImplDeclaration(Nonnull impl_decl, builder.GetSelfWitness(), Bindings(), /*add_lookup_contexts=*/true)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** resolving impls constraint type for `" - << PrintAsID(*impl_decl) << "` from `" - << *implemented_constraint << "` (" - << impl_decl->source_loc() << ")\n"; + trace_stream_->Start() + << "resolving impls constraint type for `" << PrintAsID(*impl_decl) + << "` from `" << *implemented_constraint << "` (" + << impl_decl->source_loc() << ")\n"; } CARBON_RETURN_IF_ERROR(builder.Resolve( *this, impl_decl->interface().source_loc(), impl_scope)); constraint_type = std::move(builder).Build(); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** resolving impls constraint type as `" - << *constraint_type << "`\n"; + trace_stream_->Start() << "resolving impls constraint type as `" + << *constraint_type << "`\n"; } impl_decl->set_constraint_type(constraint_type); } @@ -5936,8 +5941,9 @@ auto TypeChecker::DeclareImplDeclaration(Nonnull impl_decl, } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished declaring impl `" << *impl_decl->impl_type() - << "` as `" << impl_decl->interface() << "`\n"; + trace_stream_->End() << "finished declaring impl `" + << *impl_decl->impl_type() << "` as `" + << impl_decl->interface() << "`\n"; } return Success(); } @@ -5975,15 +5981,16 @@ auto TypeChecker::TypeCheckImplDeclaration(Nonnull impl_decl, -> ErrorOr { if (!IsTemplateSaturated(impl_decl->deduced_parameters())) { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** deferring checking templated `" << *impl_decl - << "` (" << impl_decl->source_loc() << ")\n"; + trace_stream_->Start() << "deferring checking templated `" << *impl_decl + << "` (" << impl_decl->source_loc() << ")\n"; } return Success(); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking ImplDeclaration `" << PrintAsID(*impl_decl) - << "` (" << impl_decl->source_loc() << ")\n"; + trace_stream_->Start() << "checking ImplDeclaration `" + << PrintAsID(*impl_decl) << "` (" + << impl_decl->source_loc() << ")\n"; } Nonnull self = *impl_decl->self()->constant_value(); @@ -6007,8 +6014,8 @@ auto TypeChecker::TypeCheckImplDeclaration(Nonnull impl_decl, CARBON_RETURN_IF_ERROR(TypeCheckDeclaration(m, member_scope, impl_decl)); } if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** finished checking impl `" << PrintAsID(*impl_decl) - << "` (" << impl_decl->source_loc() << ")\n"; + trace_stream_->End() << "finished checking impl `" << PrintAsID(*impl_decl) + << "` (" << impl_decl->source_loc() << ")\n"; } return Success(); } @@ -6025,8 +6032,8 @@ auto TypeChecker::DeclareChoiceDeclaration(Nonnull choice, choice_scope, ExpressionCategory::Value)); CollectAndNumberGenericBindingsInPattern(type_params, bindings); if (trace_stream_->is_enabled()) { - *trace_stream_ << "--- impl declarations for `" << PrintAsID(*choice) - << "` (" << choice->source_loc() << ")\n"; + trace_stream_->Result() << "impl declarations for `" << PrintAsID(*choice) + << "` (" << choice->source_loc() << ")\n"; *trace_stream_ << choice_scope; } } @@ -6171,8 +6178,8 @@ auto TypeChecker::TypeCheckDeclaration( std::optional> enclosing_decl) -> ErrorOr { if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** checking " << d->kind() << " `" << PrintAsID(*d) - << "` (" << d->source_loc() << ")\n"; + trace_stream_->Start() << "checking " << d->kind() << " `" << PrintAsID(*d) + << "` (" << d->source_loc() << ")\n"; } switch (d->kind()) { case DeclarationKind::NamespaceDeclaration: @@ -6492,8 +6499,8 @@ auto TypeChecker::InstantiateImplDeclaration( CARBON_CHECK(IsTemplateSaturated(*bindings)); if (trace_stream_->is_enabled()) { - *trace_stream_ << "*** instantiating `" << PrintAsID(*old_impl) << "` (" - << old_impl->source_loc() << ")\n"; + trace_stream_->Start() << "instantiating `" << PrintAsID(*old_impl) << "` (" + << old_impl->source_loc() << ")\n"; *trace_stream_ << *bindings << "\n"; } diff --git a/explorer/testdata/trace/context_all.carbon b/explorer/testdata/trace/context_all.carbon index b9f177e21ae1..0a929243d02b 100644 --- a/explorer/testdata/trace/context_all.carbon +++ b/explorer/testdata/trace/context_all.carbon @@ -15,8 +15,8 @@ fn Main() -> i32 { // ARGS: --trace_file=- --trace_phase=all --trace_file_context=all %s // NOAUTOUPDATE // SET-CHECK-SUBSET -// CHECK:STDOUT: *** declaring `interface As` (prelude.carbon:14) -// CHECK:STDOUT: *** declaring function `Main` (context_all.carbon:11) +// CHECK:STDOUT: ->> declaring `interface As` (prelude.carbon:14) +// CHECK:STDOUT: ->> declaring function `Main` (context_all.carbon:11) // CHECK:STDOUT: interface As { // CHECK:STDOUT: fn Main ()-> i32 { -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main()` (:0) ---> diff --git a/explorer/testdata/trace/context_main.carbon b/explorer/testdata/trace/context_main.carbon index 89c62c8a0c01..d82c0198d5a2 100644 --- a/explorer/testdata/trace/context_main.carbon +++ b/explorer/testdata/trace/context_main.carbon @@ -25,32 +25,32 @@ fn Main() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: ********** resolving names ********** -// CHECK:STDOUT: --- declared `TestInterface` as `interface TestInterface` in `package` (context_main.carbon:7) -// CHECK:STDOUT: --- declared `Main` as `fn Main` in `package` (context_main.carbon:11) -// CHECK:STDOUT: ** resolving decl `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: --- marked `TestInterface` declared but not usable in `package` -// CHECK:STDOUT: --- marked `TestInterface` usable in `package` -// CHECK:STDOUT: --- declared `Self` as `Self` in `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: ** finished resolving decl `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: ** resolving decl `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: --- marked `Main` declared but not usable in `package` -// CHECK:STDOUT: --- marked `Main` usable in `package` -// CHECK:STDOUT: ** resolving stmt `{return 0;}` (context_main.carbon:11) -// CHECK:STDOUT: ** resolving stmt `return 0;` (context_main.carbon:10) -// CHECK:STDOUT: ** finished resolving stmt `return 0;` (context_main.carbon:10) -// CHECK:STDOUT: ** finished resolving stmt `{return 0;}` (context_main.carbon:11) -// CHECK:STDOUT: ** finished resolving decl `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: --- resolved `Main` as `fn Main` in `package` (:0) +// CHECK:STDOUT: ==> declared `TestInterface` as `interface TestInterface` in `package` (context_main.carbon:7) +// CHECK:STDOUT: ==> declared `Main` as `fn Main` in `package` (context_main.carbon:11) +// CHECK:STDOUT: ->> resolving decl `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ==> marked `TestInterface` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `TestInterface` usable in `package` +// CHECK:STDOUT: ==> declared `Self` as `Self` in `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: <<- finished resolving decl `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> resolving decl `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: ==> marked `Main` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `Main` usable in `package` +// CHECK:STDOUT: ->> resolving stmt `{return 0;}` (context_main.carbon:11) +// CHECK:STDOUT: ->> resolving stmt `return 0;` (context_main.carbon:10) +// CHECK:STDOUT: <<- finished resolving stmt `return 0;` (context_main.carbon:10) +// CHECK:STDOUT: <<- finished resolving stmt `{return 0;}` (context_main.carbon:11) +// CHECK:STDOUT: <<- finished resolving decl `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: ==> resolved `Main` as `fn Main` in `package` (:0) // CHECK:STDOUT: ********** resolving control flow ********** -// CHECK:STDOUT: --- flow-resolved return statement `return 0;` in `fn Main` (context_main.carbon:10) +// CHECK:STDOUT: ==> flow-resolved return statement `return 0;` in `fn Main` (context_main.carbon:10) // CHECK:STDOUT: ********** type checking ********** -// CHECK:STDOUT: *** declaring `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: *** finished declaring `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: *** checking InterfaceDeclaration `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: *** checking `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: --- impl declarations for `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: ->> declaring `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: <<- finished declaring `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> checking InterfaceDeclaration `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> checking `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ==> impl declarations for `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -97,23 +97,23 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** finished checking `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: *** declaring function `Main` (context_main.carbon:11) -// CHECK:STDOUT: *** checking TuplePattern `()` (context_main.carbon:9) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (context_main.carbon:9) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (context_main.carbon:9) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (context_main.carbon:9) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (context_main.carbon:9) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (context_main.carbon:9) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (context_main.carbon:9) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (context_main.carbon:9) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (context_main.carbon:9) -// CHECK:STDOUT: *** finished declaring function `Main` of type `fn () -> i32` (context_main.carbon:11) -// CHECK:STDOUT: *** checking FunctionDeclaration `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: *** checking function `Main` (context_main.carbon:11) -// CHECK:STDOUT: --- impl declarations for `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: <<- finished checking `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> declaring function `Main` (context_main.carbon:11) +// CHECK:STDOUT: ->> checking TuplePattern `()` (context_main.carbon:9) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (context_main.carbon:9) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (context_main.carbon:9) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (context_main.carbon:9) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (context_main.carbon:9) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (context_main.carbon:9) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (context_main.carbon:9) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (context_main.carbon:9) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (context_main.carbon:9) +// CHECK:STDOUT: ->> finished declaring function `Main` of type `fn () -> i32` (context_main.carbon:11) +// CHECK:STDOUT: ->> checking FunctionDeclaration `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: ->> checking function `Main` (context_main.carbon:11) +// CHECK:STDOUT: ==> impl declarations for `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -160,21 +160,21 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** checking Block `{return 0;}` (context_main.carbon:11) -// CHECK:STDOUT: *** checking ReturnExpression `return 0;` (context_main.carbon:10) -// CHECK:STDOUT: *** checking IntLiteral `0` (context_main.carbon:10) -// CHECK:STDOUT: *** finished checking function `Main` (context_main.carbon:11) -// CHECK:STDOUT: *** checking CallExpression `Main()` (:0) -// CHECK:STDOUT: *** checking IdentifierExpression `Main` (:0) -// CHECK:STDOUT: *** checking TupleLiteral `()` (:0) -// CHECK:STDOUT: *** checking call to function of type `fn () -> i32` with arguments of type `()` (:0) -// CHECK:STDOUT: *** performing argument deduction for bindings: [] -// CHECK:STDOUT: --> deduction succeeded with results: [] +// CHECK:STDOUT: ->> checking Block `{return 0;}` (context_main.carbon:11) +// CHECK:STDOUT: ->> checking ReturnExpression `return 0;` (context_main.carbon:10) +// CHECK:STDOUT: ->> checking IntLiteral `0` (context_main.carbon:10) +// CHECK:STDOUT: ->> finished checking function `Main` (context_main.carbon:11) +// CHECK:STDOUT: ->> checking CallExpression `Main()` (:0) +// CHECK:STDOUT: ->> checking IdentifierExpression `Main` (:0) +// CHECK:STDOUT: ->> checking TupleLiteral `()` (:0) +// CHECK:STDOUT: ->> checking call to function of type `fn () -> i32` with arguments of type `()` (:0) +// CHECK:STDOUT: ->> performing argument deduction for bindings: [] +// CHECK:STDOUT: ==> deduction succeeded with results: [] // CHECK:STDOUT: ********** resolving unformed variables ********** -// CHECK:STDOUT: *** resolving-unformed in decl `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: *** resolving-unformed in decl `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: *** resolving-unformed in stmt `{return 0;}` (context_main.carbon:11) -// CHECK:STDOUT: *** resolving-unformed in stmt `return 0;` (context_main.carbon:10) +// CHECK:STDOUT: ->> resolving-unformed in decl `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> resolving-unformed in decl `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: ->> resolving-unformed in stmt `{return 0;}` (context_main.carbon:11) +// CHECK:STDOUT: ->> resolving-unformed in stmt `return 0;` (context_main.carbon:10) // CHECK:STDOUT: ********** printing declarations ********** // CHECK:STDOUT: interface TestInterface { // CHECK:STDOUT: } @@ -186,57 +186,57 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: ********** starting execution ********** // CHECK:STDOUT: ********** initializing globals ********** -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `interface TestInterface` (context_main.carbon:7) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `fn Main` (context_main.carbon:11) // CHECK:STDOUT: ********** calling main function ********** -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> -// CHECK:STDOUT: calling function: fun
+// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> +// CHECK:STDOUT: -() calling function: fun
// CHECK:STDOUT: match pattern () // CHECK:STDOUT: from value expression with value () -// CHECK:STDOUT: (+) stack-push: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) -// CHECK:STDOUT: --- step StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) ---> -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `return 0;` (context_main.carbon:10) -// CHECK:STDOUT: --- step StatementAction pos: 0 `return 0;` (context_main.carbon:10) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `0` (context_main.carbon:10) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `0` (context_main.carbon:10) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `0` (context_main.carbon:10) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `0` (context_main.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `0` (context_main.carbon:10) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `0` results: [`0`] (context_main.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `0` results: [`0`] (context_main.carbon:10) -// CHECK:STDOUT: --- step StatementAction pos: 1 `return 0;` results: [`0`] (context_main.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `return 0;` results: [`0`] (context_main.carbon:10) -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `{return 0;}` scope: [] (context_main.carbon:11) -// CHECK:STDOUT: (-) stack-pop: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) +// CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) ---> +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `return 0;` (context_main.carbon:10) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `return 0;` (context_main.carbon:10) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `0` (context_main.carbon:10) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `0` (context_main.carbon:10) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `0` (context_main.carbon:10) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `0` (context_main.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `0` (context_main.carbon:10) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `0` results: [`0`] (context_main.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `0` results: [`0`] (context_main.carbon:10) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `return 0;` results: [`0`] (context_main.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `return 0;` results: [`0`] (context_main.carbon:10) +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `{return 0;}` scope: [] (context_main.carbon:11) +// CHECK:STDOUT: <[] stack-pop: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) // CHECK:STDOUT: interpreter result: 0 // CHECK:STDOUT: ********** printing timing ********** // CHECK:STDOUT: Time elapsed in ExecProgram: {{\d+}}ms diff --git a/explorer/testdata/trace/context_prelude.carbon b/explorer/testdata/trace/context_prelude.carbon index fea2afd7a5d1..0a274c102054 100644 --- a/explorer/testdata/trace/context_prelude.carbon +++ b/explorer/testdata/trace/context_prelude.carbon @@ -15,5 +15,5 @@ fn Main() -> i32 { // ARGS: --trace_file=- --trace_phase=all --trace_file_context=prelude %s // NOAUTOUPDATE // SET-CHECK-SUBSET -// CHECK:STDOUT: *** declaring `interface As` (prelude.carbon:14) +// CHECK:STDOUT: ->> declaring `interface As` (prelude.carbon:14) // CHECK:STDOUT: interface As { diff --git a/explorer/testdata/trace/phase_all.carbon b/explorer/testdata/trace/phase_all.carbon index b612437f4da7..57ed72e22fb5 100644 --- a/explorer/testdata/trace/phase_all.carbon +++ b/explorer/testdata/trace/phase_all.carbon @@ -39,56 +39,56 @@ fn Main() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: ********** resolving names ********** -// CHECK:STDOUT: --- declared `TestInterface` as `interface TestInterface` in `package` (phase_all.carbon:7) -// CHECK:STDOUT: --- declared `N` as `namespace N` in `package` (phase_all.carbon:9) -// CHECK:STDOUT: --- resolved `N` as `namespace N` in `package` (phase_all.carbon:11) -// CHECK:STDOUT: --- declared `Foo` as `fn N.Foo` in `namespace N` (phase_all.carbon:13) -// CHECK:STDOUT: --- declared `Main` as `fn Main` in `package` (phase_all.carbon:18) -// CHECK:STDOUT: ** resolving decl `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: --- marked `TestInterface` declared but not usable in `package` -// CHECK:STDOUT: --- marked `TestInterface` usable in `package` -// CHECK:STDOUT: --- declared `Self` as `Self` in `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: ** finished resolving decl `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: ** resolving decl `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: --- marked `N` usable in `package` -// CHECK:STDOUT: ** finished resolving decl `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: ** resolving decl `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: --- resolved `N` as `namespace N` in `package` (phase_all.carbon:11) -// CHECK:STDOUT: --- marked `Foo` declared but not usable in `namespace N` -// CHECK:STDOUT: --- declared `n` as `n` in `fn N.Foo` (phase_all.carbon:11) -// CHECK:STDOUT: --- marked `Foo` usable in `namespace N` -// CHECK:STDOUT: ** resolving stmt `{return (n + 1);}` (phase_all.carbon:13) -// CHECK:STDOUT: ** resolving stmt `return (n + 1);` (phase_all.carbon:12) -// CHECK:STDOUT: --- resolved `n` as `n` in `fn N.Foo` (phase_all.carbon:12) -// CHECK:STDOUT: ** finished resolving stmt `return (n + 1);` (phase_all.carbon:12) -// CHECK:STDOUT: ** finished resolving stmt `{return (n + 1);}` (phase_all.carbon:13) -// CHECK:STDOUT: ** finished resolving decl `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: ** resolving decl `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: --- marked `Main` declared but not usable in `package` -// CHECK:STDOUT: --- marked `Main` usable in `package` -// CHECK:STDOUT: ** resolving stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) -// CHECK:STDOUT: ** resolving stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) -// CHECK:STDOUT: --- resolved `N` as `namespace N` in `package` (phase_all.carbon:16) -// CHECK:STDOUT: --- resolved `Foo` as `fn N.Foo` in `namespace N` (phase_all.carbon:16) -// CHECK:STDOUT: --- declared `x` as `x` in `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:16) -// CHECK:STDOUT: ** finished resolving stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) -// CHECK:STDOUT: ** resolving stmt `return x;` (phase_all.carbon:17) -// CHECK:STDOUT: --- resolved `x` as `x` in `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:17) -// CHECK:STDOUT: ** finished resolving stmt `return x;` (phase_all.carbon:17) -// CHECK:STDOUT: ** finished resolving stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) -// CHECK:STDOUT: ** finished resolving decl `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: --- resolved `Main` as `fn Main` in `package` (:0) +// CHECK:STDOUT: ==> declared `TestInterface` as `interface TestInterface` in `package` (phase_all.carbon:7) +// CHECK:STDOUT: ==> declared `N` as `namespace N` in `package` (phase_all.carbon:9) +// CHECK:STDOUT: ==> resolved `N` as `namespace N` in `package` (phase_all.carbon:11) +// CHECK:STDOUT: ==> declared `Foo` as `fn N.Foo` in `namespace N` (phase_all.carbon:13) +// CHECK:STDOUT: ==> declared `Main` as `fn Main` in `package` (phase_all.carbon:18) +// CHECK:STDOUT: ->> resolving decl `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ==> marked `TestInterface` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `TestInterface` usable in `package` +// CHECK:STDOUT: ==> declared `Self` as `Self` in `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: <<- finished resolving decl `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> resolving decl `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: ==> marked `N` usable in `package` +// CHECK:STDOUT: <<- finished resolving decl `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: ->> resolving decl `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ==> resolved `N` as `namespace N` in `package` (phase_all.carbon:11) +// CHECK:STDOUT: ==> marked `Foo` declared but not usable in `namespace N` +// CHECK:STDOUT: ==> declared `n` as `n` in `fn N.Foo` (phase_all.carbon:11) +// CHECK:STDOUT: ==> marked `Foo` usable in `namespace N` +// CHECK:STDOUT: ->> resolving stmt `{return (n + 1);}` (phase_all.carbon:13) +// CHECK:STDOUT: ->> resolving stmt `return (n + 1);` (phase_all.carbon:12) +// CHECK:STDOUT: ==> resolved `n` as `n` in `fn N.Foo` (phase_all.carbon:12) +// CHECK:STDOUT: <<- finished resolving stmt `return (n + 1);` (phase_all.carbon:12) +// CHECK:STDOUT: <<- finished resolving stmt `{return (n + 1);}` (phase_all.carbon:13) +// CHECK:STDOUT: <<- finished resolving decl `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> resolving decl `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: ==> marked `Main` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `Main` usable in `package` +// CHECK:STDOUT: ->> resolving stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) +// CHECK:STDOUT: ->> resolving stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) +// CHECK:STDOUT: ==> resolved `N` as `namespace N` in `package` (phase_all.carbon:16) +// CHECK:STDOUT: ==> resolved `Foo` as `fn N.Foo` in `namespace N` (phase_all.carbon:16) +// CHECK:STDOUT: ==> declared `x` as `x` in `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:16) +// CHECK:STDOUT: <<- finished resolving stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) +// CHECK:STDOUT: ->> resolving stmt `return x;` (phase_all.carbon:17) +// CHECK:STDOUT: ==> resolved `x` as `x` in `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:17) +// CHECK:STDOUT: <<- finished resolving stmt `return x;` (phase_all.carbon:17) +// CHECK:STDOUT: <<- finished resolving stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) +// CHECK:STDOUT: <<- finished resolving decl `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: ==> resolved `Main` as `fn Main` in `package` (:0) // CHECK:STDOUT: ********** resolving control flow ********** -// CHECK:STDOUT: --- flow-resolved return statement `return (n + 1);` in `fn N.Foo` (phase_all.carbon:12) -// CHECK:STDOUT: --- flow-resolved return statement `return x;` in `fn Main` (phase_all.carbon:17) +// CHECK:STDOUT: ==> flow-resolved return statement `return (n + 1);` in `fn N.Foo` (phase_all.carbon:12) +// CHECK:STDOUT: ==> flow-resolved return statement `return x;` in `fn Main` (phase_all.carbon:17) // CHECK:STDOUT: ********** type checking ********** -// CHECK:STDOUT: *** declaring `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: *** finished declaring `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: *** checking InterfaceDeclaration `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: *** checking `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: --- impl declarations for `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: ->> declaring `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: <<- finished declaring `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> checking InterfaceDeclaration `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> checking `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ==> impl declarations for `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -135,35 +135,35 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** finished checking `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: *** checking NamespaceDeclaration `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: *** declaring function `Foo` (phase_all.carbon:13) -// CHECK:STDOUT: *** checking TuplePattern `(n: i32)` (phase_all.carbon:11) -// CHECK:STDOUT: *** checking BindingPattern `n: i32` (phase_all.carbon:11) -// CHECK:STDOUT: *** checking ExpressionPattern `i32` (phase_all.carbon:11) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (phase_all.carbon:11) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) -// CHECK:STDOUT: *** finished checking tuple pattern field `n: i32` (phase_all.carbon:11) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (phase_all.carbon:11) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) -// CHECK:STDOUT: *** finished declaring function `Foo` of type `fn (i32,) -> i32` (phase_all.carbon:13) -// CHECK:STDOUT: *** checking FunctionDeclaration `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: *** checking function `Foo` (phase_all.carbon:13) -// CHECK:STDOUT: --- impl declarations for `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: <<- finished checking `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> checking NamespaceDeclaration `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: ->> declaring function `Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> checking TuplePattern `(n: i32)` (phase_all.carbon:11) +// CHECK:STDOUT: ->> checking BindingPattern `n: i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> checking ExpressionPattern `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (phase_all.carbon:11) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) +// CHECK:STDOUT: ->> finished checking tuple pattern field `n: i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (phase_all.carbon:11) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (phase_all.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:11) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:11) +// CHECK:STDOUT: ->> finished declaring function `Foo` of type `fn (i32,) -> i32` (phase_all.carbon:13) +// CHECK:STDOUT: ->> checking FunctionDeclaration `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> checking function `Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ==> impl declarations for `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -210,28 +210,28 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** checking Block `{return (n + 1);}` (phase_all.carbon:13) -// CHECK:STDOUT: *** checking ReturnExpression `return (n + 1);` (phase_all.carbon:12) -// CHECK:STDOUT: *** checking OperatorExpression `(n + 1)` (phase_all.carbon:12) -// CHECK:STDOUT: *** checking IdentifierExpression `n` (phase_all.carbon:12) -// CHECK:STDOUT: *** checking IntLiteral `1` (phase_all.carbon:12) -// CHECK:STDOUT: *** finished checking function `Foo` (phase_all.carbon:13) -// CHECK:STDOUT: *** declaring function `Main` (phase_all.carbon:18) -// CHECK:STDOUT: *** checking TuplePattern `()` (phase_all.carbon:15) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (phase_all.carbon:15) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:15) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:15) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:15) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (phase_all.carbon:15) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:15) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:15) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:15) -// CHECK:STDOUT: *** finished declaring function `Main` of type `fn () -> i32` (phase_all.carbon:18) -// CHECK:STDOUT: *** checking FunctionDeclaration `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: *** checking function `Main` (phase_all.carbon:18) -// CHECK:STDOUT: --- impl declarations for `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: ->> checking Block `{return (n + 1);}` (phase_all.carbon:13) +// CHECK:STDOUT: ->> checking ReturnExpression `return (n + 1);` (phase_all.carbon:12) +// CHECK:STDOUT: ->> checking OperatorExpression `(n + 1)` (phase_all.carbon:12) +// CHECK:STDOUT: ->> checking IdentifierExpression `n` (phase_all.carbon:12) +// CHECK:STDOUT: ->> checking IntLiteral `1` (phase_all.carbon:12) +// CHECK:STDOUT: ->> finished checking function `Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> declaring function `Main` (phase_all.carbon:18) +// CHECK:STDOUT: ->> checking TuplePattern `()` (phase_all.carbon:15) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (phase_all.carbon:15) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:15) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:15) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:15) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (phase_all.carbon:15) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:15) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:15) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:15) +// CHECK:STDOUT: ->> finished declaring function `Main` of type `fn () -> i32` (phase_all.carbon:18) +// CHECK:STDOUT: ->> checking FunctionDeclaration `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: ->> checking function `Main` (phase_all.carbon:18) +// CHECK:STDOUT: ==> impl declarations for `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -278,49 +278,49 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** checking Block `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) -// CHECK:STDOUT: *** checking VariableDefinition `var x: i32 = N.Foo(0);` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking CallExpression `N.Foo(0)` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking SimpleMemberAccessExpression `N.Foo` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking IdentifierExpression `Foo` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking TupleLiteral `(0)` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking IntLiteral `0` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking call to function of type `fn (i32,) -> i32` with arguments of type `(i32,)` (phase_all.carbon:16) -// CHECK:STDOUT: *** performing argument deduction for bindings: [] -// CHECK:STDOUT: *** deducing `i32` from `i32` -// CHECK:STDOUT: --> deduction succeeded with results: [] -// CHECK:STDOUT: *** checking BindingPattern `x: i32`, expecting `i32` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking ExpressionPattern `i32`, expecting `i32` (phase_all.carbon:16) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (phase_all.carbon:16) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:16) -// CHECK:STDOUT: *** checking ReturnExpression `return x;` (phase_all.carbon:17) -// CHECK:STDOUT: *** checking IdentifierExpression `x` (phase_all.carbon:17) -// CHECK:STDOUT: *** finished checking function `Main` (phase_all.carbon:18) -// CHECK:STDOUT: *** checking CallExpression `Main()` (:0) -// CHECK:STDOUT: *** checking IdentifierExpression `Main` (:0) -// CHECK:STDOUT: *** checking TupleLiteral `()` (:0) -// CHECK:STDOUT: *** checking call to function of type `fn () -> i32` with arguments of type `()` (:0) -// CHECK:STDOUT: *** performing argument deduction for bindings: [] -// CHECK:STDOUT: --> deduction succeeded with results: [] +// CHECK:STDOUT: ->> checking Block `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) +// CHECK:STDOUT: ->> checking VariableDefinition `var x: i32 = N.Foo(0);` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking CallExpression `N.Foo(0)` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking SimpleMemberAccessExpression `N.Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking IdentifierExpression `Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking TupleLiteral `(0)` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking IntLiteral `0` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking call to function of type `fn (i32,) -> i32` with arguments of type `(i32,)` (phase_all.carbon:16) +// CHECK:STDOUT: ->> performing argument deduction for bindings: [] +// CHECK:STDOUT: ->> deducing `i32` from `i32` +// CHECK:STDOUT: ==> deduction succeeded with results: [] +// CHECK:STDOUT: ->> checking BindingPattern `x: i32`, expecting `i32` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking ExpressionPattern `i32`, expecting `i32` (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (phase_all.carbon:16) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (phase_all.carbon:16) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_all.carbon:16) +// CHECK:STDOUT: ->> checking ReturnExpression `return x;` (phase_all.carbon:17) +// CHECK:STDOUT: ->> checking IdentifierExpression `x` (phase_all.carbon:17) +// CHECK:STDOUT: ->> finished checking function `Main` (phase_all.carbon:18) +// CHECK:STDOUT: ->> checking CallExpression `Main()` (:0) +// CHECK:STDOUT: ->> checking IdentifierExpression `Main` (:0) +// CHECK:STDOUT: ->> checking TupleLiteral `()` (:0) +// CHECK:STDOUT: ->> checking call to function of type `fn () -> i32` with arguments of type `()` (:0) +// CHECK:STDOUT: ->> performing argument deduction for bindings: [] +// CHECK:STDOUT: ==> deduction succeeded with results: [] // CHECK:STDOUT: ********** resolving unformed variables ********** -// CHECK:STDOUT: *** resolving-unformed in decl `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: *** resolving-unformed in decl `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: *** resolving-unformed in decl `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: *** resolving-unformed in stmt `{return (n + 1);}` (phase_all.carbon:13) -// CHECK:STDOUT: *** resolving-unformed in stmt `return (n + 1);` (phase_all.carbon:12) -// CHECK:STDOUT: --- check `n` (phase_all.carbon:12) -// CHECK:STDOUT: *** resolving-unformed in decl `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: *** resolving-unformed in stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) -// CHECK:STDOUT: *** resolving-unformed in stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) -// CHECK:STDOUT: --- add init `x` (phase_all.carbon:16) -// CHECK:STDOUT: *** resolving-unformed in stmt `return x;` (phase_all.carbon:17) -// CHECK:STDOUT: --- check `x` (phase_all.carbon:17) +// CHECK:STDOUT: ->> resolving-unformed in decl `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> resolving-unformed in decl `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: ->> resolving-unformed in decl `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> resolving-unformed in stmt `{return (n + 1);}` (phase_all.carbon:13) +// CHECK:STDOUT: ->> resolving-unformed in stmt `return (n + 1);` (phase_all.carbon:12) +// CHECK:STDOUT: ==> check `n` (phase_all.carbon:12) +// CHECK:STDOUT: ->> resolving-unformed in decl `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: ->> resolving-unformed in stmt `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) +// CHECK:STDOUT: ->> resolving-unformed in stmt `var x: i32 = N.Foo(0);` (phase_all.carbon:16) +// CHECK:STDOUT: ==> add init `x` (phase_all.carbon:16) +// CHECK:STDOUT: ->> resolving-unformed in stmt `return x;` (phase_all.carbon:17) +// CHECK:STDOUT: ==> check `x` (phase_all.carbon:17) // CHECK:STDOUT: ********** printing declarations ********** // CHECK:STDOUT: interface TestInterface { // CHECK:STDOUT: } @@ -339,146 +339,146 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: ********** starting execution ********** // CHECK:STDOUT: ********** initializing globals ********** -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `interface TestInterface` (phase_all.carbon:7) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `namespace N` (phase_all.carbon:9) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `fn N.Foo` (phase_all.carbon:13) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `fn Main` (phase_all.carbon:18) // CHECK:STDOUT: ********** calling main function ********** -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> -// CHECK:STDOUT: calling function: fun
+// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> +// CHECK:STDOUT: -() calling function: fun
// CHECK:STDOUT: match pattern () // CHECK:STDOUT: from value expression with value () -// CHECK:STDOUT: (+) stack-push: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) -// CHECK:STDOUT: --- step StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) ---> -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `var x: i32 = N.Foo(0);` (phase_all.carbon:16) -// CHECK:STDOUT: --- step StatementAction pos: 0 `var x: i32 = N.Foo(0);` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (+) memory-alloc: #1 `Uninit` uninitialized -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `N.Foo(0)` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `N.Foo(0)` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `N.Foo` results: [`fun`] (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `N.Foo` results: [`fun`] (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 1 `N.Foo(0)` results: [`fun`] scope: [] (phase_all.carbon:16) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `0` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `0` (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `0` (phase_all.carbon:16) -// CHECK:STDOUT: --- step ExpressionAction pos: 2 `N.Foo(0)` results: [`fun`, `0`] scope: [] (phase_all.carbon:16) ---> -// CHECK:STDOUT: calling function: fun +// CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) ---> +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `var x: i32 = N.Foo(0);` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `var x: i32 = N.Foo(0);` (phase_all.carbon:16) ---> +// CHECK:STDOUT: ++# memory-alloc: #1 `Uninit` uninitialized +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `N.Foo(0)` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `N.Foo(0)` (phase_all.carbon:16) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `N.Foo` (phase_all.carbon:16) +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `Foo` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `N.Foo` results: [`fun`] (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `N.Foo` results: [`fun`] (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 1 `N.Foo(0)` results: [`fun`] scope: [] (phase_all.carbon:16) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `0` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `0` (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `0` (phase_all.carbon:16) +// CHECK:STDOUT: ->> step ExpressionAction pos: 2 `N.Foo(0)` results: [`fun`, `0`] scope: [] (phase_all.carbon:16) ---> +// CHECK:STDOUT: -() calling function: fun // CHECK:STDOUT: match pattern (Placeholder,) // CHECK:STDOUT: from value expression with value (0,) // CHECK:STDOUT: match pattern Placeholder // CHECK:STDOUT: from value expression with value 0 -// CHECK:STDOUT: (+) stack-push: ScopeAction pos: 0 scope: [`n: i32`: `0`] (None) -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) -// CHECK:STDOUT: --- step StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) ---> -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `return (n + 1);` (phase_all.carbon:12) -// CHECK:STDOUT: --- step StatementAction pos: 0 `return (n + 1);` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `n` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `n` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `n` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `n` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `n` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `n` results: [`0`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `n` results: [`0`] (phase_all.carbon:12) -// CHECK:STDOUT: --- step ExpressionAction pos: 1 `(n + 1)` results: [`0`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `1` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `1` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `1` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `1` (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `1` (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `1` results: [`1`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `1` results: [`1`] (phase_all.carbon:12) -// CHECK:STDOUT: --- step ExpressionAction pos: 2 `(n + 1)` results: [`0`, `1`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 2 `(n + 1)` results: [`0`, `1`] (phase_all.carbon:12) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `(n + 1)` results: [`1`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `(n + 1)` results: [`1`] (phase_all.carbon:12) -// CHECK:STDOUT: --- step StatementAction pos: 1 `return (n + 1);` results: [`1`] (phase_all.carbon:12) ---> -// CHECK:STDOUT: +++ memory-write: #1 `1` -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `return (n + 1);` results: [`1`] (phase_all.carbon:12) -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `{return (n + 1);}` scope: [] (phase_all.carbon:13) -// CHECK:STDOUT: (-) stack-pop: ScopeAction pos: 0 scope: [`n: i32`: `0`] (None) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) -// CHECK:STDOUT: --- step ExpressionAction pos: 3 `N.Foo(0)` results: [`fun`, `0`, `1`] scope: [] (phase_all.carbon:16) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 3 `N.Foo(0)` results: [`fun`, `0`, `1`] scope: [] (phase_all.carbon:16) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step StatementAction pos: 1 `var x: i32 = N.Foo(0);` results: [`1`] (phase_all.carbon:16) ---> -// CHECK:STDOUT: +++ memory-read: #1 `1` +// CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [`n: i32`: `0`] (None) +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) ---> +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `return (n + 1);` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `return (n + 1);` (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `(n + 1)` (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `n` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `n` (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `n` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `n` (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `n` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `n` results: [`0`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `n` results: [`0`] (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ExpressionAction pos: 1 `(n + 1)` results: [`0`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `1` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `1` (phase_all.carbon:12) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `1` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `1` (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `1` (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `1` results: [`1`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `1` results: [`1`] (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ExpressionAction pos: 2 `(n + 1)` results: [`0`, `1`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 2 `(n + 1)` results: [`0`, `1`] (phase_all.carbon:12) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `(n + 1)` results: [`1`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `(n + 1)` results: [`1`] (phase_all.carbon:12) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `return (n + 1);` results: [`1`] (phase_all.carbon:12) ---> +// CHECK:STDOUT: --> memory-write: #1 `1` +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `return (n + 1);` results: [`1`] (phase_all.carbon:12) +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `{return (n + 1);}` scope: [] (phase_all.carbon:13) +// CHECK:STDOUT: <[] stack-pop: ScopeAction pos: 0 scope: [`n: i32`: `0`] (None) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [`n: i32`: `0`] (stack cleanup:1) +// CHECK:STDOUT: ->> step ExpressionAction pos: 3 `N.Foo(0)` results: [`fun`, `0`, `1`] scope: [] (phase_all.carbon:16) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 3 `N.Foo(0)` results: [`fun`, `0`, `1`] scope: [] (phase_all.carbon:16) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `var x: i32 = N.Foo(0);` results: [`1`] (phase_all.carbon:16) ---> +// CHECK:STDOUT: <-- memory-read: #1 `1` // CHECK:STDOUT: match pattern Placeholder // CHECK:STDOUT: from initializing expression with value 1 -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `var x: i32 = N.Foo(0);` results: [`1`] (phase_all.carbon:16) -// CHECK:STDOUT: --- step StatementAction pos: 1 `{var x: i32 = N.Foo(0);return x;}` scope: [`x: i32`: `lval`] (phase_all.carbon:18) ---> -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `return x;` (phase_all.carbon:17) -// CHECK:STDOUT: --- step StatementAction pos: 0 `return x;` (phase_all.carbon:17) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `x` (phase_all.carbon:17) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `x` (phase_all.carbon:17) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `x` (phase_all.carbon:17) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `x` (phase_all.carbon:17) ---> -// CHECK:STDOUT: +++ memory-read: #1 `1` -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `x` (phase_all.carbon:17) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `x` results: [`ref_expr`] (phase_all.carbon:17) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `x` results: [`ref_expr`] (phase_all.carbon:17) -// CHECK:STDOUT: --- step StatementAction pos: 1 `return x;` results: [`1`] (phase_all.carbon:17) ---> -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `return x;` results: [`1`] (phase_all.carbon:17) -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 2 `{var x: i32 = N.Foo(0);return x;}` scope: [`x: i32`: `lval`] (phase_all.carbon:18) -// CHECK:STDOUT: (-) stack-pop: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [`x: i32`: `lval`] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> -// CHECK:STDOUT: +++ memory-read: #1 `1` -// CHECK:STDOUT: (+) stack-push: DestroyAction pos: 0 (None) -// CHECK:STDOUT: --- step DestroyAction pos: 0 (None) ---> -// CHECK:STDOUT: (-) stack-pop: DestroyAction pos: 0 (None) -// CHECK:STDOUT: --- step CleanUpAction pos: 1 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) memory-dealloc: #1 `1` -// CHECK:STDOUT: --- step CleanUpAction pos: 2 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 2 scope: [`x: i32`: `lval`] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ExpressionAction pos: 2 `Main()` results: [`fun
`, `1`] scope: [] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `1`] scope: [] (:0) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main()` results: [`1`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`1`] (:0) +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `var x: i32 = N.Foo(0);` results: [`1`] (phase_all.carbon:16) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `{var x: i32 = N.Foo(0);return x;}` scope: [`x: i32`: `lval`] (phase_all.carbon:18) ---> +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `return x;` (phase_all.carbon:17) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `return x;` (phase_all.carbon:17) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `x` (phase_all.carbon:17) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `x` (phase_all.carbon:17) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `x` (phase_all.carbon:17) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `x` (phase_all.carbon:17) ---> +// CHECK:STDOUT: <-- memory-read: #1 `1` +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `x` (phase_all.carbon:17) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `x` results: [`ref_expr`] (phase_all.carbon:17) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `x` results: [`ref_expr`] (phase_all.carbon:17) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `return x;` results: [`1`] (phase_all.carbon:17) ---> +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `return x;` results: [`1`] (phase_all.carbon:17) +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 2 `{var x: i32 = N.Foo(0);return x;}` scope: [`x: i32`: `lval`] (phase_all.carbon:18) +// CHECK:STDOUT: <[] stack-pop: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [`x: i32`: `lval`] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> +// CHECK:STDOUT: <-- memory-read: #1 `1` +// CHECK:STDOUT: >[] stack-push: DestroyAction pos: 0 (None) +// CHECK:STDOUT: ->> step DestroyAction pos: 0 (None) ---> +// CHECK:STDOUT: <[] stack-pop: DestroyAction pos: 0 (None) +// CHECK:STDOUT: ->> step CleanUpAction pos: 1 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> +// CHECK:STDOUT: --# memory-dealloc: #1 `1` +// CHECK:STDOUT: ->> step CleanUpAction pos: 2 scope: [`x: i32`: `lval`] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 2 scope: [`x: i32`: `lval`] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ExpressionAction pos: 2 `Main()` results: [`fun
`, `1`] scope: [] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `1`] scope: [] (:0) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main()` results: [`1`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`1`] (:0) // CHECK:STDOUT: interpreter result: 1 // CHECK:STDOUT: ********** printing timing ********** // CHECK:STDOUT: Time elapsed in ExecProgram: {{\d+}}ms diff --git a/explorer/testdata/trace/phase_control_flow_resolution.carbon b/explorer/testdata/trace/phase_control_flow_resolution.carbon index 5c2111a1c3c9..e289d18db2fc 100644 --- a/explorer/testdata/trace/phase_control_flow_resolution.carbon +++ b/explorer/testdata/trace/phase_control_flow_resolution.carbon @@ -16,5 +16,5 @@ fn Main() -> i32 { // AUTOUPDATE // CHECK:STDOUT: ********** resolving control flow ********** -// CHECK:STDOUT: --- flow-resolved return statement `return 0;` in `fn Main` (phase_control_flow_resolution.carbon:10) +// CHECK:STDOUT: ==> flow-resolved return statement `return 0;` in `fn Main` (phase_control_flow_resolution.carbon:10) // CHECK:STDOUT: result: 0 diff --git a/explorer/testdata/trace/phase_execution.carbon b/explorer/testdata/trace/phase_execution.carbon index fed7c785a65a..08f60962b6ae 100644 --- a/explorer/testdata/trace/phase_execution.carbon +++ b/explorer/testdata/trace/phase_execution.carbon @@ -17,56 +17,56 @@ fn Main() -> i32 { // CHECK:STDOUT: ********** starting execution ********** // CHECK:STDOUT: ********** initializing globals ********** -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) -// CHECK:STDOUT: (+) stack-push: DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) -// CHECK:STDOUT: --- step DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) ---> -// CHECK:STDOUT: (-) stack-pop: DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `interface TestInterface` (phase_execution.carbon:7) +// CHECK:STDOUT: >[] stack-push: DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) +// CHECK:STDOUT: ->> step DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) ---> +// CHECK:STDOUT: <[] stack-pop: DeclarationAction pos: 0 `fn Main` (phase_execution.carbon:11) // CHECK:STDOUT: ********** calling main function ********** -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main()` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main()` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `Main` (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `Main` (:0) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) -// CHECK:STDOUT: --- step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> -// CHECK:STDOUT: calling function: fun
+// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main()` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main()` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `Main` (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `Main` (:0) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) +// CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> +// CHECK:STDOUT: -() calling function: fun
// CHECK:STDOUT: match pattern () // CHECK:STDOUT: from value expression with value () -// CHECK:STDOUT: (+) stack-push: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `{return 0;}` (phase_execution.carbon:11) -// CHECK:STDOUT: --- step StatementAction pos: 0 `{return 0;}` (phase_execution.carbon:11) ---> -// CHECK:STDOUT: (+) stack-push: StatementAction pos: 0 `return 0;` (phase_execution.carbon:10) -// CHECK:STDOUT: --- step StatementAction pos: 0 `return 0;` (phase_execution.carbon:10) ---> -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `0` (phase_execution.carbon:10) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `0` (phase_execution.carbon:10) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `0` (phase_execution.carbon:10) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `0` (phase_execution.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `0` (phase_execution.carbon:10) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `0` results: [`0`] (phase_execution.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `0` results: [`0`] (phase_execution.carbon:10) -// CHECK:STDOUT: --- step StatementAction pos: 1 `return 0;` results: [`0`] (phase_execution.carbon:10) ---> -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `return 0;` results: [`0`] (phase_execution.carbon:10) -// CHECK:STDOUT: (-) stack-pop: StatementAction pos: 1 `{return 0;}` scope: [] (phase_execution.carbon:11) -// CHECK:STDOUT: (-) stack-pop: ScopeAction pos: 0 scope: [] (None) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) -// CHECK:STDOUT: (+) stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> -// CHECK:STDOUT: (-) stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) +// CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return 0;}` (phase_execution.carbon:11) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `{return 0;}` (phase_execution.carbon:11) ---> +// CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `return 0;` (phase_execution.carbon:10) +// CHECK:STDOUT: ->> step StatementAction pos: 0 `return 0;` (phase_execution.carbon:10) ---> +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `0` (phase_execution.carbon:10) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `0` (phase_execution.carbon:10) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `0` (phase_execution.carbon:10) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `0` (phase_execution.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `0` (phase_execution.carbon:10) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `0` results: [`0`] (phase_execution.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `0` results: [`0`] (phase_execution.carbon:10) +// CHECK:STDOUT: ->> step StatementAction pos: 1 `return 0;` results: [`0`] (phase_execution.carbon:10) ---> +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `return 0;` results: [`0`] (phase_execution.carbon:10) +// CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `{return 0;}` scope: [] (phase_execution.carbon:11) +// CHECK:STDOUT: <[] stack-pop: ScopeAction pos: 0 scope: [] (None) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 2 `Main()` results: [`fun
`, `0`] scope: [] (:0) +// CHECK:STDOUT: >[] stack-push: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step CleanUpAction pos: 0 scope: [] (stack cleanup:1) ---> +// CHECK:STDOUT: <[] stack-pop: CleanUpAction pos: 0 scope: [] (stack cleanup:1) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main()` results: [`0`] (:0) // CHECK:STDOUT: interpreter result: 0 // CHECK:STDOUT: result: 0 diff --git a/explorer/testdata/trace/phase_name_resolution.carbon b/explorer/testdata/trace/phase_name_resolution.carbon index 0cc90a0303fa..c4adb029ac92 100644 --- a/explorer/testdata/trace/phase_name_resolution.carbon +++ b/explorer/testdata/trace/phase_name_resolution.carbon @@ -16,20 +16,20 @@ fn Main() -> i32 { // AUTOUPDATE // CHECK:STDOUT: ********** resolving names ********** -// CHECK:STDOUT: --- declared `TestInterface` as `interface TestInterface` in `package` (phase_name_resolution.carbon:7) -// CHECK:STDOUT: --- declared `Main` as `fn Main` in `package` (phase_name_resolution.carbon:11) -// CHECK:STDOUT: ** resolving decl `interface TestInterface` (phase_name_resolution.carbon:7) -// CHECK:STDOUT: --- marked `TestInterface` declared but not usable in `package` -// CHECK:STDOUT: --- marked `TestInterface` usable in `package` -// CHECK:STDOUT: --- declared `Self` as `Self` in `interface TestInterface` (phase_name_resolution.carbon:7) -// CHECK:STDOUT: ** finished resolving decl `interface TestInterface` (phase_name_resolution.carbon:7) -// CHECK:STDOUT: ** resolving decl `fn Main` (phase_name_resolution.carbon:11) -// CHECK:STDOUT: --- marked `Main` declared but not usable in `package` -// CHECK:STDOUT: --- marked `Main` usable in `package` -// CHECK:STDOUT: ** resolving stmt `{return 0;}` (phase_name_resolution.carbon:11) -// CHECK:STDOUT: ** resolving stmt `return 0;` (phase_name_resolution.carbon:10) -// CHECK:STDOUT: ** finished resolving stmt `return 0;` (phase_name_resolution.carbon:10) -// CHECK:STDOUT: ** finished resolving stmt `{return 0;}` (phase_name_resolution.carbon:11) -// CHECK:STDOUT: ** finished resolving decl `fn Main` (phase_name_resolution.carbon:11) -// CHECK:STDOUT: --- resolved `Main` as `fn Main` in `package` (:0) +// CHECK:STDOUT: ==> declared `TestInterface` as `interface TestInterface` in `package` (phase_name_resolution.carbon:7) +// CHECK:STDOUT: ==> declared `Main` as `fn Main` in `package` (phase_name_resolution.carbon:11) +// CHECK:STDOUT: ->> resolving decl `interface TestInterface` (phase_name_resolution.carbon:7) +// CHECK:STDOUT: ==> marked `TestInterface` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `TestInterface` usable in `package` +// CHECK:STDOUT: ==> declared `Self` as `Self` in `interface TestInterface` (phase_name_resolution.carbon:7) +// CHECK:STDOUT: <<- finished resolving decl `interface TestInterface` (phase_name_resolution.carbon:7) +// CHECK:STDOUT: ->> resolving decl `fn Main` (phase_name_resolution.carbon:11) +// CHECK:STDOUT: ==> marked `Main` declared but not usable in `package` +// CHECK:STDOUT: ==> marked `Main` usable in `package` +// CHECK:STDOUT: ->> resolving stmt `{return 0;}` (phase_name_resolution.carbon:11) +// CHECK:STDOUT: ->> resolving stmt `return 0;` (phase_name_resolution.carbon:10) +// CHECK:STDOUT: <<- finished resolving stmt `return 0;` (phase_name_resolution.carbon:10) +// CHECK:STDOUT: <<- finished resolving stmt `{return 0;}` (phase_name_resolution.carbon:11) +// CHECK:STDOUT: <<- finished resolving decl `fn Main` (phase_name_resolution.carbon:11) +// CHECK:STDOUT: ==> resolved `Main` as `fn Main` in `package` (:0) // CHECK:STDOUT: result: 0 diff --git a/explorer/testdata/trace/phase_type_checking.carbon b/explorer/testdata/trace/phase_type_checking.carbon index fe0dc171b410..07d3930044c5 100644 --- a/explorer/testdata/trace/phase_type_checking.carbon +++ b/explorer/testdata/trace/phase_type_checking.carbon @@ -16,13 +16,13 @@ fn Main() -> i32 { // AUTOUPDATE // CHECK:STDOUT: ********** type checking ********** -// CHECK:STDOUT: *** declaring `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: *** finished declaring `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: *** checking InterfaceDeclaration `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: *** checking `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: --- impl declarations for `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: ->> declaring `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: <<- finished declaring `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: ->> checking InterfaceDeclaration `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: ->> checking `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: ==> impl declarations for `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -69,23 +69,23 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** finished checking `interface TestInterface` (phase_type_checking.carbon:7) -// CHECK:STDOUT: *** declaring function `Main` (phase_type_checking.carbon:11) -// CHECK:STDOUT: *** checking TuplePattern `()` (phase_type_checking.carbon:9) -// CHECK:STDOUT: *** checking IntTypeLiteral `i32` (phase_type_checking.carbon:9) -// CHECK:STDOUT: (+) stack-push: ValueExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) ---> -// CHECK:STDOUT: (+) stack-push: ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) -// CHECK:STDOUT: --- step ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) ---> -// CHECK:STDOUT: (-) stack-pop: ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) -// CHECK:STDOUT: --- step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_type_checking.carbon:9) ---> -// CHECK:STDOUT: (-) stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_type_checking.carbon:9) -// CHECK:STDOUT: *** finished declaring function `Main` of type `fn () -> i32` (phase_type_checking.carbon:11) -// CHECK:STDOUT: *** checking FunctionDeclaration `fn Main` (phase_type_checking.carbon:11) -// CHECK:STDOUT: *** checking function `Main` (phase_type_checking.carbon:11) -// CHECK:STDOUT: --- impl declarations for `fn Main` (phase_type_checking.carbon:11) -// CHECK:STDOUT: + [] -// CHECK:STDOUT: + [`bool` as `interface EqWith(U = bool)`, +// CHECK:STDOUT: <<- finished checking `interface TestInterface` (phase_type_checking.carbon:7) +// CHECK:STDOUT: ->> declaring function `Main` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ->> checking TuplePattern `()` (phase_type_checking.carbon:9) +// CHECK:STDOUT: ->> checking IntTypeLiteral `i32` (phase_type_checking.carbon:9) +// CHECK:STDOUT: >[] stack-push: ValueExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) ---> +// CHECK:STDOUT: >[] stack-push: ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) +// CHECK:STDOUT: ->> step ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) ---> +// CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `i32` (phase_type_checking.carbon:9) +// CHECK:STDOUT: ->> step ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_type_checking.carbon:9) ---> +// CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `i32` results: [`i32`] (phase_type_checking.carbon:9) +// CHECK:STDOUT: ->> finished declaring function `Main` of type `fn () -> i32` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ->> checking FunctionDeclaration `fn Main` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ->> checking function `Main` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ==> impl declarations for `fn Main` (phase_type_checking.carbon:11) +// CHECK:STDOUT: [] +// CHECK:STDOUT: [`bool` as `interface EqWith(U = bool)`, // CHECK:STDOUT: `i32` as `interface EqWith(U = i32)`, // CHECK:STDOUT: `String` as `interface EqWith(U = String)`, // CHECK:STDOUT: `i32` as `interface CompareWith(U = i32)`, @@ -132,14 +132,14 @@ fn Main() -> i32 { // CHECK:STDOUT: `T` as `interface BitXorAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface LeftShiftAssignWith(U = U)` [0; 1, 1, 0], // CHECK:STDOUT: `T` as `interface RightShiftAssignWith(U = U)` [0; 1, 1, 0]] -// CHECK:STDOUT: *** checking Block `{return 0;}` (phase_type_checking.carbon:11) -// CHECK:STDOUT: *** checking ReturnExpression `return 0;` (phase_type_checking.carbon:10) -// CHECK:STDOUT: *** checking IntLiteral `0` (phase_type_checking.carbon:10) -// CHECK:STDOUT: *** finished checking function `Main` (phase_type_checking.carbon:11) -// CHECK:STDOUT: *** checking CallExpression `Main()` (:0) -// CHECK:STDOUT: *** checking IdentifierExpression `Main` (:0) -// CHECK:STDOUT: *** checking TupleLiteral `()` (:0) -// CHECK:STDOUT: *** checking call to function of type `fn () -> i32` with arguments of type `()` (:0) -// CHECK:STDOUT: *** performing argument deduction for bindings: [] -// CHECK:STDOUT: --> deduction succeeded with results: [] +// CHECK:STDOUT: ->> checking Block `{return 0;}` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ->> checking ReturnExpression `return 0;` (phase_type_checking.carbon:10) +// CHECK:STDOUT: ->> checking IntLiteral `0` (phase_type_checking.carbon:10) +// CHECK:STDOUT: ->> finished checking function `Main` (phase_type_checking.carbon:11) +// CHECK:STDOUT: ->> checking CallExpression `Main()` (:0) +// CHECK:STDOUT: ->> checking IdentifierExpression `Main` (:0) +// CHECK:STDOUT: ->> checking TupleLiteral `()` (:0) +// CHECK:STDOUT: ->> checking call to function of type `fn () -> i32` with arguments of type `()` (:0) +// CHECK:STDOUT: ->> performing argument deduction for bindings: [] +// CHECK:STDOUT: ==> deduction succeeded with results: [] // CHECK:STDOUT: result: 0 diff --git a/explorer/testdata/trace/phase_unformed_variables_resolution.carbon b/explorer/testdata/trace/phase_unformed_variables_resolution.carbon index 7872dfb379f7..c371c37535d1 100644 --- a/explorer/testdata/trace/phase_unformed_variables_resolution.carbon +++ b/explorer/testdata/trace/phase_unformed_variables_resolution.carbon @@ -16,8 +16,8 @@ fn Main() -> i32 { // AUTOUPDATE // CHECK:STDOUT: ********** resolving unformed variables ********** -// CHECK:STDOUT: *** resolving-unformed in decl `interface TestInterface` (phase_unformed_variables_resolution.carbon:7) -// CHECK:STDOUT: *** resolving-unformed in decl `fn Main` (phase_unformed_variables_resolution.carbon:11) -// CHECK:STDOUT: *** resolving-unformed in stmt `{return 0;}` (phase_unformed_variables_resolution.carbon:11) -// CHECK:STDOUT: *** resolving-unformed in stmt `return 0;` (phase_unformed_variables_resolution.carbon:10) +// CHECK:STDOUT: ->> resolving-unformed in decl `interface TestInterface` (phase_unformed_variables_resolution.carbon:7) +// CHECK:STDOUT: ->> resolving-unformed in decl `fn Main` (phase_unformed_variables_resolution.carbon:11) +// CHECK:STDOUT: ->> resolving-unformed in stmt `{return 0;}` (phase_unformed_variables_resolution.carbon:11) +// CHECK:STDOUT: ->> resolving-unformed in stmt `return 0;` (phase_unformed_variables_resolution.carbon:10) // CHECK:STDOUT: result: 0