equal
deleted
inserted
replaced
105 * |
105 * |
106 * Note, however, that the first record (fb_instance1 in the above example) may be an output variable! |
106 * Note, however, that the first record (fb_instance1 in the above example) may be an output variable! |
107 */ |
107 */ |
108 void lvalue_check_c::check_assignment_to_output(symbol_c *lvalue) { |
108 void lvalue_check_c::check_assignment_to_output(symbol_c *lvalue) { |
109 decompose_var_instance_name_c decompose_lvalue(lvalue); |
109 decompose_var_instance_name_c decompose_lvalue(lvalue); |
110 search_base_type_c search_base_type; |
|
111 |
110 |
112 /* Get the first element/record of the potentially structured variable symbol */ |
111 /* Get the first element/record of the potentially structured variable symbol */ |
113 /* Note that if symbol is pointing to an expression (or simply a literal value), it will return a NULL. |
112 /* Note that if symbol is pointing to an expression (or simply a literal value), it will return a NULL. |
114 * Once we have implemented the check_assignment_to_expression() method, and abort calling the other checks (including this one) |
113 * Once we have implemented the check_assignment_to_expression() method, and abort calling the other checks (including this one) |
115 * when an expression is found, we may replace this check with an assertion... |
114 * when an expression is found, we may replace this check with an assertion... |
118 symbol_c *struct_elem = decompose_lvalue.next_part(); |
117 symbol_c *struct_elem = decompose_lvalue.next_part(); |
119 if (NULL == struct_elem) return; |
118 if (NULL == struct_elem) return; |
120 |
119 |
121 symbol_c *type_decl = search_var_instance_decl->get_decl(struct_elem); |
120 symbol_c *type_decl = search_var_instance_decl->get_decl(struct_elem); |
122 // symbol_c *type_id = spec_init_sperator_c::get_spec(type_decl); /* this is not required! search_base_type_c can handle spec_init symbols! */ |
121 // symbol_c *type_id = spec_init_sperator_c::get_spec(type_decl); /* this is not required! search_base_type_c can handle spec_init symbols! */ |
123 symbol_c *basetype_id = search_base_type.get_basetype_id(/*type_id*/ type_decl); |
122 symbol_c *basetype_id = search_base_type_c::get_basetype_id(/*type_id*/ type_decl); |
124 /* If we can not determine the data type of the element, then the code must have a data type semantic error. |
123 /* If we can not determine the data type of the element, then the code must have a data type semantic error. |
125 * This will have been caught by the data type semantic verifier, so we do not bother with this anymore! |
124 * This will have been caught by the data type semantic verifier, so we do not bother with this anymore! |
126 */ |
125 */ |
127 if (NULL == basetype_id) return; |
126 if (NULL == basetype_id) return; |
128 |
127 |
143 return; /* no need to carry on checking once the first error is found! */ |
142 return; /* no need to carry on checking once the first error is found! */ |
144 } |
143 } |
145 |
144 |
146 /* prepare for any possible further record/structure elements */ |
145 /* prepare for any possible further record/structure elements */ |
147 type_decl = fb_search_var_instance_decl.get_decl(struct_elem); |
146 type_decl = fb_search_var_instance_decl.get_decl(struct_elem); |
148 basetype_id = search_base_type.get_basetype_id(type_decl); |
147 basetype_id = search_base_type_c::get_basetype_id(type_decl); |
149 if (NULL == basetype_id) return; /* same comment as above... */ |
148 if (NULL == basetype_id) return; /* same comment as above... */ |
150 fb_decl = function_block_type_symtable.find_value(basetype_id); |
149 fb_decl = function_block_type_symtable.find_value(basetype_id); |
151 if (function_block_type_symtable.end_value() == fb_decl) return; /* same comment as above... */ |
150 if (function_block_type_symtable.end_value() == fb_decl) return; /* same comment as above... */ |
152 } |
151 } |
153 } |
152 } |