cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
load_method_by_regex.cpp
Go to the documentation of this file.
1
2
/*******************************************************************\
3
4
Module: Java Bytecode
5
6
Author: Diffblue Ltd.
7
8
\*******************************************************************/
9
10
#include "
load_method_by_regex.h
"
11
12
#include <
util/prefix.h
>
13
#include <
util/symbol_table_base.h
>
14
15
#include <regex>
16
22
static
std::regex
build_regex_from_pattern
(
const
std::string &pattern)
23
{
24
std::string modified_pattern = pattern;
25
if
(
does_pattern_miss_descriptor
(pattern))
26
modified_pattern += R
"(:\(.*\).*)";
27
28
if
(!
has_prefix
(pattern,
"java::"
))
29
modified_pattern =
"java::"
+ modified_pattern;
30
31
return
std::regex{modified_pattern};
32
}
33
39
bool
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 &&
47
has_prefix
(pattern, java_prefix);
48
}
49
57
std::function<std::vector<irep_idt>(
const
symbol_table_baset
&symbol_table)>
58
build_load_method_by_regex
(
const
std::string &pattern)
59
{
60
std::regex regex =
build_regex_from_pattern
(pattern);
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
}
symbol_table_baset
The symbol table base class interface.
Definition
symbol_table_base.h:23
has_prefix
bool has_prefix(const std::string &s, const std::string &prefix)
Definition
converter.cpp:13
id2string
const std::string & id2string(const irep_idt &d)
Definition
irep.h:44
does_pattern_miss_descriptor
bool does_pattern_miss_descriptor(const std::string &pattern)
Identify if a parameter includes a part that will match a descriptor.
Definition
load_method_by_regex.cpp:39
build_load_method_by_regex
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...
Definition
load_method_by_regex.cpp:58
build_regex_from_pattern
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...
Definition
load_method_by_regex.cpp:22
load_method_by_regex.h
Process a pattern to use as a regex for selecting extra entry points for ci_lazy_methodst.
prefix.h
symbol_table_base.h
Author: Diffblue Ltd.
jbmc
src
java_bytecode
load_method_by_regex.cpp
Generated by
1.17.0