Skip to content

Commit eb71a01

Browse files
author
Thomas Kiley
authored
Merge pull request #2639 from thk123/array-element-type
Make array element type be not a comment
2 parents c5519ec + b827ea4 commit eb71a01

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ void java_bytecode_parsert::get_class_refs_rec(const typet &src)
621621
irep_idt name=src.get(ID_C_base_name);
622622
if(has_prefix(id2string(name), "array["))
623623
{
624-
const typet &element_type=
625-
static_cast<const typet &>(src.find(ID_C_element_type));
624+
const typet &element_type =
625+
static_cast<const typet &>(src.find(ID_element_type));
626626
get_class_refs_rec(element_type);
627627
}
628628
else

jbmc/src/java_bytecode/java_object_factory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ void java_object_factoryt::allocate_nondet_length_array(
12531253
side_effect_exprt java_new_array(ID_java_new_array, lhs.type());
12541254
java_new_array.copy_to_operands(length_sym_expr);
12551255
java_new_array.set(ID_length_upper_bound, max_length_expr);
1256-
java_new_array.type().subtype().set(ID_C_element_type, element_type);
1256+
java_new_array.type().subtype().set(ID_element_type, element_type);
12571257
code_assignt assign(lhs, java_new_array);
12581258
assign.add_source_location()=loc;
12591259
assignments.copy_to_operands(assign);
@@ -1277,8 +1277,8 @@ void java_object_factoryt::gen_nondet_array_init(
12771277

12781278
const typet &type=ns.follow(expr.type().subtype());
12791279
const struct_typet &struct_type=to_struct_type(type);
1280-
const typet &element_type=
1281-
static_cast<const typet &>(expr.type().subtype().find(ID_C_element_type));
1280+
const typet &element_type =
1281+
static_cast<const typet &>(expr.type().subtype().find(ID_element_type));
12821282

12831283
auto max_length_expr=from_integer(
12841284
object_factory_parameters.max_nondet_array_length, java_int_type());

jbmc/src/java_bytecode/java_types.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ reference_typet java_lang_object_type()
8888
}
8989

9090
/// Construct an array pointer type. It is a pointer to a symbol with identifier
91-
/// java::array[]. Its ID_C_element_type is set to the corresponding primitive
91+
/// java::array[]. Its ID_element_type is set to the corresponding primitive
9292
/// type, or void* for arrays of references.
9393
/// \param subtype Character indicating the type of array
9494
reference_typet java_array_type(const char subtype)
@@ -119,7 +119,7 @@ reference_typet java_array_type(const char subtype)
119119

120120
symbol_typet symbol_type("java::"+id2string(class_name));
121121
symbol_type.set(ID_C_base_name, class_name);
122-
symbol_type.set(ID_C_element_type, java_type_from_char(subtype));
122+
symbol_type.set(ID_element_type, java_type_from_char(subtype));
123123

124124
return java_reference_type(symbol_type);
125125
}
@@ -131,7 +131,7 @@ const typet &java_array_element_type(const symbol_typet &array_symbol)
131131
DATA_INVARIANT(
132132
is_java_array_tag(array_symbol.get_identifier()),
133133
"Symbol should have array tag");
134-
return array_symbol.find_type(ID_C_element_type);
134+
return array_symbol.find_type(ID_element_type);
135135
}
136136

137137
/// Return a non-const reference to the element type of a given java array type
@@ -141,7 +141,7 @@ typet &java_array_element_type(symbol_typet &array_symbol)
141141
DATA_INVARIANT(
142142
is_java_array_tag(array_symbol.get_identifier()),
143143
"Symbol should have array tag");
144-
return array_symbol.add_type(ID_C_element_type);
144+
return array_symbol.add_type(ID_element_type);
145145
}
146146

147147
/// Checks whether the given type is an array pointer type
@@ -555,7 +555,7 @@ typet java_type_from_string(
555555
case '[': // array type
556556
{
557557
// If this is a reference array, we generate a plain array[reference]
558-
// with void* members, but note the real type in ID_C_element_type.
558+
// with void* members, but note the real type in ID_element_type.
559559
if(src.size()<=1)
560560
return nil_typet();
561561
char subtype_letter=src[1];
@@ -567,7 +567,7 @@ typet java_type_from_string(
567567
subtype_letter=='T') // Array of generic types
568568
subtype_letter='A';
569569
typet tmp=java_array_type(std::tolower(subtype_letter));
570-
tmp.subtype().set(ID_C_element_type, subtype);
570+
tmp.subtype().set(ID_element_type, subtype);
571571
return tmp;
572572
}
573573

jbmc/src/java_bytecode/remove_java_new.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
177177
struct_type.components()[2].type());
178178

179179
// Allocate a (struct realtype**) instead of a (void**) if possible.
180-
const irept &given_element_type = object_type.find(ID_C_element_type);
180+
const irept &given_element_type = object_type.find(ID_element_type);
181181
typet allocate_data_type;
182182
if(given_element_type.is_not_nil())
183183
{
@@ -272,7 +272,7 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
272272

273273
// we already know that rhs has pointer type
274274
typet sub_type =
275-
static_cast<const typet &>(rhs.type().subtype().find("#element_type"));
275+
static_cast<const typet &>(rhs.type().subtype().find(ID_element_type));
276276
CHECK_RETURN(sub_type.id() == ID_pointer);
277277
sub_java_new.type() = sub_type;
278278

jbmc/src/java_bytecode/select_pointer_type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pointer_typet select_pointer_typet::specialize_generics(
122122
visited_nodes);
123123

124124
pointer_typet replacement_array_type = java_array_type('a');
125-
replacement_array_type.subtype().set(ID_C_element_type, new_array_type);
125+
replacement_array_type.subtype().set(ID_element_type, new_array_type);
126126
return replacement_array_type;
127127
}
128128
}

jbmc/unit/java-testing-utils/require_type.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <testing-utils/catch.hpp>
1212
#include <util/base_type.h>
13+
#include <util/namespace.h>
14+
#include <util/symbol_table.h>
1315

1416
/// Checks a type is a pointer type optionally with a specific subtype
1517
/// \param type: The type to check
@@ -25,8 +27,8 @@ pointer_typet require_type::require_pointer(
2527

2628
if(subtype)
2729
{
28-
// TODO: use base_type_eq
29-
REQUIRE(pointer.subtype() == subtype.value());
30+
namespacet ns{symbol_tablet{}};
31+
base_type_eq(pointer.subtype(), subtype.value(), ns);
3032
}
3133
return pointer;
3234
}

src/util/irep_ids.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ IREP_ID_TWO(C_spec_loop_invariant, #spec_loop_invariant)
571571
IREP_ID_TWO(C_spec_requires, #spec_requires)
572572
IREP_ID_TWO(C_spec_ensures, #spec_ensures)
573573
IREP_ID_ONE(virtual_function)
574-
IREP_ID_TWO(C_element_type, #element_type)
574+
IREP_ID_TWO(element_type, element_type)
575575
IREP_ID_ONE(working_directory)
576576
IREP_ID_ONE(section)
577577
IREP_ID_ONE(bswap)

0 commit comments

Comments
 (0)