Skip to content

Commit 7a1ae03

Browse files
author
Daniel Kroening
committed
Introduce getters/setters for java class properties
The IDs are used already; this commit merely adds a wrapper. The consistency of using the "is_" prefix should be considered as a separate PR.
1 parent 4b9e20e commit 7a1ae03

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,10 @@ void java_bytecode_convert_classt::convert(
311311

312312
class_type.set_tag(c.name);
313313
class_type.set_inner_name(c.inner_name);
314-
class_type.set(ID_abstract, c.is_abstract);
315-
class_type.set(ID_is_annotation, c.is_annotation);
316-
class_type.set(ID_interface, c.is_interface);
317-
class_type.set(ID_synthetic, c.is_synthetic);
314+
class_type.set_abstract(c.is_abstract);
315+
class_type.set_is_annotation(c.is_annotation);
316+
class_type.set_interface(c.is_interface);
317+
class_type.set_synthetic(c.is_synthetic);
318318
class_type.set_final(c.is_final);
319319
class_type.set_is_inner_class(c.is_inner_class);
320320
class_type.set_is_static_class(c.is_static_class);

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static void java_static_lifetime_init(
188188
// For arguments we can't parse yet:
189189
side_effect_expr_nondett nondet_bool(java_boolean_type(), sym.location);
190190

191+
const auto &java_class_type = to_java_class_type(class_symbol.type);
192+
191193
// Argument order is: name, isAnnotation, isArray, isInterface,
192194
// isSynthetic, isLocalClass, isMemberClass, isEnum
193195

@@ -198,19 +200,19 @@ static void java_static_lifetime_init(
198200
// name:
199201
address_of_exprt(class_name_literal),
200202
// isAnnotation:
201-
constant_bool(class_symbol.type.get_bool(ID_is_annotation)),
203+
constant_bool(java_class_type.get_is_annotation()),
202204
// isArray:
203205
constant_bool(class_is_array),
204206
// isInterface:
205-
constant_bool(class_symbol.type.get_bool(ID_interface)),
207+
constant_bool(java_class_type.get_interface()),
206208
// isSynthetic:
207-
constant_bool(class_symbol.type.get_bool(ID_synthetic)),
209+
constant_bool(java_class_type.get_synthetic()),
208210
// isLocalClass:
209211
nondet_bool,
210212
// isMemberClass:
211213
nondet_bool,
212214
// isEnum:
213-
constant_bool(class_symbol.type.get_bool(ID_enumeration))});
215+
constant_bool(java_class_type.get_is_enumeration())});
214216

215217
// First initialize the object as prior to a constructor:
216218
namespacet ns(symbol_table);

jbmc/src/java_bytecode/java_types.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,54 @@ class java_class_typet:public class_typet
402402
set(ID_enumeration, is_enumeration);
403403
}
404404

405+
/// is class abstract?
406+
bool get_abstract() const
407+
{
408+
return get_bool(ID_abstract);
409+
}
410+
411+
/// marks class abstract
412+
void set_abstract(bool abstract)
413+
{
414+
set(ID_abstract, abstract);
415+
}
416+
417+
/// is class synthetic?
418+
bool get_synthetic() const
419+
{
420+
return get_bool(ID_synthetic);
421+
}
422+
423+
/// marks class synthetic
424+
void set_synthetic(bool synthetic)
425+
{
426+
set(ID_synthetic, synthetic);
427+
}
428+
429+
/// is class an annotation?
430+
bool get_is_annotation() const
431+
{
432+
return get_bool(ID_is_annotation);
433+
}
434+
435+
/// marks class an annotation
436+
void set_is_annotation(bool is_annotation)
437+
{
438+
set(ID_is_annotation, is_annotation);
439+
}
440+
441+
/// is class an interface?
442+
bool get_interface() const
443+
{
444+
return get_bool(ID_interface);
445+
}
446+
447+
/// marks class an interface
448+
void set_interface(bool interface)
449+
{
450+
set(ID_interface, interface);
451+
}
452+
405453
// it may be better to introduce a class like
406454
// class java_lambda_method_handlet : private irept
407455
// {

0 commit comments

Comments
 (0)