@@ -100,12 +100,12 @@ void statement_list_typecheckt::typecheck()
100
100
parse_tree.function_blocks )
101
101
{
102
102
symbolt &fb_sym{symbol_table.get_writeable_ref (fb.name )};
103
- typecheck_statement_list_networks (fb. networks , fb_sym);
103
+ typecheck_statement_list_networks (fb, fb_sym);
104
104
}
105
105
for (const statement_list_parse_treet::functiont &fc : parse_tree.functions )
106
106
{
107
107
symbolt &function_sym{symbol_table.get_writeable_ref (fc.name )};
108
- typecheck_statement_list_networks (fc. networks , function_sym);
108
+ typecheck_statement_list_networks (fc, function_sym);
109
109
}
110
110
}
111
111
@@ -149,14 +149,12 @@ void statement_list_typecheckt::typecheck_function_block_declaration(
149
149
param_sym.mode = STATEMENT_LIST_MODE;
150
150
symbol_table.add (param_sym);
151
151
152
- // Setup FB symbol type and value and add it to the symbol table .
152
+ // Setup FB symbol type and value.
153
153
code_typet::parameterst params;
154
154
params.push_back (param);
155
155
code_typet fb_type{params, empty_typet ()};
156
156
fb_type.set (ID_statement_list_type, ID_statement_list_function_block);
157
157
function_block_sym.type = fb_type;
158
- function_block_sym.value = code_blockt{};
159
- typecheck_temp_var_decls (function_block, function_block_sym);
160
158
symbol_table.add (function_block_sym);
161
159
}
162
160
@@ -180,10 +178,6 @@ void statement_list_typecheckt::typecheck_function_declaration(
180
178
code_typet fc_type{params, function.return_type };
181
179
fc_type.set (ID_statement_list_type, ID_statement_list_function);
182
180
function_sym.type = fc_type;
183
- function_sym.value = code_blockt{};
184
-
185
- typecheck_temp_var_decls (function, function_sym);
186
-
187
181
symbol_table.add (function_sym);
188
182
}
189
183
@@ -285,15 +279,23 @@ void statement_list_typecheckt::typecheck_temp_var_decls(
285
279
}
286
280
287
281
void statement_list_typecheckt::typecheck_statement_list_networks (
288
- const statement_list_parse_treet::networkst &networks ,
289
- symbolt &tia_element )
282
+ const statement_list_parse_treet::tia_modulet &tia_module ,
283
+ symbolt &tia_symbol )
290
284
{
291
- for (const auto &network : networks)
285
+ // Leave value empty if there are no networks to iterate through.
286
+ if (tia_module.networks .empty ())
287
+ return ;
288
+ if (tia_symbol.value .is_nil ())
289
+ tia_symbol.value = code_blockt{};
290
+
291
+ typecheck_temp_var_decls (tia_module, tia_symbol);
292
+
293
+ for (const auto &network : tia_module.networks )
292
294
{
293
295
// Set RLO to true each time a new network is entered (TIA behaviour).
294
296
rlo_bit = true_exprt ();
295
297
for (const auto &instruction : network.instructions )
296
- typecheck_statement_list_instruction (instruction, tia_element );
298
+ typecheck_statement_list_instruction (instruction, tia_symbol );
297
299
}
298
300
}
299
301
0 commit comments