cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
java_bytecode_typecheck_code.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: JAVA Bytecode Conversion / Type Checking
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
11
12
#include "
java_bytecode_typecheck.h
"
13
14
#include <
goto-programs/goto_instruction_code.h
>
15
16
#include <
util/std_code.h
>
17
18
void
java_bytecode_typecheckt::typecheck_code
(
codet
&code)
19
{
20
const
irep_idt
&statement=code.
get_statement
();
21
22
if
(statement==ID_assign)
23
{
24
code_frontend_assignt
&code_assign =
to_code_frontend_assign
(code);
25
typecheck_expr
(code_assign.
lhs
());
26
typecheck_expr
(code_assign.
rhs
());
27
28
code_assign.
rhs
() =
typecast_exprt::conditional_cast
(
29
code_assign.
rhs
(), code_assign.
lhs
().
type
());
30
}
31
else
if
(statement==ID_block)
32
{
33
Forall_operands
(it, code)
34
typecheck_code
(
to_code
(*it));
35
}
36
else
if
(statement==ID_label)
37
{
38
code_labelt
&code_label=
to_code_label
(code);
39
typecheck_code
(code_label.
code
());
40
}
41
else
if
(statement==ID_goto)
42
{
43
}
44
else
if
(statement==ID_ifthenelse)
45
{
46
code_ifthenelset
&code_ifthenelse=
to_code_ifthenelse
(code);
47
typecheck_expr
(code_ifthenelse.
cond
());
48
typecheck_code
(code_ifthenelse.
then_case
());
49
if
(code_ifthenelse.
else_case
().
is_not_nil
())
50
typecheck_code
(code_ifthenelse.
else_case
());
51
}
52
else
if
(statement==ID_switch)
53
{
54
code_switcht
&code_switch =
to_code_switch
(code);
55
typecheck_expr
(code_switch.
value
());
56
}
57
else
if
(statement==ID_return)
58
{
59
code_returnt
&code_return =
to_code_return
(code);
60
typecheck_expr
(code_return.
return_value
());
61
}
62
else
if
(statement==ID_function_call)
63
{
64
code_function_callt
&code_function_call=
to_code_function_call
(code);
65
typecheck_expr
(code_function_call.
lhs
());
66
typecheck_expr
(code_function_call.
function
());
67
68
for
(code_function_callt::argumentst::iterator
69
a_it=code_function_call.
arguments
().begin();
70
a_it!=code_function_call.
arguments
().end();
71
a_it++)
72
typecheck_expr
(*a_it);
73
}
74
else
if
(statement==ID_assert || statement==ID_assume)
75
{
76
typecheck_expr
(code.
op0
());
77
}
78
}
code_frontend_assignt
A codet representing an assignment in the program.
Definition
std_code.h:24
code_frontend_assignt::rhs
exprt & rhs()
Definition
std_code.h:46
code_frontend_assignt::lhs
exprt & lhs()
Definition
std_code.h:41
code_function_callt
goto_instruction_codet representation of a function call statement.
Definition
goto_instruction_code.h:271
code_function_callt::function
exprt & function()
Definition
goto_instruction_code.h:306
code_function_callt::lhs
exprt & lhs()
Definition
goto_instruction_code.h:296
code_function_callt::arguments
argumentst & arguments()
Definition
goto_instruction_code.h:316
code_ifthenelset
codet representation of an if-then-else statement.
Definition
std_code.h:460
code_ifthenelset::cond
const exprt & cond() const
Definition
std_code.h:478
code_ifthenelset::else_case
const codet & else_case() const
Definition
std_code.h:498
code_ifthenelset::then_case
const codet & then_case() const
Definition
std_code.h:488
code_labelt
codet representation of a label for branch targets.
Definition
std_code.h:959
code_labelt::code
codet & code()
Definition
std_code.h:977
code_returnt
goto_instruction_codet representation of a "return from afunction" statement.
Definition
goto_instruction_code.h:494
code_returnt::return_value
const exprt & return_value() const
Definition
goto_instruction_code.h:501
code_switcht
codet representing a switch statement.
Definition
std_code.h:548
code_switcht::value
const exprt & value() const
Definition
std_code.h:555
codet
Data structure for representing an arbitrary statement in a program.
Definition
std_code_base.h:29
codet::op0
exprt & op0()
Definition
expr.h:134
codet::get_statement
const irep_idt & get_statement() const
Definition
std_code_base.h:65
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
irept::is_not_nil
bool is_not_nil() const
Definition
irep.h:372
java_bytecode_typecheckt::typecheck_code
void typecheck_code(codet &)
Definition
java_bytecode_typecheck_code.cpp:18
java_bytecode_typecheckt::typecheck_expr
virtual void typecheck_expr(exprt &expr)
Definition
java_bytecode_typecheck_expr.cpp:20
typecast_exprt::conditional_cast
static exprt conditional_cast(const exprt &expr, const typet &type)
Definition
std_expr.h:1993
Forall_operands
#define Forall_operands(it, expr)
Definition
expr.h:28
goto_instruction_code.h
to_code_function_call
const code_function_callt & to_code_function_call(const goto_instruction_codet &code)
Definition
goto_instruction_code.h:384
to_code_return
const code_returnt & to_code_return(const goto_instruction_codet &code)
Definition
goto_instruction_code.h:536
java_bytecode_typecheck.h
JAVA Bytecode Language Type Checking.
std_code.h
to_code_label
const code_labelt & to_code_label(const codet &code)
Definition
std_code.h:1004
to_code_ifthenelse
const code_ifthenelset & to_code_ifthenelse(const codet &code)
Definition
std_code.h:530
to_code_frontend_assign
const code_frontend_assignt & to_code_frontend_assign(const codet &code)
Definition
std_code.h:113
to_code_switch
const code_switcht & to_code_switch(const codet &code)
Definition
std_code.h:592
to_code
const codet & to_code(const exprt &expr)
Definition
std_code_base.h:104
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
jbmc
src
java_bytecode
java_bytecode_typecheck_code.cpp
Generated by
1.17.0