30inline const nlohmann::json *
33 const std::string type = node.value(
"_type",
"");
34 const nlohmann::json *target = type ==
"Assign" && node[
"targets"].size() == 1
36 : type ==
"AnnAssign" ? &node[
"target"]
39 !target || target->value(
"_type",
"") !=
"Name" ||
40 target->value(
"id",
"") != name || !node[
"value"].is_object() ||
41 node[
"value"].value(
"_type",
"") !=
"Constant")
43 return &node[
"value"];
52 const nlohmann::json &node,
53 const std::string &name,
55 const nlohmann::json *&
value)
58 count += node.get<std::string>() == name;
60 for (
const auto &item : node)
62 if (!node.is_object())
64 const std::string type = node.value(
"_type",
"");
65 if (type ==
"Name" || type ==
"Constant")
68 node.contains(
"ctx") && node[
"ctx"].value(
"_type",
"") ==
"Load";
69 count += type ==
"Name" && node.value(
"id",
"") == name && !load;
74 for (
const auto &item : node.items())
75 if (item.key() !=
"_type")
89 const std::string type =
key.value(
"_type",
"");
90 if (type ==
"Constant")
91 return key[
"value"].dump();
95 const nlohmann::json *
value =
nullptr;
97 return count == 1 &&
value ? (*value)[
"value"].dump() : std::string();
int count
Definition cuda.h:51
Handler for Python dictionary operations in ESBMC's Python frontend.
std::string dict_key_id(const nlohmann::json &key, const nlohmann::json &ast)
The source literal of a constant dict key, e.g.
Definition python_dict_internal.h:85
const nlohmann::json * constant_bound_to(const nlohmann::json &node, const std::string &name)
The Constant that statement node binds to name alone, as in name = c or name: T = c,...
Definition python_dict_internal.h:31
void count_name_bindings(const nlohmann::json &node, const std::string &name, unsigned &count, const nlohmann::json *&value)
Counts every binding of name in node (a Name it stores or deletes, a parameter, def,...
Definition python_dict_internal.h:51
uint256_t key
Definition solidity_mapping.c:1