ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
12{
13public:
14 // ---- possible class types cache ----
15
16 std::optional<std::vector<std::string>>
17 get_possible_class_types(const std::string &key) const
18 {
19 auto it = possible_class_types_cache_.find(key);
20 if (it == possible_class_types_cache_.end())
21 return std::nullopt;
22 return it->second;
23 }
24
26 const std::string &key,
27 const std::vector<std::string> &types)
28 {
29 possible_class_types_cache_[key] = types;
30 }
31
32 // ---- method exists cache ----
33
34 std::optional<bool> get_method_exists(const std::string &key) const
35 {
36 auto it = method_exists_cache_.find(key);
37 if (it != method_exists_cache_.end())
38 return it->second;
39 return std::nullopt;
40 }
41
42 void set_method_exists(const std::string &key, bool exists)
43 {
44 method_exists_cache_[key] = exists;
45 }
46
47 // ---- math/cmath dispatch classification cache ----
48
49 std::optional<bool>
50 get_math_dispatch_classification(const std::string &key) const
51 {
52 auto it = math_dispatch_cache_.find(key);
53 if (it != math_dispatch_cache_.end())
54 return it->second;
55 return std::nullopt;
56 }
57
58 void set_math_dispatch_classification(const std::string &key, bool matches)
59 {
60 math_dispatch_cache_[key] = matches;
61 }
62
63 // ---- lifecycle ----
64
65 void clear()
66 {
67 possible_class_types_cache_.clear();
68 method_exists_cache_.clear();
69 math_dispatch_cache_.clear();
70 }
71
72private:
73 std::unordered_map<std::string, std::vector<std::string>>
74 possible_class_types_cache_;
75 std::unordered_map<std::string, bool> method_exists_cache_;
76 std::unordered_map<std::string, bool> math_dispatch_cache_;
77};
Dedicated cache for function-call resolution data.
Definition cache.h:12
std::optional< bool > get_math_dispatch_classification(const std::string &key) const
Definition cache.h:50
std::optional< bool > get_method_exists(const std::string &key) const
Definition cache.h:34
void set_method_exists(const std::string &key, bool exists)
Definition cache.h:42
std::optional< std::vector< std::string > > get_possible_class_types(const std::string &key) const
Definition cache.h:17
void set_math_dispatch_classification(const std::string &key, bool matches)
Definition cache.h:58
void set_possible_class_types(const std::string &key, const std::vector< std::string > &types)
Definition cache.h:25
void clear()
Definition cache.h:65
uint256_t key
Definition solidity_mapping.c:1