Explorer: improve type checking trace output (#3039)

Updates the trace output for type checking to be more consistent like
the rest of trace output.
This PR also includes few changes in the lit tests related to trace
output.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Prabhat SachdevaandRichard Smith authored and GitHub committed 2023-08-08 17:58:12 +00:00
1 parent 6d3a4b84cb
commit a359da37c4
10 files changed
+638 -259

No files matched your search

+28 -12
View File
@@ -37,23 +37,39 @@ void Bindings::Add(Nonnull<const GenericBinding*> binding,
}
}
void Bindings::Print(llvm::raw_ostream& out) const {
std::vector<std::pair<Nonnull<const GenericBinding*>, Nonnull<const Value*>>>
args(args_.begin(), args_.end());
std::vector<std::pair<Nonnull<const ImplBinding*>, Nonnull<const Value*>>>
witnesses(witnesses_.begin(), witnesses_.end());
std::stable_sort(args.begin(), args.end(), [](const auto& a, const auto& b) {
return a.first->index() < b.first->index();
});
std::stable_sort(
witnesses.begin(), witnesses.end(), [](const auto& a, const auto& b) {
return a.first->type_var()->index() < b.first->type_var()->index();
});
llvm::ListSeparator sep;
out << " > bindings args: [";
for (const auto& [binding, value] : args) {
out << sep << "`" << *binding << "`: `" << *value << "`";
}
out << "]\n > bindings witnesses: [";
for (const auto& [binding, value] : witnesses) {
out << sep << "`" << *binding << "`: `" << *value << "`";
}
out << "]";
};
auto Bindings::None() -> Nonnull<const Bindings*> {
static Nonnull<const Bindings*> bindings = new Bindings;
return bindings;
}
void Bindings::Print(llvm::raw_ostream& out) const {
out << "{";
llvm::ListSeparator sep;
for (const auto& [name, value] : args_) {
out << sep << *name << " -> " << *value;
}
for (const auto& [name, value] : witnesses_) {
out << sep << *name << " -> " << *value;
}
out << "}";
}
auto Bindings::SymbolicIdentity(
Nonnull<Arena*> arena,
llvm::ArrayRef<Nonnull<const GenericBinding*>> bindings)