CBMC
Loading...
Searching...
No Matches
load_method_by_regex.cpp
Go to the documentation of this file.
1
2/*******************************************************************\
3
4Module: Java Bytecode
5
6Author: Diffblue Ltd.
7
8\*******************************************************************/
9
11
12#include <util/prefix.h>
14
15#include <regex>
16
22static std::regex build_regex_from_pattern(const std::string &pattern)
23{
24 std::string modified_pattern = pattern;
26 modified_pattern += R"(:\‍(.*\).*)";
27
28 if(!has_prefix(pattern, "java::"))
30
31 return std::regex{modified_pattern};
32}
33
39bool does_pattern_miss_descriptor(const std::string &pattern)
40{
41 const size_t descriptor_index = pattern.rfind(':');
42 if(descriptor_index == std::string::npos)
43 return true;
44
45 const std::string java_prefix = "java::";
46 return descriptor_index == java_prefix.length() - 1 &&
48}
49
57std::function<std::vector<irep_idt>(const symbol_table_baset &symbol_table)>
59{
61
62 return [=](const symbol_table_baset &symbol_table) {
63 std::vector<irep_idt> matched_methods;
64 for(const auto &symbol : symbol_table.symbols)
65 {
66 if(
67 symbol.second.is_function() &&
68 std::regex_match(id2string(symbol.first), regex))
69 {
70 matched_methods.push_back(symbol.first);
71 }
72 }
73 return matched_methods;
74 };
75}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
The symbol table base class interface.
bool has_prefix(const std::string &s, const std::string &prefix)
Definition converter.cpp:13
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
bool does_pattern_miss_descriptor(const std::string &pattern)
Identify if a parameter includes a part that will match a descriptor.
std::function< std::vector< irep_idt >(const symbol_table_baset &symbol_table)> build_load_method_by_regex(const std::string &pattern)
Create a lambda that returns the symbols that the given pattern should be loaded.If the pattern doesn...
static std::regex build_regex_from_pattern(const std::string &pattern)
For a given user provided pattern, return a regex, having dealt with the cases where the user has not...
Process a pattern to use as a regex for selecting extra entry points for ci_lazy_methodst.
Author: Diffblue Ltd.