Skip to content

Commit

Permalink
json: Make the JSON parser deterministic
Browse files Browse the repository at this point in the history
Signed-off-by: David Shah <[email protected]>
  • Loading branch information
gatecat committed Jun 19, 2018
1 parent 10785bd commit 1d34507
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frontend/json/jsonparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <iostream>
#include <log.h>
#include <string>
#include <map>
#include "nextpnr.h"

NEXTPNR_NAMESPACE_BEGIN
Expand All @@ -47,7 +48,7 @@ struct JsonNode
string data_string;
int data_number;
std::vector<JsonNode *> data_array;
std::unordered_map<string, JsonNode *> data_dict;
std::map<string, JsonNode *> data_dict;
std::vector<string> data_dict_keys;

JsonNode(std::istream &f)
Expand Down Expand Up @@ -748,11 +749,12 @@ void json_import(Context *ctx, string modname, JsonNode *node)
int netid = bits->data_array.at(i)->data_number;
if (netid >= netnames.size())
netnames.resize(netid + 1);
netnames.at(netid) = ctx->id(
basename +
(num_bits == 1 ? "" : std::string("[") +
std::to_string(i) +
std::string("]")));
netnames.at(netid) =
ctx->id(basename +
(num_bits == 1 ? ""
: std::string("[") +
std::to_string(i) +
std::string("]")));
}
}
}
Expand Down

0 comments on commit 1d34507

Please sign in to comment.