Skip to content

Commit 153618e

Browse files
committed
Add STL var type marker
Adds a property to each variable declaration so that their type (e.g. input or output) can be distinguished.
1 parent c020ea7 commit 153618e

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

src/statement-list/statement_list_typecheck.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ void statement_list_typecheckt::typecheck_function_declaration(
170170
function_sym.pretty_name = function_sym.name;
171171
function_sym.mode = STATEMENT_LIST_MODE;
172172
code_typet::parameterst params;
173-
typecheck_function_var_decls(function.var_input, params, function.name);
174-
typecheck_function_var_decls(function.var_inout, params, function.name);
175-
typecheck_function_var_decls(function.var_output, params, function.name);
173+
typecheck_function_var_decls(
174+
function.var_input, params, function.name, ID_statement_list_var_input);
175+
typecheck_function_var_decls(
176+
function.var_inout, params, function.name, ID_statement_list_var_inout);
177+
typecheck_function_var_decls(
178+
function.var_output, params, function.name, ID_statement_list_var_output);
176179

177180
code_typet fc_type{params, function.return_type};
178181
fc_type.set(ID_statement_list_type, ID_statement_list_function);
@@ -204,32 +207,39 @@ struct_typet statement_list_typecheckt::create_instance_data_block_type(
204207
const statement_list_parse_treet::function_blockt &function_block)
205208
{
206209
struct_union_typet::componentst components;
207-
typecheck_function_block_var_decls(function_block.var_input, components);
208-
typecheck_function_block_var_decls(function_block.var_inout, components);
209-
typecheck_function_block_var_decls(function_block.var_output, components);
210-
typecheck_function_block_var_decls(function_block.var_static, components);
210+
typecheck_function_block_var_decls(
211+
function_block.var_input, components, ID_statement_list_var_input);
212+
typecheck_function_block_var_decls(
213+
function_block.var_inout, components, ID_statement_list_var_inout);
214+
typecheck_function_block_var_decls(
215+
function_block.var_output, components, ID_statement_list_var_output);
216+
typecheck_function_block_var_decls(
217+
function_block.var_static, components, ID_statement_list_var_static);
211218

212219
return struct_typet{components};
213220
}
214221

215222
void statement_list_typecheckt::typecheck_function_block_var_decls(
216223
const statement_list_parse_treet::var_declarationst &var_decls,
217-
struct_union_typet::componentst &components)
224+
struct_union_typet::componentst &components,
225+
const irep_idt &var_property)
218226
{
219227
for(const statement_list_parse_treet::var_declarationt &declaration :
220228
var_decls)
221229
{
222230
const irep_idt &var_name{declaration.variable.get_identifier()};
223231
const typet &var_type{declaration.variable.type()};
224232
struct_union_typet::componentt component{var_name, var_type};
233+
component.set(ID_statement_list_type, var_property);
225234
components.push_back(component);
226235
}
227236
}
228237

229238
void statement_list_typecheckt::typecheck_function_var_decls(
230239
const statement_list_parse_treet::var_declarationst &var_decls,
231240
code_typet::parameterst &params,
232-
const irep_idt &function_name)
241+
const irep_idt &function_name,
242+
const irep_idt &var_property)
233243
{
234244
for(const statement_list_parse_treet::var_declarationt &declaration :
235245
var_decls)
@@ -247,6 +257,7 @@ void statement_list_typecheckt::typecheck_function_var_decls(
247257
code_typet::parametert param{declaration.variable.type()};
248258
param.set_identifier(param_sym.name);
249259
param.set_base_name(declaration.variable.get_identifier());
260+
param.set(ID_statement_list_type, var_property);
250261
params.push_back(param);
251262
}
252263
}

src/statement-list/statement_list_typecheck.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,26 @@ class statement_list_typecheckt : public typecheckt
143143
/// to the given component element.
144144
/// \param var_decls: List of declarations which should be typechecked.
145145
/// \param [out] components: List of typechecked and converted declarations.
146+
/// \param var_property: Type of variable declaration list (for example
147+
/// input, output, ...).
146148
void typecheck_function_block_var_decls(
147149
const statement_list_parse_treet::var_declarationst &var_decls,
148-
struct_union_typet::componentst &components);
150+
struct_union_typet::componentst &components,
151+
const irep_idt &var_property);
149152

150153
/// Performs a typecheck on a variable declaration list and saves the result
151154
/// to the given component element.
152155
/// \param var_decls: List of declarations which should be typechecked.
153156
/// \param [out] params: List of typechecked and converted declarations.
154157
/// \param function_name: Function to which the variable list belongs (used
155158
/// for naming).
159+
/// \param var_property: Type of variable declaration list (for example
160+
/// input, output, ...).
156161
void typecheck_function_var_decls(
157162
const statement_list_parse_treet::var_declarationst &var_decls,
158163
code_typet::parameterst &params,
159-
const irep_idt &function_name);
164+
const irep_idt &function_name,
165+
const irep_idt &var_property);
160166

161167
/// Performs a typecheck on the temp variables of a TIA module and saves the
162168
/// result to the given symbol value.

0 commit comments

Comments
 (0)