aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-06-21 16:16:58 +0200
committerClifford Wolf <clifford@clifford.at>2018-06-21 16:16:58 +0200
commit4fefdbd57c52d6373456bd379e3e54df770e1945 (patch)
tree668c93671338f4482b163c2e8f40298cbedcb2c0 /frontend
parent417e67938c12be20a1c314d42386ede0ad8993a7 (diff)
downloadnextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.tar.gz
nextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.tar.bz2
nextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.zip
Cleanup parse_json_file API, some other cleanups
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'frontend')
-rw-r--r--frontend/json/jsonparse.cc37
-rw-r--r--frontend/json/jsonparse.h2
2 files changed, 13 insertions, 26 deletions
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc
index 277e602a..7d9e9dcf 100644
--- a/frontend/json/jsonparse.cc
+++ b/frontend/json/jsonparse.cc
@@ -795,39 +795,26 @@ void json_import(Context *ctx, string modname, JsonNode *node)
}
check_all_nets_driven(ctx);
}
+}; // End Namespace JsonParser
-struct JsonFrontend
+void parse_json_file(std::istream &f, std::string &filename, Context *ctx)
{
- // JsonFrontend() : Frontend("json", "read JSON file") { }
- JsonFrontend(void) {}
- virtual void help() {}
- virtual void execute(std::istream *&f, std::string &filename, Context *ctx)
- {
- // log_header(ctx, "Executing JSON frontend.\n");
+ using namespace JsonParser;
- JsonNode root(*f);
+ JsonNode root(f);
- if (root.type != 'D')
- log_error("JSON root node is not a dictionary.\n");
+ if (root.type != 'D')
+ log_error("JSON root node is not a dictionary.\n");
- if (root.data_dict.count("modules") != 0) {
- JsonNode *modules = root.data_dict.at("modules");
+ if (root.data_dict.count("modules") != 0) {
+ JsonNode *modules = root.data_dict.at("modules");
- if (modules->type != 'D')
- log_error("JSON modules node is not a dictionary.\n");
+ if (modules->type != 'D')
+ log_error("JSON modules node is not a dictionary.\n");
- for (auto &it : modules->data_dict)
- json_import(ctx, it.first, it.second);
- }
+ for (auto &it : modules->data_dict)
+ json_import(ctx, it.first, it.second);
}
-}; // JsonFrontend;
-
-}; // End Namespace JsonParser
-
-void parse_json_file(std::istream *&f, std::string &filename, Context *ctx)
-{
- auto *parser = new JsonParser::JsonFrontend();
- parser->execute(f, filename, ctx);
log_info("Checksum: 0x%08x\n", ctx->checksum());
log_break();
diff --git a/frontend/json/jsonparse.h b/frontend/json/jsonparse.h
index ee3d19ca..351b6558 100644
--- a/frontend/json/jsonparse.h
+++ b/frontend/json/jsonparse.h
@@ -26,7 +26,7 @@
NEXTPNR_NAMESPACE_BEGIN
-extern void parse_json_file(std::istream *&, std::string &, Context *);
+extern void parse_json_file(std::istream &, std::string &, Context *);
NEXTPNR_NAMESPACE_END