Skip to content

Commit 8cf378e

Browse files
MatWisetautschnig
authored andcommitted
Clear STL module and network state on entering new
Sets the typecheck to the correct state for verifying new blocks or networks. Limitations: The accumulator is unaffected by this. It needs to be investigated whether the accumulator gets reset at all in TIA.
1 parent d2ced33 commit 8cf378e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/statement-list/statement_list_typecheck.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ void statement_list_typecheckt::typecheck_statement_list_networks(
343343
if(tia_symbol.value.is_nil())
344344
tia_symbol.value = code_blockt{};
345345

346+
clear_module_state();
346347
typecheck_temp_var_decls(tia_module, tia_symbol);
347348

348349
for(const auto &network : tia_module.networks)
349350
{
350-
// Set RLO to true each time a new network is entered (TIA behaviour).
351-
rlo_bit = true_exprt();
351+
clear_network_state();
352352
for(const auto &instruction : network.instructions)
353353
typecheck_statement_list_instruction(instruction, tia_symbol);
354354
}
@@ -1804,6 +1804,21 @@ void statement_list_typecheckt::initialize_bit_expression(const exprt &op)
18041804
rlo_bit = op;
18051805
}
18061806

1807+
void statement_list_typecheckt::clear_network_state()
1808+
{
1809+
rlo_bit = true_exprt{};
1810+
fc_bit = false;
1811+
or_bit = false;
1812+
nesting_stack.clear();
1813+
}
1814+
1815+
void statement_list_typecheckt::clear_module_state()
1816+
{
1817+
clear_network_state();
1818+
label_references.clear();
1819+
stl_labels.clear();
1820+
}
1821+
18071822
void statement_list_typecheckt::save_rlo_state(symbolt &tia_element)
18081823
{
18091824
symbol_exprt temp_rlo{

src/statement-list/statement_list_typecheck.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ class statement_list_typecheckt : public typecheckt
756756
/// \param op: Operand of the encountered instruction.
757757
void initialize_bit_expression(const exprt &op);
758758

759+
/// Modifies the state of the typecheck to resemble the beginning of a new
760+
/// module. All changes to the implicit typecheck fields are close to the
761+
/// original TIA behaviour.
762+
void clear_module_state();
763+
764+
/// Modifies the state of the typecheck to resemble the beginning of a new
765+
/// network. All changes to the implicit typecheck fields are close to the
766+
/// original TIA behaviour.
767+
void clear_network_state();
768+
759769
/// Saves the current RLO bit to a temporary variable to prevent false
760770
/// overrides when modifying boolean variables.
761771
/// \param tia_element: Symbol representation of the TIA element.

0 commit comments

Comments
 (0)