27#define STATEMENT_LIST_PTR_WIDTH 64
29#define TYPECHECK_ERROR 0
31#define DATA_BLOCK_PARAMETER_NAME "data_block"
33#define DATA_BLOCK_TYPE_POSTFIX "_db"
35#define CPROVER_ASSERT CPROVER_PREFIX "assert"
37#define CPROVER_ASSUME CPROVER_PREFIX "assume"
39#define CPROVER_TEMP_RLO CPROVER_PREFIX "temp_rlo"
42 ID_statement_list_and,
43 ID_statement_list_and_not,
45 ID_statement_list_or_not,
46 ID_statement_list_xor,
47 ID_statement_list_xor_not,
48 ID_statement_list_and_nested,
49 ID_statement_list_and_not_nested,
50 ID_statement_list_or_nested,
51 ID_statement_list_or_not_nested,
52 ID_statement_list_xor_nested,
53 ID_statement_list_xor_not_nested,
57 ID_statement_list_set_rlo,
58 ID_statement_list_clr_rlo,
59 ID_statement_list_set,
60 ID_statement_list_reset,
61 ID_statement_list_assign,
85 const std::string &module,
89 parse_tree, symbol_table, module, message_handler);
121 const std::string &
module,
161 symbolt function_block_sym{function_block.
name,
typet{}, ID_statement_list};
162 function_block_sym.
module =
module;
187 param_sym.
module =
module;
192 param_sym.
mode = ID_statement_list;
197 params.push_back(param);
199 fb_type.
set(ID_statement_list_type, ID_statement_list_function_block);
200 function_block_sym.
type = fb_type;
208 function_sym.
module =
module;
213 function.
var_input, params, function.
name, ID_statement_list_var_input);
215 function.
var_inout, params, function.
name, ID_statement_list_var_inout);
217 function.
var_output, params, function.
name, ID_statement_list_var_output);
220 fc_type.
set(ID_statement_list_type, ID_statement_list_function);
221 function_sym.
type = fc_type;
253 function_block.
var_input, components, ID_statement_list_var_input);
255 function_block.
var_inout, components, ID_statement_list_var_inout);
257 function_block.
var_output, components, ID_statement_list_var_output);
259 function_block.
var_static, components, ID_statement_list_var_static);
272 const irep_idt &var_name{declaration.variable.get_identifier()};
273 const typet &var_type{declaration.variable.type()};
275 component.set(ID_statement_list_type, var_property);
290 param_sym.
module =
module;
291 param_sym.
type = declaration.variable.type();
293 "::" +
id2string(declaration.variable.get_identifier());
294 param_sym.
base_name = declaration.variable.get_identifier();
296 param_sym.
mode = ID_statement_list;
302 param.
set(ID_statement_list_type, var_property);
303 params.push_back(param);
342 for(
const auto &network : tia_module.
networks)
345 for(
const auto &instruction : network.instructions)
355 error() <<
"Unable to find the labels:";
375 const codet &instruction,
380 if(ID_label == statement)
382 else if(ID_statement_list_load == statement)
384 else if(ID_statement_list_transfer == statement)
386 else if(ID_statement_list_accu_int_add == statement)
388 else if(ID_statement_list_accu_int_sub == statement)
390 else if(ID_statement_list_accu_int_mul == statement)
392 else if(ID_statement_list_accu_int_div == statement)
394 else if(ID_statement_list_accu_int_eq == statement)
396 else if(ID_statement_list_accu_int_neq == statement)
398 else if(ID_statement_list_accu_int_lt == statement)
400 else if(ID_statement_list_accu_int_gt == statement)
402 else if(ID_statement_list_accu_int_lte == statement)
404 else if(ID_statement_list_accu_int_gte == statement)
406 else if(ID_statement_list_accu_dint_add == statement)
408 else if(ID_statement_list_accu_dint_sub == statement)
410 else if(ID_statement_list_accu_dint_mul == statement)
412 else if(ID_statement_list_accu_dint_div == statement)
414 else if(ID_statement_list_accu_dint_eq == statement)
416 else if(ID_statement_list_accu_dint_neq == statement)
418 else if(ID_statement_list_accu_dint_lt == statement)
420 else if(ID_statement_list_accu_dint_gt == statement)
422 else if(ID_statement_list_accu_dint_lte == statement)
424 else if(ID_statement_list_accu_dint_gte == statement)
426 else if(ID_statement_list_accu_real_add == statement)
428 else if(ID_statement_list_accu_real_sub == statement)
430 else if(ID_statement_list_accu_real_mul == statement)
432 else if(ID_statement_list_accu_real_div == statement)
434 else if(ID_statement_list_accu_real_eq == statement)
436 else if(ID_statement_list_accu_real_neq == statement)
438 else if(ID_statement_list_accu_real_lt == statement)
440 else if(ID_statement_list_accu_real_gt == statement)
442 else if(ID_statement_list_accu_real_lte == statement)
444 else if(ID_statement_list_accu_real_gte == statement)
446 else if(ID_statement_list_not == statement)
448 else if(ID_statement_list_and == statement)
450 else if(ID_statement_list_and_not == statement)
452 else if(ID_statement_list_or == statement)
454 else if(ID_statement_list_or_not == statement)
456 else if(ID_statement_list_xor == statement)
458 else if(ID_statement_list_xor_not == statement)
460 else if(ID_statement_list_and_nested == statement)
462 else if(ID_statement_list_and_not_nested == statement)
464 else if(ID_statement_list_or_nested == statement)
466 else if(ID_statement_list_or_not_nested == statement)
468 else if(ID_statement_list_xor_nested == statement)
470 else if(ID_statement_list_xor_not_nested == statement)
472 else if(ID_statement_list_nesting_closed == statement)
474 else if(ID_statement_list_assign == statement)
476 else if(ID_statement_list_set_rlo == statement)
478 else if(ID_statement_list_clr_rlo == statement)
480 else if(ID_statement_list_set == statement)
482 else if(ID_statement_list_reset == statement)
484 else if(ID_statement_list_jump_unconditional == statement)
486 else if(ID_statement_list_jump_conditional == statement)
488 else if(ID_statement_list_jump_conditional_not == statement)
490 else if(ID_statement_list_nop == statement)
492 else if(ID_statement_list_call == statement)
496 error() <<
"OP code of instruction not found: "
503 const codet &instruction,
559 bool jumps_permitted =
false;
560 bool fc_false_required =
false;
563 jumps_permitted =
true;
568 fc_false_required =
true;
577 jumps_permitted =
true;
604 for(
auto jump_location_it = begin(reference_it->second);
605 jump_location_it != end(reference_it->second);
611 <<
" can not be unconditional" <<
eom;
617 <<
" violates brace scope" <<
eom;
627 const codet &op_code,
642 error() <<
"Instruction is not followed by symbol or constant" <<
eom;
648 const codet &op_code,
655 error() <<
"Types of transfer assignment do not match" <<
eom;
663 const codet &op_code)
676 const codet &op_code)
689 const codet &op_code)
702 const codet &op_code)
715 const codet &op_code)
722 const codet &op_code)
729 const codet &op_code)
736 const codet &op_code)
743 const codet &op_code)
750 const codet &op_code)
757 const codet &op_code)
770 const codet &op_code)
783 const codet &op_code)
796 const codet &op_code)
809 const codet &op_code)
816 const codet &op_code)
823 const codet &op_code)
830 const codet &op_code)
837 const codet &op_code)
844 const codet &op_code)
851 const codet &op_code)
864 const codet &op_code)
877 const codet &op_code)
890 const codet &op_code)
903 const codet &op_code)
910 const codet &op_code)
917 const codet &op_code)
924 const codet &op_code)
931 const codet &op_code)
938 const codet &op_code)
945 const codet &op_code)
953 const codet &op_code,
975 const codet &op_code,
997 const codet &op_code,
1022 const codet &op_code,
1043 const codet &op_code,
1063 const codet &op_code,
1095 const codet &op_code)
1103 const codet &op_code)
1111 const codet &op_code)
1119 const codet &op_code)
1127 const codet &op_code)
1135 const codet &op_code)
1143 const codet &op_code)
1148 error() <<
"Wrong order of brackets (Right parenthesis is not preceded by "
1156 if(ID_statement_list_and_nested == statement)
1167 else if(ID_statement_list_and_not_nested == statement)
1178 else if(ID_statement_list_or_nested == statement)
1183 else if(ID_statement_list_or_not_nested == statement)
1188 else if(ID_statement_list_xor_nested == statement)
1193 else if(ID_statement_list_xor_not_nested == statement)
1202 const codet &op_code,
1210 error() <<
"Types of assign do not match" <<
eom;
1223 const codet &op_code)
1232 const codet &op_code)
1241 const codet &op_code,
1258 const codet &op_code,
1275 const codet &op_code,
1288 error() <<
"Called function could not be found" <<
eom;
1296 const codet &op_code,
1309 const codet &op_code,
1327 const codet &op_code,
1345 const codet &op_code)
1360 error() <<
"Operands of integer addition are no integers" <<
eom;
1366 const codet &op_code)
1381 error() <<
"Operands of double integer addition are no double integers"
1388 const codet &op_code)
1398 error() <<
"Operands of Real addition do not have the type Real" <<
eom;
1422 if(!label_it->second.jumps_permitted)
1424 error() <<
"Not allowed to jump to label " <<
id2string(label_it->first)
1429 if(label_it->second.fc_false_required && !sets_fc_false)
1432 <<
" can not be unconditional" <<
eom;
1439 <<
" violates brace scope" <<
eom;
1449 std::vector<stl_jump_locationt> locations;
1450 locations.push_back(location);
1454 reference_it->second.push_back(location);
1460 const codet &op_code)
1468 error() <<
"Instruction is not followed by symbol" <<
eom;
1473 const codet &op_code)
1477 error() <<
"Instruction is followed by operand" <<
eom;
1483 const codet &op_code)
1488 error() <<
"Not enough operands in the accumulator" <<
eom;
1494 const codet &op_code,
1495 const exprt &rlo_value)
1510 const codet &op_code,
1518 return negate ? not_op : op;
1538 return symbol_table.lookup_ref(identifier).symbol_expr();
1541 element_type.
get(ID_statement_list_type) ==
1542 ID_statement_list_function_block)
1554 if(member.get_name() == identifier)
1563 element_type.
get(ID_statement_list_type) == ID_statement_list_function)
1566 for(
const auto &member : element_type.
parameters())
1568 if(member.get_base_name() == identifier)
1571 symbol_table.get_writeable_ref(member.get_identifier())};
1579 error() <<
"Identifier could not be found in project" <<
eom;
1584 const codet &op_code,
1588 const auto assignment =
1597 error() <<
"No assignment found for assertion" <<
eom;
1603 const codet &op_code,
1607 const auto assignment =
1616 error() <<
"No assignment found for assumption" <<
eom;
1622 const codet &op_code,
1626 const symbolt &called_function{
1631 called_type.
get(ID_statement_list_type) == ID_statement_list_function_block)
1633 else if(called_type.
get(ID_statement_list_type) == ID_statement_list_function)
1637 error() <<
"Tried to call element that is no function or function block"
1644 const codet &op_code,
1648 const symbolt &called_function_sym{
1656 error() <<
"Function calls should not address instance data blocks" <<
eom;
1663 std::vector<code_frontend_assignt> assignments;
1664 for(
const auto &expr : op_code.
operands())
1667 assignments.push_back(*assign);
1681 assignments, called_type.
return_type(), tia_element)};
1688 const codet &op_code,
1695 error() <<
"Calls to function blocks are not supported yet" <<
eom;
1700 const std::vector<code_frontend_assignt> &assignments,
1706 for(
const auto &assignment : assignments)
1711 exprt assigned_variable{
1714 if(param_type == assigned_variable.
type())
1715 return assigned_variable;
1718 error() <<
"Types of parameter assignment do not match: "
1719 << param.
type().
id() <<
" != " << assigned_variable.
type().
id()
1725 error() <<
"No assignment found for function parameter "
1734 exprt assigned_operand;
1741 assigned_operand = rhs;
1742 return assigned_operand;
1746 const std::vector<code_frontend_assignt> &assignments,
1747 const typet &return_type,
1750 for(
const auto &assignment : assignments)
1756 const exprt assigned_variable{
1758 if(return_type == assigned_variable.
type())
1759 return assigned_variable;
1762 error() <<
"Types of return value assignment do not match: "
1763 << return_type.
id() <<
" != " << assigned_variable.
type().
id()
1769 error() <<
"No assignment found for function return value" <<
eom;
1783 or_wrapper.
op1() = and_op;
1788 or_wrapper.
op1() = and_op;
1821 rlo_bit = std::move(temp_rlo);
Boolean AND All operands must be boolean, and the result is always boolean.
A base class for relations, i.e., binary predicates whose two operands have the same type.
std::size_t get_width() const
A non-fatal assertion, which checks a condition then permits execution to continue.
A goto_instruction_codet representing an assignment in the program.
An assumption, which must hold in subsequent code.
A codet representing sequential composition of program statements.
A goto_instruction_codet representing the declaration of a local variable.
goto_instruction_codet representation of a function call statement.
exprt::operandst argumentst
codet representation of a goto statement.
codet representation of an if-then-else statement.
codet representation of a label for branch targets.
const irep_idt & get_label() const
A codet representing a skip statement.
const irep_idt & get_base_name() const
void set_base_name(const irep_idt &name)
const irep_idt & get_identifier() const
void set_identifier(const irep_idt &identifier)
std::vector< parametert > parameterst
const parameterst & parameters() const
const typet & return_type() const
Data structure for representing an arbitrary statement in a program.
const irep_idt & get_statement() const
Operator to dereference a pointer.
Base class for all expressions.
typet & type()
Return the type of the expression.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
The Boolean constant false.
const irep_idt & get(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
Extract member of struct or union.
message_handlert * message_handler
Binary multiplication Associativity is not specified.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Boolean OR All operands must be boolean, and the result is always boolean.
Symbol table entry of function parameterThis is a symbol generated as part of type checking.
The plus expression Associativity is not specified.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Fixed-width bit-vector with two's complement interpretation.
Intermediate representation of a parsed Statement List file before converting it into a goto program.
std::list< var_declarationt > var_declarationst
Class for encapsulating the current state of the type check.
void typecheck_accumulator_compare_instruction(const irep_idt &comparison)
Performs a typecheck on an STL comparison instruction.
void typecheck_statement_list_accu_real_div(const codet &op_code)
Performs a typecheck on a STL accumulator divide instruction for reals.
struct_typet create_instance_data_block_type(const statement_list_parse_treet::function_blockt &function_block)
Creates a data block type for the given function block.
const symbol_exprt & typecheck_instruction_with_non_const_operand(const codet &op_code)
Performs a typecheck on a STL instruction with an additional operand that should be no constant.
void typecheck_statement_list_accu_real_lte(const codet &op_code)
Performs a typecheck on a STL accumulator less than or equal comparison instruction for integers.
const statement_list_parse_treet & parse_tree
Parse tree which is used to fill the symbol table.
void typecheck_statement_list_nesting_closed(const codet &op_code)
Performs a typecheck on a Nesting Closed instruction.
void typecheck_statement_list_accu_real_sub(const codet &op_code)
Performs a typecheck on a STL accumulator subtract instruction for reals.
void typecheck_statement_list_networks(const statement_list_parse_treet::tia_modulet &tia_module, symbolt &tia_symbol)
Performs a typecheck on the networks of a TIA module and saves the result to the given symbol.
void clear_module_state()
Modifies the state of the typecheck to resemble the beginning of a new module.
void typecheck_statement_list_accu_int_add(const codet &op_code)
Performs a typecheck on a STL accumulator add instruction for integers.
void typecheck_jump_locations(const code_labelt &label, const stl_label_locationt &location)
Performs a typecheck on all references for the given label.
void typecheck_label_reference(const irep_idt &label, bool sets_fc_false)
Checks if the given label is already present and compares the current state with it.
void typecheck_statement_list_clr_rlo(const codet &op_code)
Performs a typecheck on a STL 'CLR' instruction and modifies the RLO, OR and FC bit.
statement_list_typecheckt(const statement_list_parse_treet &parse_tree, symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler)
Creates a new instance of statement_list_typecheckt.
symbol_table_baset & symbol_table
Reference to the symbol table that should be filled during the typecheck.
void typecheck_statement_list_transfer(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a STL transfer instruction and saves the result to the given symbol.
void typecheck_function_declaration(const statement_list_parse_treet::functiont &function)
Performs a typecheck on a function declaration inside of the parse tree and adds symbols for it and i...
void typecheck_statement_list_accu_dint_gte(const codet &op_code)
Performs a typecheck on a STL accumulator greater than or equal comparison instruction for double int...
void typecheck_statement_list_and_not(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean And Not instruction.
void add_to_or_rlo_wrapper(const exprt &op)
Adds the given expression to the operands of the Or expression that is saved in the RLO.
void typecheck_function_block_var_decls(const statement_list_parse_treet::var_declarationst &var_decls, struct_union_typet::componentst &components, const irep_idt &var_property)
Performs a typecheck on a variable declaration list and saves the result to the given component eleme...
exprt typecheck_return_value_assignment(const std::vector< code_frontend_assignt > &assignments, const typet &return_type, const symbolt &tia_element)
Checks if there is a return value assignment inside of the assignment list of a function call and ret...
exprt typecheck_function_call_argument_rhs(const symbolt &tia_element, const exprt &rhs)
Checks if the given assigned expression is a variable or a constant and returns the typechecked versi...
void typecheck() override
Performs the actual typecheck by using the parse tree with which the object was initialized and modif...
void typecheck_statement_list_accu_dint_mul(const codet &op_code)
Performs a typecheck on a STL accumulator divide instruction for double integers.
void typecheck_statement_list_accu_int_gte(const codet &op_code)
Performs a typecheck on a STL accumulator greater than or equal comparison instruction for integers.
void typecheck_statement_list_nested_xor(const codet &op_code)
Performs a typecheck on a nested XOR instruction.
void typecheck_statement_list_accu_int_mul(const codet &op_code)
Performs a typecheck on a STL accumulator multiply instruction for integers.
const irep_idt module
Name of the module this typecheck belongs to.
void typecheck_statement_list_accu_int_lt(const codet &op_code)
Performs a typecheck on a STL accumulator less than comparison instruction for integers.
void typecheck_statement_list_nested_or_not(const codet &op_code)
Performs a typecheck on a nested Or Not instruction.
void typecheck_statement_list_set_rlo(const codet &op_code)
Performs a typecheck on a STL 'SET' instruction and modifies the RLO, OR and FC bit.
void typecheck_statement_list_accu_dint_add(const codet &op_code)
Performs a typecheck on a STL accumulator add instruction for double integers.
void typecheck_statement_list_accu_real_gt(const codet &op_code)
Performs a typecheck on a STL accumulator greater than comparison instruction for double integers.
std::vector< exprt > accumulator
Representation of the accumulator of a TIA element.
void typecheck_statement_list_nested_xor_not(const codet &op_code)
Performs a typecheck on a nested XOR Not instruction.
void clear_network_state()
Modifies the state of the typecheck to resemble the beginning of a new network.
void typecheck_statement_list_accu_real_eq(const codet &op_code)
Performs a typecheck on a STL accumulator equality comparison instruction for double integers.
void typecheck_statement_list_xor(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean XOR instruction.
exprt typecheck_identifier(const symbolt &tia_element, const irep_idt &identifier)
Performs a typecheck on the given identifier and returns its symbol.
void typecheck_tag_list()
Performs a typecheck on the tag list of the referenced parse tree and adds symbols for its contents t...
void typecheck_statement_list_xor_not(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean XOR Not instruction.
void typecheck_called_tia_element(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a call of a TIA element and saves the result to the given symbol.
void typecheck_statement_list_jump_unconditional(const codet &op_code, symbolt &tia_element)
Performs a typecheck on an unconditional jump instruction (JU) and adds the jump to the given symbol.
void typecheck_code(const codet &instruction, symbolt &tia_element)
Performs a typecheck for the specified instruction in code form.
void typecheck_CPROVER_assume(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a call of __CPOVER_ASSUME and saves the result to the given symbol.
void typecheck_statement_list_accu_real_add(const codet &op_code)
Performs a typecheck on a STL accumulator add instruction for reals.
label_referencest label_references
Holds associations between labels and jumps that are referencing it.
exprt rlo_bit
Result of Logic Operation (Part of the TIA status word).
exprt typecheck_simple_boolean_instruction_operand(const codet &op_code, const symbolt &tia_element, bool negate)
Performs a typecheck on the operand of a not nested boolean instruction and returns the result.
bool or_bit
Or (Part of the TIA status word).
void typecheck_statement_list_accu_dint_lt(const codet &op_code)
Performs a typecheck on a STL accumulator less than comparison instruction for double integers.
stl_labelst stl_labels
Data structure that contains data about the labels of the current module.
void typecheck_function_block_declaration(const statement_list_parse_treet::function_blockt &function_block)
Performs a typecheck on a function block declaration inside of the parse tree and adds symbols for it...
void typecheck_statement_list_load(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL load instruction.
void typecheck_statement_list_accu_int_div(const codet &op_code)
Performs a typecheck on a STL accumulator divide instruction for integers.
stl_label_locationt typecheck_label_location(const code_labelt &label)
Converts the properties of the current typecheck state to a label location.
void typecheck_statement_list_accu_int_neq(const codet &op_code)
Performs a typecheck on a STL accumulator inequality comparison instruction for integers.
void typecheck_statement_list_or(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean Or instruction.
void typecheck_statement_list_accu_int_arith(const codet &op_code)
Performs a typecheck on a STL Accumulator instruction for integers.
void typecheck_statement_list_and(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean And instruction.
void typecheck_statement_list_accu_real_lt(const codet &op_code)
Performs a typecheck on a STL accumulator less than comparison instruction for double integers.
void typecheck_instruction_without_operand(const codet &op_code)
Performs a typecheck on an operand-less STL instruction.
void typecheck_label(const codet &instruction, symbolt &tia_element)
Performs a typecheck for the given label in code form.
bool fc_bit
First Check (Part of the TIA status word).
void typecheck_statement_list_jump_conditional(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a conditional jump instruction (JC) and adds it to the given symbol.
void typecheck_statement_list_jump_conditional_not(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a inverted conditional jump instruction (JCN) and adds it to the given symbol...
void typecheck_statement_list_or_not(const codet &op_code, const symbolt &tia_element)
Performs a typecheck on a STL boolean Or Not instruction.
void typecheck_label_references()
Checks if all jumps reference labels that exist.
void typecheck_binary_accumulator_instruction(const codet &op_code)
Performs a typecheck on a STL instruction that uses two accumulator entries.
void initialize_bit_expression(const exprt &op)
Initializes the FC, RLO an OR bits for the scenario when a new boolean instruction was encontered.
void typecheck_statement_list_call(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a STL Call instruction and saves the result to the given symbol.
void typecheck_statement_list_nested_or(const codet &op_code)
Performs a typecheck on a nested Or instruction.
void typecheck_statement_list_accu_dint_neq(const codet &op_code)
Performs a typecheck on a STL accumulator inequality comparison instruction for double integers.
void typecheck_statement_list_accu_real_mul(const codet &op_code)
Performs a typecheck on a STL accumulator multiply instruction for reals.
exprt typecheck_function_call_arguments(const std::vector< code_frontend_assignt > &assignments, const code_typet::parametert ¶m, const symbolt &tia_element)
Checks if the given parameter is inside of the assignment list of a function call and returns the exp...
void typecheck_temp_var_decls(const statement_list_parse_treet::tia_modulet &tia_module, symbolt &tia_symbol)
Performs a typecheck on the temp variables of a TIA module and saves the result to the given symbol v...
void typecheck_statement_list_accu_dint_arith(const codet &op_code)
Performs a typecheck on a STL Accumulator instruction for double integers.
void typecheck_CPROVER_assert(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a call of __CPOVER_ASSERT and saves the result to the given symbol.
void typecheck_statement_list_nested_and_not(const codet &op_code)
Performs a typecheck on a nested And Not instruction.
void typecheck_statement_list_accu_int_gt(const codet &op_code)
Performs a typecheck on a STL accumulator greater than comparison instruction for integers.
void typecheck_statement_list_accu_int_sub(const codet &op_code)
Performs a typecheck on a STL accumulator subtract instruction for integers.
void typecheck_function_var_decls(const statement_list_parse_treet::var_declarationst &var_decls, code_typet::parameterst ¶ms, const irep_idt &function_name, const irep_idt &var_property)
Performs a typecheck on a variable declaration list and saves the result to the given component eleme...
void typecheck_statement_list_instruction(const statement_list_parse_treet::instructiont &instruction, symbolt &tia_element)
Performs a typecheck on a single instruction and saves the result to the given symbol body if necessa...
void typecheck_statement_list_accu_dint_eq(const codet &op_code)
Performs a typecheck on a STL accumulator equality comparison instruction for double integers.
void typecheck_statement_list_accu_real_arith(const codet &op_code)
Performs a typecheck on a STL Accumulator instruction for reals.
void typecheck_statement_list_accu_real_gte(const codet &op_code)
Performs a typecheck on a STL accumulator greater than or equal comparison instruction for double int...
void typecheck_statement_list_reset(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a STL 'R' instruction and saves the result to the given symbol.
void typecheck_statement_list_accu_real_neq(const codet &op_code)
Performs a typecheck on a STL accumulator inequality comparison instruction for double integers.
nesting_stackt nesting_stack
Representation of the nesting stack.
void typecheck_statement_list_not(const codet &op_code)
Performs a typecheck on a STL boolean NOT instruction.
void typecheck_statement_list_accu_dint_lte(const codet &op_code)
Performs a typecheck on a STL accumulator less than or equal comparison instruction for double intege...
void typecheck_called_function(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a call of a TIA function and saves the result to the given symbol.
void typecheck_statement_list_accu_int_lte(const codet &op_code)
Performs a typecheck on a STL accumulator less than or equal comparison instruction for integers.
void typecheck_statement_list_accu_dint_gt(const codet &op_code)
Performs a typecheck on a STL accumulator greater than comparison instruction for double integers.
void typecheck_statement_list_assign(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a STL assign instruction and saves the result to the given symbol.
void typecheck_statement_list_accu_int_eq(const codet &op_code)
Performs a typecheck on a STL accumulator equality comparison instruction for integers.
void typecheck_statement_list_accu_dint_sub(const codet &op_code)
Performs a typecheck on a STL accumulator subtract instruction for double integers.
void typecheck_called_function_block(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a call of a TIA function block and saves the result to the given symbol.
void typecheck_statement_list_accu_dint_div(const codet &op_code)
Performs a typecheck on a STL accumulator divide instruction for double integers.
void add_temp_rlo()
Adds a symbol for the RLO to the symbol table.
void typecheck_statement_list_nested_and(const codet &op_code)
Performs a typecheck on a nested And instruction.
void save_rlo_state(symbolt &tia_element)
Saves the current RLO bit to a temporary variable to prevent false overrides when modifying boolean v...
void typecheck_nested_boolean_instruction(const codet &op_code, const exprt &rlo_value)
Performs a typecheck on a STL instruction that initializes a new boolean nesting.
void typecheck_statement_list_set(const codet &op_code, symbolt &tia_element)
Performs a typecheck on a STL 'S' instruction and saves the result to the given symbol.
void typecheck_statement_list_and_before_or()
Performs a typecheck on a STL operand-less Or instruction.
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
Expression to hold a symbol (variable).
const irep_idt & get_identifier() const
The symbol table base class interface.
irep_idt base_name
Base (non-scoped) name.
irep_idt module
Name of module the symbol belongs to.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt pretty_name
Language-specific display name.
exprt value
Initial value of symbol.
irep_idt mode
Language mode.
The Boolean constant true.
Symbol table entry describing a data typeThis is a symbol generated as part of type checking.
const typet & subtype() const
typecheckt(message_handlert &_message_handler)
virtual bool typecheck_main()
The type of an expression, extends irept.
Boolean XOR All operands must be boolean, and the result is always boolean.
bool can_cast_expr(const exprt &base)
Check whether a reference to a generic exprt is of a specific derived class.
auto type_try_dynamic_cast(TType &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TType >::type
Try to cast a reference to a generic typet to a specific derived class.
bool can_cast_type(const typet &base)
Check whether a reference to a generic typet is of a specific derived class.
auto expr_try_dynamic_cast(TExpr &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TExpr >::type
Try to cast a reference to a generic exprt to a specific derived class.
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
exprt simplify_expr(exprt src, const namespacet &ns)
#define UNREACHABLE
This should be used to mark dead code.
bool statement_list_typecheck(const statement_list_parse_treet &parse_tree, symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler)
Create a new statement_list_typecheckt object and perform a type check to fill the symbol table.
#define CPROVER_ASSERT
Name of the CBMC assert function.
#define CPROVER_TEMP_RLO
Name of the RLO symbol used in some operations.
static code_typet::parametert create_data_block_parameter(const struct_typet &data_block_type, const irep_idt &function_block_name)
Creates the artificial data block parameter with a generic name and the specified type.
#define DATA_BLOCK_PARAMETER_NAME
Artificial name for the data block interface of a function block.
#define DATA_BLOCK_TYPE_POSTFIX
Postfix for the type of a data block.
#define STATEMENT_LIST_PTR_WIDTH
Size of pointers in Siemens TIA.
static const std::vector< irep_idt > logic_sequence_terminators
#define CPROVER_ASSUME
Name of the CBMC assume function.
static const std::vector< irep_idt > logic_sequence_initializers
Statement List Language Type Checking.
bool_typet get_bool_type()
Creates a new type that resembles the 'Bool' type of the Siemens PLC languages.
Statement List Type Helper.
const code_labelt & to_code_label(const codet &code)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
const and_exprt & to_and_expr(const exprt &expr)
Cast an exprt to a and_exprt.
const or_exprt & to_or_expr(const exprt &expr)
Cast an exprt to a or_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Structure for a simple function block in Statement List.
var_declarationst var_static
FB-exclusive static variable declarations.
Structure for a simple function in Statement List.
const typet return_type
FC-exclusive return type.
Represents a regular Statement List instruction which consists out of one or more codet tokens.
std::vector< codet > tokens
Data structure for all tokens of the instruction.
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
var_declarationst var_input
Input variable declarations.
const irep_idt name
Name of the module.
var_declarationst var_inout
Inout variable declarations.
networkst networks
List of all networks of this module.
var_declarationst var_temp
Temp variable declarations.
var_declarationst var_output
Output variable declarations.
Struct for a single variable declaration in Statement List.
symbol_exprt variable
Representation of the variable, including identifier and type.
Every time branching occurs inside of a boolean expression string in STL, the current value of the RL...
nesting_stack_entryt(exprt rlo_bit, bool or_bit, codet function_code)
exprt rlo_bit
The rlo's value when the entry was generated.
codet function_code
OP code of the instruction that generated the stack entry.
bool or_bit
The OR bit's value when the entry was generated.
Holds information about the properties of a jump instruction.
const size_t nesting_depth
The size of the nesting stack at the label location, used for checking scope violations.
stl_jump_locationt(size_t nesting_depth, bool sets_fc_false)
Constructs a new location with the specified properties.
const bool sets_fc_false
States if the jump instruction sets the /FC bit to false.
Holds information about the instruction and the nesting depth to which a label points.
const bool jumps_permitted
States if jumps to this location are permitted or if the location is invalid.
const size_t nesting_depth
The size of the nesting stack at the label location, used for checking scope violations.
stl_label_locationt(size_t nesting_depth, bool jumps_permitted, bool fc_false_required)
Constructs a new location with the specified properties.
const bool fc_false_required
States if jump instructions to this location need to set the /FC bit to false.
const type_with_subtypet & to_type_with_subtype(const typet &type)