stage3/lvalue_check.cc
changeset 826 1e6bf9839ece
parent 718 a9f8cc778444
child 828 a5f08df62002
equal deleted inserted replaced
825:6658fc039264 826:1e6bf9839ece
   112 	/* 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.
   113 	 * 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)
   114 	 * 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...
   115 	 * if (NULL == struct_elem) ERROR;
   115 	 * if (NULL == struct_elem) ERROR;
   116 	 */
   116 	 */
   117 	symbol_c *struct_elem = decompose_lvalue.next_part();
   117 	symbol_c *struct_elem = decompose_lvalue.get_next();
   118 	if (NULL == struct_elem) return;
   118 	if (NULL == struct_elem) return;
   119 	
   119 	
   120 	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);
   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! */
   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! */
   122 	symbol_c *basetype_id = search_base_type_c::get_basetype_id(/*type_id*/ type_decl);
   122 	symbol_c *basetype_id = search_base_type_c::get_basetype_id(/*type_id*/ type_decl);
   133 	 *       will be of FB type, which means we can quit this check!
   133 	 *       will be of FB type, which means we can quit this check!
   134 	 */
   134 	 */
   135 	function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(basetype_id);
   135 	function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(basetype_id);
   136 	if (function_block_type_symtable.end_value() == fb_decl) return;
   136 	if (function_block_type_symtable.end_value() == fb_decl) return;
   137 
   137 
   138 	while (NULL != (struct_elem = decompose_lvalue.next_part())) {
   138 	while (NULL != (struct_elem = decompose_lvalue.get_next())) {
   139 		search_var_instance_decl_c   fb_search_var_instance_decl(fb_decl);
   139 		search_var_instance_decl_c   fb_search_var_instance_decl(fb_decl);
   140 		if (search_var_instance_decl_c::output_vt == fb_search_var_instance_decl.get_vartype(struct_elem)) {
   140 		if (search_var_instance_decl_c::output_vt == fb_search_var_instance_decl.get_vartype(struct_elem)) {
   141 			STAGE3_ERROR(0, struct_elem, struct_elem, "Assignment to FB output variable is not allowed.");
   141 			STAGE3_ERROR(0, struct_elem, struct_elem, "Assignment to FB output variable is not allowed.");
   142 			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! */
   143 		}
   143 		}