Skip to content

Commit f73048f

Browse files
mgudemannDaniel Kroening
authored andcommitted
add java_utils.cpp
1 parent 7d2a303 commit f73048f

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

src/java_bytecode/java_object_factory.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author: Daniel Kroening, [email protected]
2323

2424
#include "java_object_factory.h"
2525
#include "java_types.h"
26+
#include "java_utils.h"
2627

2728
/*******************************************************************\
2829
@@ -223,11 +224,8 @@ void java_object_factoryt::gen_nondet_init(
223224
init_code.move_to_operands(null_check);
224225
}
225226

226-
if(subtype.id()==ID_struct &&
227-
has_prefix(id2string(to_struct_type(subtype).get_tag()), "java::array["))
228-
{
227+
if(java_is_array_type(subtype))
229228
gen_nondet_array_init(expr, loc);
230-
}
231229
else
232230
{
233231
exprt allocated=

src/java_bytecode/java_utils.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*******************************************************************\
2+
3+
Module:
4+
5+
Author: Daniel Kroening, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#include <util/prefix.h>
10+
#include <util/std_types.h>
11+
12+
#include "java_utils.h"
13+
14+
bool java_is_array_type(const typet &type)
15+
{
16+
if(type.id()!=ID_struct)
17+
return false;
18+
return has_prefix(id2string(
19+
to_struct_type(type).get_tag()),
20+
"java::array[");
21+
}

src/java_bytecode/java_utils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*******************************************************************\
2+
3+
Module:
4+
5+
Author: Daniel Kroening, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#include <util/type.h>
10+
11+
#ifndef CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
12+
#define CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
13+
14+
bool java_is_array_type(const typet &type);
15+
16+
#endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H

0 commit comments

Comments
 (0)