File tree 7 files changed +48
-17
lines changed
java_bytecode/java_bytecode_language
7 files changed +48
-17
lines changed Original file line number Diff line number Diff line change @@ -740,10 +740,10 @@ void java_bytecode_convert_classt::convert(
740
740
}
741
741
else
742
742
{
743
- class_typet &class_type= to_class_type (class_symbol.type );
743
+ auto &class_type = to_java_class_type (class_symbol.type );
744
744
745
745
class_type.components ().emplace_back ();
746
- class_typet::componentt &component= class_type.components ().back ();
746
+ auto &component = class_type.components ().back ();
747
747
748
748
component.set_name (f.name );
749
749
component.set_base_name (f.name );
Original file line number Diff line number Diff line change @@ -332,7 +332,7 @@ static void infer_opaque_type_fields(
332
332
symbolt &writable_class_symbol =
333
333
symbol_table.get_writeable_ref (class_symbol_id);
334
334
auto &components =
335
- to_struct_type (writable_class_symbol.type ).components ();
335
+ to_java_class_type (writable_class_symbol.type ).components ();
336
336
components.emplace_back (component_name, fieldref.type ());
337
337
components.back ().set_base_name (component_name);
338
338
components.back ().set_pretty_name (component_name);
Original file line number Diff line number Diff line change @@ -112,6 +112,18 @@ class java_class_typet:public class_typet
112
112
{
113
113
}
114
114
115
+ // / is a method or field 'final'?
116
+ bool get_is_final () const
117
+ {
118
+ return get_bool (ID_final);
119
+ }
120
+
121
+ // / is a method or field 'final'?
122
+ void set_is_final (const bool is_final)
123
+ {
124
+ set (ID_final, is_final);
125
+ }
126
+
115
127
// / is a method 'native'?
116
128
bool get_is_native () const
117
129
{
@@ -137,6 +149,12 @@ class java_class_typet:public class_typet
137
149
return (componentst &)(add (ID_components).get_sub ());
138
150
}
139
151
152
+ const componentt &get_component (const irep_idt &component_name) const
153
+ {
154
+ return static_cast <const componentt &>(
155
+ class_typet::get_component (component_name));
156
+ }
157
+
140
158
const irep_idt &get_access () const
141
159
{
142
160
return get (ID_access);
Original file line number Diff line number Diff line change @@ -34,7 +34,26 @@ pointer_typet require_type::require_pointer(
34
34
// / \param struct_type: The structure that should have the component
35
35
// / \param component_name: The name of the component
36
36
// / \return The component with the specified name
37
- struct_union_typet::componentt require_type::require_component (
37
+ java_class_typet::componentt require_type::require_component (
38
+ const java_class_typet &java_class_type,
39
+ const irep_idt &component_name)
40
+ {
41
+ const auto &component = std::find_if (
42
+ java_class_type.components ().begin (),
43
+ java_class_type.components ().end (),
44
+ [&component_name](const java_class_typet::componentt &component) {
45
+ return component.get_name () == component_name;
46
+ });
47
+
48
+ REQUIRE (component != java_class_type.components ().end ());
49
+ return *component;
50
+ }
51
+
52
+ // / Checks a struct like type has a component with a specific name
53
+ // / \param struct_type: The structure that should have the component
54
+ // / \param component_name: The name of the component
55
+ // / \return The component with the specified name
56
+ struct_typet::componentt require_type::require_component (
38
57
const struct_typet &struct_type,
39
58
const irep_idt &component_name)
40
59
{
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ const pointer_typet require_pointer_to_tag(
32
32
const typet &type,
33
33
const irep_idt &identifier = irep_idt());
34
34
35
+ java_class_typet::componentt require_component (
36
+ const java_class_typet &java_class_type,
37
+ const irep_idt &component_name);
38
+
35
39
struct_typet::componentt require_component (
36
40
const struct_typet &struct_type,
37
41
const irep_idt &component_name);
Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ SCENARIO(
36
36
{
37
37
const symbolt &opaque_class_symbol =
38
38
symbol_table.lookup_ref (opaque_class_prefix);
39
- const struct_typet &opaque_class_struct =
40
- to_struct_type (opaque_class_symbol.type );
41
- const struct_union_typet::componentt &field =
39
+ const auto &opaque_class_struct =
40
+ to_java_class_type (opaque_class_symbol.type );
41
+ const auto &field =
42
42
require_type::require_component (opaque_class_struct, " field2" );
43
43
REQUIRE (field.get_is_final ());
44
44
}
Original file line number Diff line number Diff line change @@ -123,16 +123,6 @@ class struct_union_typet:public typet
123
123
{
124
124
return set (ID_C_is_padding, is_padding);
125
125
}
126
-
127
- bool get_is_final () const
128
- {
129
- return get_bool (ID_final);
130
- }
131
-
132
- void set_is_final (const bool is_final)
133
- {
134
- set (ID_final, is_final);
135
- }
136
126
};
137
127
138
128
typedef std::vector<componentt> componentst;
You can’t perform that action at this time.
0 commit comments