cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
java_bytecode_typecheck_type.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 <
util/invariant.h
>
15
#include <
util/std_types.h
>
16
17
#include "
java_types.h
"
18
19
void
java_bytecode_typecheckt::typecheck_type
(
typet
&type)
20
{
21
if
(type.
id
() == ID_struct_tag)
22
{
23
irep_idt
identifier =
to_struct_tag_type
(type).
get_identifier
();
24
25
auto
type_symbol =
symbol_table
.lookup(identifier);
26
DATA_INVARIANT
(
27
type_symbol,
"symbol "
+
id2string
(identifier) +
" must exist already"
);
28
DATA_INVARIANT
(
29
type_symbol->is_type,
30
"symbol "
+
id2string
(identifier) +
" must be a type"
);
31
}
32
else
if
(type.
id
()==ID_pointer)
33
{
34
typecheck_type
(
to_pointer_type
(type).base_type());
35
}
36
else
if
(type.
id
()==ID_array)
37
{
38
typecheck_type
(
to_array_type
(type).element_type());
39
typecheck_expr
(
to_array_type
(type).size());
40
}
41
else
if
(type.
id
()==ID_code)
42
{
43
java_method_typet
&method_type =
to_java_method_type
(type);
44
typecheck_type
(method_type.
return_type
());
45
46
java_method_typet::parameterst
¶meters = method_type.
parameters
();
47
48
for
(java_method_typet::parameterst::iterator it = parameters.begin();
49
it != parameters.end();
50
it++)
51
typecheck_type
(it->type());
52
}
53
}
54
55
void
java_bytecode_typecheckt::typecheck_type_symbol
(
symbolt
&symbol)
56
{
57
DATA_INVARIANT
(
58
symbol.
is_type
,
"symbol "
+
id2string
(symbol.
name
) +
" must be a type"
);
59
60
symbol.
mode
= ID_java;
61
typecheck_type
(symbol.
type
);
62
}
code_typet::parameters
const parameterst & parameters() const
Definition
std_types.h:699
code_typet::return_type
const typet & return_type() const
Definition
std_types.h:689
irept::id
const irep_idt & id() const
Definition
irep.h:388
java_bytecode_typecheckt::typecheck_type_symbol
void typecheck_type_symbol(symbolt &)
Definition
java_bytecode_typecheck_type.cpp:55
java_bytecode_typecheckt::typecheck_type
void typecheck_type(typet &)
Definition
java_bytecode_typecheck_type.cpp:19
java_bytecode_typecheckt::typecheck_expr
virtual void typecheck_expr(exprt &expr)
Definition
java_bytecode_typecheck_expr.cpp:20
java_bytecode_typecheckt::symbol_table
symbol_table_baset & symbol_table
Definition
java_bytecode_typecheck.h:60
java_method_typet
Definition
java_types.h:100
java_method_typet::parameterst
std::vector< parametert > parameterst
Definition
std_types.h:586
symbolt
Symbol table entry.
Definition
symbol.h:28
symbolt::is_type
bool is_type
Definition
symbol.h:61
symbolt::type
typet type
Type of symbol.
Definition
symbol.h:31
symbolt::name
irep_idt name
The unique identifier.
Definition
symbol.h:40
symbolt::mode
irep_idt mode
Language mode.
Definition
symbol.h:49
tag_typet::get_identifier
const irep_idt & get_identifier() const
Definition
std_types.h:410
typet
The type of an expression, extends irept.
Definition
type.h:29
id2string
const std::string & id2string(const irep_idt &d)
Definition
irep.h:44
java_bytecode_typecheck.h
JAVA Bytecode Language Type Checking.
java_types.h
to_java_method_type
const java_method_typet & to_java_method_type(const typet &type)
Definition
java_types.h:183
to_pointer_type
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition
pointer_expr.h:93
invariant.h
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
std_types.h
Pre-defined types.
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
to_array_type
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition
std_types.h:888
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
jbmc
src
java_bytecode
java_bytecode_typecheck_type.cpp
Generated by
1.17.0