Add --json-only and related JSON dumping (#4715) (#4831).

This commit is contained in:
Szymon Gizler
2024-02-09 17:50:09 -05:00
committed by Wilson Snyder
parent 248de2be2e
commit d667b73e8d
103 changed files with 27663 additions and 180 deletions
+23
View File
@@ -22,6 +22,7 @@
#include <iomanip>
#include <memory>
#include <sstream>
VL_DEFINE_DEBUG_FUNCTIONS;
@@ -1330,6 +1331,28 @@ void AstNode::dumpTreeDot(std::ostream& os) const {
drawChildren(os, this, m_op4p, "op4");
}
void AstNode::dumpTreeJsonFile(const string& filename, bool doDump) {
if (!doDump) return;
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> treejsonp{V3File::new_ofstream(filename)};
if (treejsonp->fail()) v3fatal("Can't write " << filename);
dumpTreeJson(*treejsonp);
*treejsonp << '\n';
}
void AstNode::dumpJsonMetaFile(const string& filename) {
UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> treejsonp{V3File::new_ofstream(filename)};
if (treejsonp->fail()) v3fatal("Can't write " << filename);
*treejsonp << '{';
FileLine::fileNameNumMapDumpJson(*treejsonp);
*treejsonp << ',';
v3Global.idPtrMapDumpJson(*treejsonp);
*treejsonp << ',';
v3Global.ptrNamesDumpJson(*treejsonp);
*treejsonp << "}\n";
}
void AstNode::dumpTreeDotFile(const string& filename, bool doDump) {
if (doDump) {
UINFO(2, "Dumping " << filename << endl);