File tree 3 files changed +80
-0
lines changed
3 files changed +80
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ SRC = bytecode_info.cpp \
6
6
expr2java.cpp \
7
7
generic_parameter_specialization_map_keys.cpp \
8
8
jar_file.cpp \
9
+ jar_pool.cpp \
9
10
java_bytecode_convert_class.cpp \
10
11
java_bytecode_convert_method.cpp \
11
12
java_bytecode_concurrency_instrumentation.cpp \
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module:
4
+
5
+ Author: Daniel Kroening, [email protected]
6
+
7
+ \*******************************************************************/
8
+
9
+ #include " jar_pool.h"
10
+ #include " jar_file.h"
11
+
12
+ jar_filet &jar_poolt::operator ()(const std::string &file_name)
13
+ {
14
+ const auto it = m_archives.find (file_name);
15
+ if (it == m_archives.end ())
16
+ {
17
+ // VS: Can't construct in place
18
+ auto file = jar_filet (file_name);
19
+ return m_archives.emplace (file_name, std::move (file)).first ->second ;
20
+ }
21
+ else
22
+ return it->second ;
23
+ }
24
+
25
+ jar_filet &jar_poolt::add_jar (
26
+ const std::string &buffer_name,
27
+ const void *pmem,
28
+ size_t size)
29
+ {
30
+ const auto it = m_archives.find (buffer_name);
31
+ if (it == m_archives.end ())
32
+ {
33
+ // VS: Can't construct in place
34
+ auto file = jar_filet (pmem, size);
35
+ return m_archives.emplace (buffer_name, std::move (file)).first ->second ;
36
+ }
37
+ else
38
+ return it->second ;
39
+ }
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module:
4
+
5
+ Author: Daniel Kroening, [email protected]
6
+
7
+ \*******************************************************************/
8
+
9
+ #ifndef CPROVER_JAVA_BYTECODE_JAR_POOL_H
10
+ #define CPROVER_JAVA_BYTECODE_JAR_POOL_H
11
+
12
+ #include < map>
13
+ #include < string>
14
+
15
+ class jar_filet ;
16
+
17
+ // / A chache for jar_filet objects, by file name
18
+ class jar_poolt
19
+ {
20
+ public:
21
+ // / Load jar archive or retrieve from cache if already loaded
22
+ // / \param jar_path name of the file
23
+ // Throws an exception if the file does not exist
24
+ jar_filet &operator ()(const std::string &jar_path);
25
+
26
+ // / Add a jar archive or retrieve from cache if already added
27
+ // / \param buffer_name name of the original file
28
+ // / \param pmem memory pointer to the contents of the file
29
+ // / \param size size of the memory buffer
30
+ // / Note that this mocks the existence of a file which may
31
+ // / or may not exist since the actual data bis retrieved from memory.
32
+ jar_filet &
33
+ add_jar (const std::string &buffer_name, const void *pmem, size_t size);
34
+
35
+ protected:
36
+ // / Jar files that have been loaded
37
+ std::map<std::string, jar_filet> m_archives;
38
+ };
39
+
40
+ #endif // CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H
You can’t perform that action at this time.
0 commit comments