CBMC
java_expr.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Java-specific exprt subclasses
4 
5 Author: Diffblue Ltd
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_JAVA_BYTECODE_JAVA_EXPR_H
13 #define CPROVER_JAVA_BYTECODE_JAVA_EXPR_H
14 
15 #include <util/std_expr.h>
16 
18 {
19 public:
22  std::move(lhs),
23  ID_java_instanceof,
25  {
26  }
27 
28  const exprt &tested_expr() const
29  {
30  return op0();
31  }
33  {
34  return op0();
35  }
36 
38  {
39  return to_struct_tag_type(op1().type());
40  }
41 
42  static void check(
43  const exprt &expr,
45  {
47  }
48 
49  static void validate(
50  const exprt &expr,
51  const namespacet &ns,
53  {
55 
56  const auto &expr_binary = static_cast<const binary_predicate_exprt &>(expr);
57 
58  DATA_CHECK(
59  vm,
60  can_cast_expr<type_exprt>(expr_binary.rhs()),
61  "java_instanceof_exprt rhs should be a type_exprt");
62  DATA_CHECK(
63  vm,
64  can_cast_type<struct_tag_typet>(expr_binary.rhs().type()),
65  "java_instanceof_exprt rhs should denote a struct_tag_typet");
66  }
67 };
68 
69 template <>
71 {
72  return can_cast_expr<binary_exprt>(base) && base.id() == ID_java_instanceof;
73 }
74 
75 inline void validate_expr(const java_instanceof_exprt &value)
76 {
78 }
79 
87 {
90  return static_cast<const java_instanceof_exprt &>(expr);
91 }
92 
95 {
98  return static_cast<java_instanceof_exprt &>(expr);
99 }
100 
101 #endif // CPROVER_JAVA_BYTECODE_JAVA_EXPR_H
DATA_CHECK
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
can_cast_expr< java_instanceof_exprt >
bool can_cast_expr< java_instanceof_exprt >(const exprt &base)
Definition: java_expr.h:70
exprt
Base class for all expressions.
Definition: expr.h:55
binary_exprt::lhs
exprt & lhs()
Definition: std_expr.h:613
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:448
can_cast_expr< binary_exprt >
bool can_cast_expr< binary_exprt >(const exprt &base)
Definition: std_expr.h:644
exprt::op0
exprt & op0()
Definition: expr.h:125
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
java_instanceof_exprt::java_instanceof_exprt
java_instanceof_exprt(exprt lhs, const struct_tag_typet &target_type)
Definition: java_expr.h:20
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
java_instanceof_exprt::tested_expr
const exprt & tested_expr() const
Definition: java_expr.h:28
java_instanceof_exprt::tested_expr
exprt & tested_expr()
Definition: java_expr.h:32
can_cast_type< struct_tag_typet >
bool can_cast_type< struct_tag_typet >(const typet &type)
Check whether a reference to a typet is a struct_tag_typet.
Definition: std_types.h:461
java_instanceof_exprt::validate
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition: java_expr.h:49
binary_predicate_exprt
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition: std_expr.h:675
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
java_instanceof_exprt::target_type
const struct_tag_typet & target_type() const
Definition: java_expr.h:37
exprt::op1
exprt & op1()
Definition: expr.h:128
validation_modet
validation_modet
Definition: validation_mode.h:12
irept::id
const irep_idt & id() const
Definition: irep.h:396
to_struct_tag_type
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
Definition: std_types.h:474
binary_predicate_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:683
validate_expr
void validate_expr(const java_instanceof_exprt &value)
Definition: java_expr.h:75
type_exprt
An expression denoting a type.
Definition: std_expr.h:2905
to_java_instanceof_expr
const java_instanceof_exprt & to_java_instanceof_expr(const exprt &expr)
Cast an exprt to a java_instanceof_exprt.
Definition: java_expr.h:86
can_cast_expr< type_exprt >
bool can_cast_expr< type_exprt >(const exprt &base)
Definition: std_expr.h:2914
java_instanceof_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: java_expr.h:42
binary_predicate_exprt::validate
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:690
std_expr.h
java_instanceof_exprt
Definition: java_expr.h:17
validation_modet::INVARIANT
@ INVARIANT