ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
json_utils.h File Reference
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <functional>
#include <map>
#include <unordered_map>
#include <vector>
#include <nlohmann/json.hpp>
Include dependency graph for json_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  json_utils

Macros

#define DUMP_OBJECT(obj)

Functions

bool json_utils::ast_equal_ignoring_location (const nlohmann::json &a, const nlohmann::json &b)
bool json_utils::ast_location_key (const std::string &k)
bool json_utils::ast_objects_equal_ignoring_location (const nlohmann::json &a, const nlohmann::json &b)
bool json_utils::ast_arrays_equal_ignoring_location (const nlohmann::json &a, const nlohmann::json &b)
bool json_utils::ast_contains_call (const nlohmann::json &n)
 True for X = Y between two bare names, such as _Elem = int.
bool json_utils::is_name_alias (const nlohmann::json &stmt)
std::string json_utils::dotted_to_path (const std::string &module_name)
 Convert a dotted Python module name to a filesystem path segment.
template<typename JsonType>
bool json_utils::search_function_in_ast (const JsonType &node, const std::string &func_name)
template<typename JsonType>
JsonType json_utils::find_class (const JsonType &ast_json, const std::string &class_name)
template<class Json>
Json json_utils::find_attr_annotation (const Json &class_node, const std::string &attr)
 The annotation of self.
template<class Json>
std::size_t json_utils::count_attr_stores (const Json &node, const std::string &attr, bool non_self_only)
 Counts the stores and deletions of <obj>.
template<class Json>
std::string json_utils::constructed_attr_class (const Json &class_node, const std::string &attr)
 C when the __init__ of class_node holds self.
template<typename JsonType>
bool json_utils::is_property_def (const JsonType &function_def)
template<typename JsonType>
bool json_utils::any_class_has_property (const JsonType &ast_body, const std::string &name)
template<typename JsonType>
bool json_utils::any_class_defines_method (const JsonType &node, const std::string &name)
 True when a class anywhere under node defines a method named name.
template<typename JsonType>
bool json_utils::is_property_method (const JsonType &ast_body, const std::string &class_name, const std::string &method_name)
template<typename JsonType>
bool json_utils::class_defines_method (const JsonType &ast_body, const std::string &class_name, const std::string &method_name)
 True when class_name or one of its (transitive) base classes defines a method named method_name.
template<typename JsonType>
std::size_t json_utils::count_class_defs (const JsonType &node)
 Counts every ClassDef under node, at any depth.
template<typename JsonType>
unsigned json_utils::count_function_scope_classes (const JsonType &body, const std::string &class_name, bool in_function=false)
 Counts the ClassDef nodes named class_name that sit inside a function body under body.
template<typename JsonType>
void json_utils::collect_class_definition_lines (const JsonType &node, const std::string &class_name, std::vector< int > &lines)
 Source lines of every ClassDef named class_name under node that the converter registers: at any scope except directly inside a class body.
template<typename JsonType>
bool json_utils::is_class (const std::string &name, const JsonType &ast_json)
template<typename JsonType>
bool json_utils::is_module (const std::string &module_name, const JsonType &ast)
template<typename JsonType>
JsonType json_utils::try_find_function (const JsonType &json, const std::string &func_name)
 Returns an empty JsonType on a miss. Never throws.
template<typename JsonType>
JsonType & json_utils::find_function_or_throw (JsonType &json, const std::string &func_name)
 Throws std::runtime_error on a miss.
template<typename JsonType>
bool json_utils::is_imported_from (const JsonType &ast, const std::string &module, const std::string &entity)
 True when from <module> import <entity> appears at the AST top level.
template<typename JsonType>
const JsonType & json_utils::find_imported_function (const JsonType &ast, const std::string &func_name)
std::string json_utils::dotted_name (const nlohmann::json &node)
 The dotted name a Name or Attribute node spells, e.g. "collections.abc.Set".
std::string json_utils::resolve_import (const nlohmann::json &ast, const std::string &name)
 What dotted name denotes through the module's imports, e.g.
std::string json_utils::collections_abc_class (const nlohmann::json &ast, const std::string &name)
 The collections.abc class that dotted name denotes, or empty.
template<typename JsonType>
const std::string json_utils::get_object_alias (const JsonType &ast, const std::string &obj_name)
template<typename JsonType>
const JsonType json_utils::get_var_node (const std::string &var_name, const JsonType &block)
std::vector< std::string > json_utils::split_function_path (const std::string &function)
template<typename JsonType>
const JsonType * json_utils::class_method_scope (const JsonType &body, std::string &name)
template<typename JsonType>
JsonType json_utils::find_function_by_path (const JsonType &ast, const std::vector< std::string > &path)
template<typename JsonType>
JsonType json_utils::find_var_in_function (const std::string &var_name, const JsonType &func_node)
template<typename JsonType>
const JsonType json_utils::find_var_decl (const std::string &var_name, const std::string &function, const JsonType &ast)
template<typename JsonType>
std::string json_utils::get_annotation_type_name (const JsonType &annotation)
std::vector< std::string > json_utils::split_top_level_params (const std::string &s)
 Split a rendered parameter list on commas that are not inside brackets, trimming each part.
template<typename JsonType>
std::string json_utils::render_annotation_type (const JsonType &annotation)
 The full generic spelling of an annotation node, e.g.
template<typename JsonType>
const JsonType json_utils::get_var_value (const std::string &var_name, const std::string &function, const JsonType &ast)
std::size_t json_utils::binds_by_field (const nlohmann::json &node, const std::string &kind, const std::string &name)
std::size_t json_utils::count_name_bindings (const nlohmann::json &node, const std::string &name)
const nlohmann::json * json_utils::top_level_value (const nlohmann::json &module, const std::string &name)
template<typename JsonType>
bool json_utils::has_multiple_assignments_in_block (const std::string &var_name, const JsonType &block)
template<typename JsonType>
bool json_utils::has_multiple_assignments_in_scope (const std::string &var_name, const std::string &function, const JsonType &ast)
template<typename JsonType>
bool json_utils::extract_constant_integer (const JsonType &node, const std::string &function, const JsonType &ast, long long &value)
template<typename JsonType>
const JsonType json_utils::get_list_element (const JsonType &list_value, int pos)
template<typename JsonType>
const JsonType json_utils::find_return_node (const JsonType &block)
std::string json_utils::extract_var_name_from_symbol_id (const std::string &symbol_id)
 Extract the variable name from a symbol identifier Examples: "py:test.py@l" -> "l" "py:test.py@F@foo@x" -> "x" "py:test.py@C@MyClass@F@method@var" -> "var".
template<typename JsonType>
JsonType json_utils::build_char_sequence_node (const char *kind, const std::string &chars, const JsonType &loc_src)
template<typename JsonType>
bool json_utils::has_overload_decorator (const JsonType &func_node)
template<typename JsonType>
std::string json_utils::imported_function_return_type (const std::string &name, const JsonType &ast_json)
 The declared return-type name of a function name defined in a module this AST imports, or "" if there is none.
void json_utils::collect_return_values (const nlohmann::json &node, std::vector< nlohmann::json > &values)

Macro Definition Documentation

◆ DUMP_OBJECT

#define DUMP_OBJECT ( obj)
Value:
printf("%s\n", (obj).dump(2).c_str())
int printf(const char *__ESBMC_restrict format,...)