mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Switch SemanticsIR dumps to produce YAML (#2517)
The parser and lexer already produce YAML, so this is fundamentally a consistency issue. I've been thinking about this, and was looking again because I'm working on adding callables, and figured I'd just fix it now.
This commit is contained in:
@@ -75,45 +75,43 @@ auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir,
|
||||
auto SemanticsIR::Print(llvm::raw_ostream& out) const -> void {
|
||||
constexpr int Indent = 2;
|
||||
|
||||
out << "cross_reference_irs.size == " << cross_reference_irs_.size() << ",\n";
|
||||
out << "cross_reference_irs_size: " << cross_reference_irs_.size() << "\n";
|
||||
|
||||
out << "integer_literals = {\n";
|
||||
out << "integer_literals: [\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(integer_literals_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsIntegerLiteralId(i) << " = " << integer_literals_[i]
|
||||
<< ";\n";
|
||||
out << integer_literals_[i] << ",\n";
|
||||
}
|
||||
out << "},\n";
|
||||
out << "]\n";
|
||||
|
||||
out << "strings = {\n";
|
||||
out << "strings: [\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(strings_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsStringId(i) << " = \"" << strings_[i] << "\";\n";
|
||||
out << strings_[i] << ",\n";
|
||||
}
|
||||
out << "},\n";
|
||||
out << "]\n";
|
||||
|
||||
out << "nodes = {\n";
|
||||
out << "nodes: [\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(nodes_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsNodeId(i) << " = " << nodes_[i] << ";\n";
|
||||
out << nodes_[i] << ",\n";
|
||||
}
|
||||
out << "},\n";
|
||||
out << "]\n";
|
||||
|
||||
out << "node_blocks = {\n";
|
||||
out << "node_blocks: [\n";
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(node_blocks_.size()); ++i) {
|
||||
out.indent(Indent);
|
||||
out << SemanticsNodeBlockId(i) << " = {\n";
|
||||
out << "[\n";
|
||||
|
||||
const auto& node_block = node_blocks_[i];
|
||||
for (int32_t i = 0; i < static_cast<int32_t>(node_block.size()); ++i) {
|
||||
out.indent(2 * Indent);
|
||||
out << node_block[i] << ";\n";
|
||||
out << node_block[i] << ",\n";
|
||||
}
|
||||
|
||||
out.indent(Indent);
|
||||
out << "},\n";
|
||||
out << "],\n";
|
||||
}
|
||||
out << "}\n";
|
||||
out << "]\n";
|
||||
}
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user