Skip to content

Commit dfb11c2

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#1480 from diffblue/java-types-cleanup
cleanup of java_types.h
2 parents 8f4f2ec + f4bc0ec commit dfb11c2

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

src/java_bytecode/java_types.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ typet java_type_from_string(
323323
irep_idt type_var_name(class_name_prefix+"::"+src.substr(1, src.size()-2));
324324
return java_generic_parametert(
325325
type_var_name,
326-
java_type_from_string("Ljava/lang/Object;").subtype());
326+
to_symbol_type(java_type_from_string("Ljava/lang/Object;").subtype()));
327327
}
328328
case 'L':
329329
{
@@ -403,7 +403,8 @@ typet java_type_from_string(
403403
// current type
404404
else
405405
{
406-
java_generic_inst_parametert inst_type(t.subtype());
406+
java_generic_inst_parametert inst_type(
407+
to_symbol_type(t.subtype()));
407408
#ifdef DEBUG
408409
std::cout << " instantiation of generic type var "
409410
<< to_symbol_type(t.subtype()).get_identifier() << "\n";
@@ -510,7 +511,7 @@ std::vector<typet> java_generic_type_from_string(
510511

511512
java_generic_parametert type_var_type(
512513
type_var_name,
513-
java_type_from_string(bound_type, class_name).subtype());
514+
to_symbol_type(java_type_from_string(bound_type, class_name).subtype()));
514515

515516
types.push_back(type_var_type);
516517
signature=signature.substr(var_sep+1, std::string::npos);

src/java_bytecode/java_types.h

+16-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
109
#ifndef CPROVER_JAVA_BYTECODE_JAVA_TYPES_H
1110
#define CPROVER_JAVA_BYTECODE_JAVA_TYPES_H
1211

@@ -16,7 +15,6 @@ Author: Daniel Kroening, [email protected]
1615
#include <util/type.h>
1716
#include <util/std_types.h>
1817
#include <util/c_types.h>
19-
#include <util/config.h>
2018
#include <util/optional.h>
2119

2220
class java_class_typet:public class_typet
@@ -83,10 +81,8 @@ std::vector<typet> java_generic_type_from_string(
8381
typet java_bytecode_promotion(const typet &);
8482
exprt java_bytecode_promotion(const exprt &);
8583

86-
bool is_java_array_tag(const irep_idt& tag);
87-
88-
bool is_valid_java_array(const struct_typet &type);
89-
84+
bool is_java_array_tag(const irep_idt &tag);
85+
bool is_valid_java_array(const struct_typet &);
9086

9187
/// class to hold a Java generic type
9288
/// upper bound can specify type requirements
@@ -96,14 +92,12 @@ class java_generic_parametert:public reference_typet
9692
typedef symbol_typet type_variablet;
9793
typedef std::vector<type_variablet> type_variablest;
9894

99-
java_generic_parametert(const irep_idt &_type_var_name, const typet &_bound) :
100-
// the reference_typet now needs a pointer width, here it uses the one
101-
// defined in the reference_type function from c_types.cpp
102-
reference_typet(_bound, config.ansi_c.pointer_width)
95+
java_generic_parametert(
96+
const irep_idt &_type_var_name,
97+
const symbol_typet &_bound):
98+
reference_typet(java_reference_type(_bound))
10399
{
104-
PRECONDITION(_bound.id()==ID_symbol);
105100
set(ID_C_java_generic_parameter, true);
106-
// bound must be symbol type
107101
type_variables().push_back(symbol_typet(_type_var_name));
108102
}
109103

@@ -156,7 +150,7 @@ class java_generic_inst_parametert:public java_generic_parametert
156150
public:
157151
// uses empty name for base type variable java_generic_parametert as real name
158152
// is not known here
159-
explicit java_generic_inst_parametert(const typet &type) :
153+
explicit java_generic_inst_parametert(const symbol_typet &type):
160154
java_generic_parametert(irep_idt(), type)
161155
{
162156
set(ID_C_java_generic_inst_parameter, true);
@@ -205,27 +199,27 @@ class java_generic_typet:public reference_typet
205199
public:
206200
typedef std::vector<java_generic_parametert> generic_type_variablest;
207201

208-
explicit java_generic_typet(const typet &_type) :
209-
reference_typet(_type, config.ansi_c.pointer_width)
202+
explicit java_generic_typet(const typet &_type):
203+
reference_typet(java_reference_type(_type))
210204
{
211205
set(ID_C_java_generic_type, true);
212206
}
213207

214-
215208
/// \return vector of type variables
216209
const generic_type_variablest &generic_type_variables() const
217210
{
218-
return (const generic_type_variablest &)(find(ID_type_variables).get_sub());
211+
return (const generic_type_variablest &)(
212+
find(ID_type_variables).get_sub());
219213
}
220214

221215
/// \return vector of type variables
222216
generic_type_variablest &generic_type_variables()
223217
{
224-
return (generic_type_variablest &)(add(ID_type_variables).get_sub());
218+
return (generic_type_variablest &)(
219+
add(ID_type_variables).get_sub());
225220
}
226221
};
227222

228-
229223
/// \param type: the type to check
230224
/// \return true if type is java type containing with generics, e.g., List<T>
231225
inline bool is_java_generic_type(const typet &type)
@@ -353,7 +347,6 @@ inline const typet &java_generics_class_type_bound(
353347
return gen_type.subtype();
354348
}
355349

356-
357350
/// An exception that is raised for unsupported class signature.
358351
/// Currently we do not parse multiple bounds.
359352
class unsupported_java_class_signature_exceptiont:public std::logic_error
@@ -375,7 +368,7 @@ inline typet java_type_from_string_with_exception(
375368
{
376369
return java_type_from_string(signature.value(), class_name);
377370
}
378-
catch (unsupported_java_class_signature_exceptiont &e)
371+
catch(unsupported_java_class_signature_exceptiont &)
379372
{
380373
return java_type_from_string(descriptor, class_name);
381374
}
@@ -389,7 +382,8 @@ inline const optionalt<size_t> java_generics_get_index_for_subtype(
389382
const java_generics_class_typet &t,
390383
const irep_idt &identifier)
391384
{
392-
const std::vector<java_generic_parametert> &gen_types=t.generic_types();
385+
const std::vector<java_generic_parametert> &gen_types=
386+
t.generic_types();
393387

394388
const auto iter = std::find_if(
395389
gen_types.cbegin(),

0 commit comments

Comments
 (0)