Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
{extern IEC_BYTE __IS_GLOBAL_##name##_FORCED();\
if (!(prefix name.flags & __IEC_FORCE_FLAG || __IS_GLOBAL_##name##_FORCED()))\
(*(prefix name.value)) suffix = new_value;}
#define __SET_EXTERNAL_ARRAY(prefix, arrayname, index, new_value)\
{extern IEC_BYTE __IS_GLOBAL_##arrayname##_FORCED();\
if (!(prefix arrayname.flags & __IEC_FORCE_FLAG || __IS_GLOBAL_##arrayname##_FORCED()))\
(*(prefix arrayname.value)).table[index] = new_value;}
#define __SET_EXTERNAL_FB(prefix, name, suffix, new_value)\
__SET_VAR((*(prefix name)), suffix, new_value)
#define __SET_LOCATED(prefix, name, suffix, new_value)\
Expand Down
21 changes: 18 additions & 3 deletions stage4/generate_c/generate_c_st.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,24 @@ void *print_setter(symbol_c* symbol,
// Generate the macro with field as the "name" parameter
unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);

if (vartype == search_var_instance_decl_c::external_vt)
s4o.print(SET_EXTERNAL);
else if (vartype == search_var_instance_decl_c::located_vt)
if (vartype == search_var_instance_decl_c::external_vt) {
symbol_c *array_type = search_varfb_instance_type->get_basetype_decl(array_var->subscripted_variable);
s4o.print("__SET_EXTERNAL_ARRAY(");
print_variable_prefix();
s4o.print(",");
accept_without_prefix(array_var->subscripted_variable);
s4o.print(",");
current_array_type = array_type;
array_var->subscript_list->accept(*this);
current_array_type = NULL;
s4o.print(",");
wanted_variablegeneration = expression_vg;
print_check_function(type, value, fb_value);
s4o.print(")");
wanted_variablegeneration = expression_vg;
return NULL;
}
if (vartype == search_var_instance_decl_c::located_vt)
s4o.print(SET_LOCATED);
else
s4o.print(SET_VAR);
Expand Down