ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
function_values.h
Go to the documentation of this file.
1#pragma once
2
3#include <nlohmann/json.hpp>
4
5#include <map>
6#include <optional>
7#include <string>
8#include <utility>
9#include <vector>
10
18{
19public:
21 struct candidate
22 {
23 const nlohmann::json *def;
24 const nlohmann::json *module;
25 };
26
30 const nlohmann::json &module,
31 const std::vector<const nlohmann::json *> &others);
32
35 std::optional<std::vector<candidate>> of(const nlohmann::json &expr);
36
39 std::optional<std::vector<const nlohmann::json *>>
40 parameter_arguments(const nlohmann::json &name);
41
42private:
44 using chaint = std::vector<const nlohmann::json *>;
45 using valuet = std::pair<const nlohmann::json *, chaint>;
46
48 const nlohmann::json *locate(const nlohmann::json &expr, chaint &chain);
49
50 bool resolve(
51 const nlohmann::json &expr,
52 const chaint &chain,
53 std::vector<candidate> &out,
54 unsigned depth);
55 bool name_values(
56 const nlohmann::json &name,
57 const chaint &chain,
58 std::vector<valuet> &values,
59 std::vector<candidate> &out);
60 bool local_values(
61 const nlohmann::json &name,
62 const chaint &chain,
63 std::vector<valuet> &values);
64 bool module_name_values(
65 const nlohmann::json &name,
66 const chaint &chain,
67 std::vector<valuet> &values,
68 std::vector<candidate> &out);
69 bool parameter_values(
70 const nlohmann::json &def,
71 const chaint &chain,
72 const std::string &name,
73 std::vector<valuet> &values);
77 std::optional<std::vector<std::pair<const nlohmann::json *, std::string>>>
78 callers_of(const nlohmann::json &def, const nlohmann::json &module) const;
81 bool bound_arguments(
82 const nlohmann::json &module,
83 const nlohmann::json *scope,
84 const std::string &callee,
85 const nlohmann::json &args,
86 std::size_t index,
87 const std::string &name,
88 std::vector<valuet> &values) const;
90 bool
91 only_called(const nlohmann::json &def, const nlohmann::json &module) const;
92 bool element_values(
93 const nlohmann::json &subscript,
94 const chaint &chain,
95 std::vector<valuet> &values);
96 bool returned_values(
97 const std::vector<candidate> &callees,
98 std::vector<valuet> &values);
99 bool imported_function(
100 const nlohmann::json &module,
101 const nlohmann::json &import_from,
102 const nlohmann::json &alias,
103 std::vector<candidate> &out);
105 bool mentioned_elsewhere(
106 const nlohmann::json &module,
107 const std::string &name) const;
108
109 const nlohmann::json &module_;
110 std::vector<const nlohmann::json *> others_;
112 std::map<std::string, nlohmann::json> loaded_;
113};
std::optional< std::vector< const nlohmann::json * > > parameter_arguments(const nlohmann::json &name)
The values a read name of a parameter of a module-level def may hold: the argument each caller passes...
Definition function_values.cpp:506
function_values(const nlohmann::json &module, const std::vector< const nlohmann::json * > &others)
others are the program's other modules, searched for uses of this module's functions.
Definition function_values.cpp:470
std::optional< std::vector< candidate > > of(const nlohmann::json &expr)
The functions expr may evaluate to.
Definition function_values.cpp:493
Definition module.h:60
unsigned stack_budget_guardt< Tag >::depth
Definition stack_budget.h:72
A function definition and the module AST it belongs to.
Definition function_values.h:22
const nlohmann::json * def
Definition function_values.h:23
const nlohmann::json * module
Definition function_values.h:24