Skip to content

Commit 70887e2

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2564 from tautschnig/vs-java-parse-tree
Cleanup java_bytecode_parse_treet: all members are public, no virtual tables required
2 parents 6c5ecec + 0c15fed commit 70887e2

File tree

3 files changed

+25
-37
lines changed

3 files changed

+25
-37
lines changed

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

+19-33
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ Author: Daniel Kroening, [email protected]
1919

2020
#include "bytecode_info.h"
2121

22-
class java_bytecode_parse_treet
22+
struct java_bytecode_parse_treet
2323
{
24-
public:
2524
// Disallow copy construction and copy assignment, but allow move construction
2625
// and move assignment.
2726
#ifndef _MSC_VER // Ommit this on MS VC2013 as move is not supported.
@@ -32,15 +31,12 @@ class java_bytecode_parse_treet
3231
java_bytecode_parse_treet &operator=(java_bytecode_parse_treet &&) = default;
3332
#endif
3433

35-
virtual ~java_bytecode_parse_treet() = default;
36-
class annotationt
34+
struct annotationt
3735
{
38-
public:
3936
typet type;
4037

41-
class element_value_pairt
38+
struct element_value_pairt
4239
{
43-
public:
4440
irep_idt element_name;
4541
exprt value;
4642
void output(std::ostream &) const;
@@ -58,27 +54,23 @@ class java_bytecode_parse_treet
5854
const annotationst &annotations,
5955
const irep_idt &annotation_type_name);
6056

61-
class instructiont
57+
struct instructiont
6258
{
63-
public:
6459
source_locationt source_location;
6560
unsigned address;
6661
irep_idt statement;
6762
typedef std::vector<exprt> argst;
6863
argst args;
6964
};
7065

71-
class membert
66+
struct membert
7267
{
73-
public:
7468
std::string descriptor;
7569
optionalt<std::string> signature;
7670
irep_idt name;
7771
bool is_public, is_protected, is_private, is_static, is_final;
7872
annotationst annotations;
7973

80-
virtual void output(std::ostream &out) const = 0;
81-
8274
membert():
8375
is_public(false), is_protected(false),
8476
is_private(false), is_static(false), is_final(false)
@@ -91,9 +83,8 @@ class java_bytecode_parse_treet
9183
}
9284
};
9385

94-
class methodt:public membert
86+
struct methodt : public membert
9587
{
96-
public:
9788
irep_idt base_name;
9889
bool is_native, is_abstract, is_synchronized;
9990
source_locationt source_location;
@@ -109,7 +100,6 @@ class java_bytecode_parse_treet
109100

110101
struct exceptiont
111102
{
112-
public:
113103
exceptiont()
114104
: start_pc(0), end_pc(0), handler_pc(0), catch_type(irep_idt())
115105
{
@@ -124,9 +114,8 @@ class java_bytecode_parse_treet
124114
typedef std::vector<exceptiont> exception_tablet;
125115
exception_tablet exception_table;
126116

127-
class local_variablet
117+
struct local_variablet
128118
{
129-
public:
130119
irep_idt name;
131120
std::string descriptor;
132121
optionalt<std::string> signature;
@@ -138,9 +127,8 @@ class java_bytecode_parse_treet
138127
typedef std::vector<local_variablet> local_variable_tablet;
139128
local_variable_tablet local_variable_table;
140129

141-
class verification_type_infot
130+
struct verification_type_infot
142131
{
143-
public:
144132
enum verification_type_info_type { TOP, INTEGER, FLOAT, LONG, DOUBLE,
145133
ITEM_NULL, UNINITIALIZED_THIS,
146134
OBJECT, UNINITIALIZED};
@@ -150,9 +138,8 @@ class java_bytecode_parse_treet
150138
u2 offset;
151139
};
152140

153-
class stack_map_table_entryt
141+
struct stack_map_table_entryt
154142
{
155-
public:
156143
enum stack_frame_type
157144
{
158145
SAME, SAME_LOCALS_ONE_STACK, SAME_LOCALS_ONE_STACK_EXTENDED,
@@ -175,29 +162,29 @@ class java_bytecode_parse_treet
175162
typedef std::vector<stack_map_table_entryt> stack_map_tablet;
176163
stack_map_tablet stack_map_table;
177164

178-
virtual void output(std::ostream &out) const;
165+
void output(std::ostream &out) const;
179166

180167
methodt():
181168
is_native(false),
182169
is_abstract(false),
183170
is_synchronized(false)
184171
{
185172
}
186-
187-
virtual ~methodt() = default;
188173
};
189174

190-
class fieldt:public membert
175+
struct fieldt : public membert
191176
{
192-
public:
193-
virtual ~fieldt() = default;
194-
virtual void output(std::ostream &out) const;
195177
bool is_enum;
178+
179+
void output(std::ostream &out) const;
180+
181+
fieldt() : is_enum(false)
182+
{
183+
}
196184
};
197185

198-
class classt
186+
struct classt
199187
{
200-
public:
201188
classt() = default;
202189

203190
// Disallow copy construction and copy assignment, but allow move
@@ -230,9 +217,8 @@ class java_bytecode_parse_treet
230217
};
231218

232219
typedef std::vector<u2> u2_valuest;
233-
class lambda_method_handlet
220+
struct lambda_method_handlet
234221
{
235-
public:
236222
method_handle_typet handle_type;
237223
irep_idt lambda_method_name;
238224
irep_idt lambda_method_ref;

jbmc/src/java_bytecode/java_bytecode_parser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ void java_bytecode_parsert::rmethod(classt &parsed_class)
17751775
rmethod_attribute(method);
17761776
}
17771777

1778-
optionalt<class java_bytecode_parse_treet>
1778+
optionalt<java_bytecode_parse_treet>
17791779
java_bytecode_parse(std::istream &istream, message_handlert &message_handler)
17801780
{
17811781
java_bytecode_parsert java_bytecode_parser;
@@ -1792,7 +1792,7 @@ java_bytecode_parse(std::istream &istream, message_handlert &message_handler)
17921792
return std::move(java_bytecode_parser.parse_tree);
17931793
}
17941794

1795-
optionalt<class java_bytecode_parse_treet>
1795+
optionalt<java_bytecode_parse_treet>
17961796
java_bytecode_parse(const std::string &file, message_handlert &message_handler)
17971797
{
17981798
std::ifstream in(file, std::ios::binary);

jbmc/src/java_bytecode/java_bytecode_parser.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Author: Daniel Kroening, [email protected]
1414
#include <string>
1515
#include <util/optional.h>
1616

17-
optionalt<class java_bytecode_parse_treet>
17+
struct java_bytecode_parse_treet;
18+
19+
optionalt<java_bytecode_parse_treet>
1820
java_bytecode_parse(const std::string &file, class message_handlert &);
1921

20-
optionalt<class java_bytecode_parse_treet>
22+
optionalt<java_bytecode_parse_treet>
2123
java_bytecode_parse(std::istream &, class message_handlert &);
2224

2325
#endif // CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSER_H

0 commit comments

Comments
 (0)