Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the json loader and parser independent from the generated ir files. #5055

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Temporary check
  • Loading branch information
fruffy committed Dec 12, 2024
commit d132111eae84c804e1e8a85470518df8d94221f1
29 changes: 15 additions & 14 deletions ir/json_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ limitations under the License.
#define IR_JSON_GENERATOR_H_

#include <optional>
#include <set>
#include <string>
#include <unordered_set>
#include <variant>

#include "ir/node.h"
#include "ir/inode.h"
#include "lib/bitvec.h"
#include "lib/cstring.h"
#include "lib/indent.h"
Expand Down Expand Up @@ -247,19 +248,19 @@ class JSONGenerator {
out << std::endl << --indent << "}";
}

void generate(const IR::Node &v) {
out << "{" << std::endl;
++indent;
if (node_refs.find(v.id) != node_refs.end()) {
out << indent << "\"Node_ID\" : " << v.id;
} else {
node_refs.insert(v.id);
v.toJSON(*this);
if (dumpSourceInfo) {
v.sourceInfoToJSON(*this);
}
}
out << std::endl << --indent << "}";
void generate(const IR::INode &v) {
// out << "{" << std::endl;
// ++indent;
// if (node_refs.find(v.id) != node_refs.end()) {
// out << indent << "\"Node_ID\" : " << v.id;
// } else {
// node_refs.insert(v.id);
// v.toJSON(*this);
// if (dumpSourceInfo) {
// v.sourceInfoToJSON(*this);
// }
// }
// out << std::endl << --indent << "}";
}

template <typename T>
Expand Down
3 changes: 1 addition & 2 deletions ir/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ cstring IR::Node::prepareSourceInfoForJSON(Util::SourceInfo &si, unsigned *lineN
if (!si.isValid()) {
return nullptr;
}
if (is<IR::AssignmentStatement>()) {
auto assign = to<IR::AssignmentStatement>();
if (auto assign = to<IR::AssignmentStatement>()) {
si = (assign->left->srcInfo + si) + assign->right->srcInfo;
}
return si.toSourcePositionData(lineNumber, columnNumber);
Expand Down
Loading