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
exprt & op1()
Definition: expr.h:136
exprt & lhs()
Definition: std_expr.h:668
exprt & op0()
Definition: expr.h:133
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition: std_expr.h:731
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:738
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:745
Base class for all expressions.
Definition: expr.h:56
typet & type()
Return the type of the expression.
Definition: expr.h:84
const irep_idt & id() const
Definition: irep.h:388
java_instanceof_exprt(exprt lhs, const struct_tag_typet &target_type)
Definition: java_expr.h:20
exprt & tested_expr()
Definition: java_expr.h:32
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition: java_expr.h:49
const exprt & tested_expr() const
Definition: java_expr.h:28
const struct_tag_typet & target_type() const
Definition: java_expr.h:37
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: java_expr.h:42
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:493
An expression denoting a type.
Definition: std_expr.h:2954
bool can_cast_expr< java_instanceof_exprt >(const exprt &base)
Definition: java_expr.h:70
const java_instanceof_exprt & to_java_instanceof_expr(const exprt &expr)
Cast an exprt to a java_instanceof_exprt.
Definition: java_expr.h:86
void validate_expr(const java_instanceof_exprt &value)
Definition: java_expr.h:75
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
API to expression classes.
bool can_cast_expr< type_exprt >(const exprt &base)
Definition: std_expr.h:2962
bool can_cast_expr< binary_exprt >(const exprt &base)
Definition: std_expr.h:699
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:505
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
Definition: std_types.h:518
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
validation_modet