stage3/fill_candidate_datatypes.cc
changeset 837 e0184feaebd2
parent 834 783ef40344dd
child 854 13d0b67de111
equal deleted inserted replaced
836:149398f525a7 837:e0184feaebd2
   602 	symbol_c *prev_instruction_type, *operand_type;
   602 	symbol_c *prev_instruction_type, *operand_type;
   603 
   603 
   604 	if (NULL == prev_il_instruction) return NULL;
   604 	if (NULL == prev_il_instruction) return NULL;
   605 	if (NULL == il_operand)          return NULL;
   605 	if (NULL == il_operand)          return NULL;
   606 
   606 
       
   607 	/* Try the Set/Reset semantics */
   607 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
   608 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
   608 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
   609 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
   609 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
   610 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
   610 			operand_type = il_operand->candidate_datatypes[j];
   611 			operand_type = il_operand->candidate_datatypes[j];
   611 			/* IEC61131-3, Table 52, Note (e) states that the datatype of the operand must be BOOL!
   612 			/* IEC61131-3, Table 52, Note (e) states that the datatype of the operand must be BOOL!
   616 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
   617 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
   617 		}
   618 		}
   618 	}
   619 	}
   619 
   620 
   620 	/* if the appropriate semantics is not a Set/Reset of a boolean variable, the we try for the FB invocation! */
   621 	/* if the appropriate semantics is not a Set/Reset of a boolean variable, the we try for the FB invocation! */
   621 	if (symbol->candidate_datatypes.size() == 0) 
   622 	if (symbol->candidate_datatypes.size() == 0) {
   622 		handle_implicit_il_fb_call(symbol,  operator_str, called_fb_declaration);
   623 		handle_implicit_il_fb_call(symbol,  operator_str, called_fb_declaration);
   623 
   624 		/* If it is also not a valid FB call, make sure the candidate_datatypes is empty (handle_implicit_il_fb_call may leave it non-empty!!) */
   624 	/* If it is also not a valid FB call, make sure the candidate_datatypes is empty (handle_implicit_il_fb_call may leave it non-empty!!) */
   625 		/* From here on out, all later code will consider the symbol->called_fb_declaration being NULL as an indication that this operator must use the
   625 	/* From here on out, all later code will consider the symbol->called_fb_declaration being NULL as an indication that this operator must use the
   626 		 * Set/Reset semantics, so we must also guarantee that the remainder of the state of this symbol is compatible with that assumption!
   626 	 * Set/Reset semantics, so we must also guarantee that the remainder of the state of this symbol is compatible with that assumption!
   627 		 */
   627 	 */
   628 		if (NULL == called_fb_declaration)
   628 	if (NULL == called_fb_declaration)
   629 			symbol->candidate_datatypes.clear();
   629 		symbol->candidate_datatypes.clear();
   630 	}
   630 
   631 
   631 	if (debug) std::cout << operator_str << " [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
   632 	if (debug) std::cout << operator_str << " [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
   632 	return NULL;
   633 	return NULL;
   633 }
   634 }
   634 
   635