cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
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
17
class
java_instanceof_exprt
:
public
binary_predicate_exprt
18
{
19
public
:
20
java_instanceof_exprt
(
exprt
lhs
,
const
struct_tag_typet
&
target_type
)
21
:
binary_predicate_exprt
(
22
std
::move(
lhs
),
23
ID_java_instanceof,
24
type_exprt
(
target_type
))
25
{
26
}
27
28
const
exprt
&
tested_expr
()
const
29
{
30
return
op0
();
31
}
32
exprt
&
tested_expr
()
33
{
34
return
op0
();
35
}
36
37
const
struct_tag_typet
&
target_type
()
const
38
{
39
return
to_struct_tag_type
(
op1
().
type
());
40
}
41
42
static
void
check
(
43
const
exprt
&expr,
44
const
validation_modet
vm =
validation_modet::INVARIANT
)
45
{
46
binary_predicate_exprt::check
(expr, vm);
47
}
48
49
static
void
validate
(
50
const
exprt
&expr,
51
const
namespacet
&ns,
52
const
validation_modet
vm =
validation_modet::INVARIANT
)
53
{
54
binary_predicate_exprt::validate
(expr, ns, vm);
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
<>
70
inline
bool
can_cast_expr<java_instanceof_exprt>
(
const
exprt
&base)
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
{
77
java_instanceof_exprt::check
(value);
78
}
79
86
inline
const
java_instanceof_exprt
&
to_java_instanceof_expr
(
const
exprt
&expr)
87
{
88
java_instanceof_exprt::check
(expr);
89
PRECONDITION
(
can_cast_expr<java_instanceof_exprt>
(expr));
90
return
static_cast<
const
java_instanceof_exprt
&
>
(expr);
91
}
92
94
inline
java_instanceof_exprt
&
to_java_instanceof_expr
(
exprt
&expr)
95
{
96
java_instanceof_exprt::check
(expr);
97
PRECONDITION
(
can_cast_expr<java_instanceof_exprt>
(expr));
98
return
static_cast<
java_instanceof_exprt
&
>
(expr);
99
}
100
101
#endif
// CPROVER_JAVA_BYTECODE_JAVA_EXPR_H
binary_exprt::lhs
exprt & lhs()
Definition
std_expr.h:669
binary_exprt::op0
exprt & op0()
Definition
expr.h:134
binary_exprt::op1
exprt & op1()
Definition
expr.h:137
binary_predicate_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition
std_expr.h:734
binary_predicate_exprt::binary_predicate_exprt
binary_predicate_exprt(exprt _op0, const irep_idt &_id, exprt _op1)
Definition
std_expr.h:729
binary_predicate_exprt::validate
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition
std_expr.h:742
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
irept::id
const irep_idt & id() const
Definition
irep.h:388
java_instanceof_exprt
Definition
java_expr.h:18
java_instanceof_exprt::tested_expr
exprt & tested_expr()
Definition
java_expr.h:32
java_instanceof_exprt::java_instanceof_exprt
java_instanceof_exprt(exprt lhs, const struct_tag_typet &target_type)
Definition
java_expr.h:20
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
java_instanceof_exprt::tested_expr
const exprt & tested_expr() const
Definition
java_expr.h:28
java_instanceof_exprt::check
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition
java_expr.h:42
java_instanceof_exprt::target_type
const struct_tag_typet & target_type() const
Definition
java_expr.h:37
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition
std_types.h:493
type_exprt
An expression denoting a type.
Definition
std_expr.h:2961
can_cast_expr
bool can_cast_expr(const exprt &base)
Check whether a reference to a generic exprt is of a specific derived class.
can_cast_type
bool can_cast_type(const typet &base)
Check whether a reference to a generic typet is of a specific derived class.
can_cast_expr< java_instanceof_exprt >
bool can_cast_expr< java_instanceof_exprt >(const exprt &base)
Definition
java_expr.h:70
validate_expr
void validate_expr(const java_instanceof_exprt &value)
Definition
java_expr.h:75
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
std
STL namespace.
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
std_expr.h
API to expression classes.
can_cast_expr< binary_exprt >
bool can_cast_expr< binary_exprt >(const exprt &base)
Definition
std_expr.h:700
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:518
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
validation_modet
validation_modet
Definition
validation_mode.h:13
validation_modet::INVARIANT
@ INVARIANT
Definition
validation_mode.h:14
jbmc
src
java_bytecode
java_expr.h
Generated by
1.17.0