stage3/datatype_functions.cc
changeset 445 e6c34ee82954
parent 443 ff4d26b7e51d
child 447 aad0f3e5df33
equal deleted inserted replaced
444:92d40d2a7adc 445:e6c34ee82954
    22  * used in safety-critical situations without a full and competent review.
    22  * used in safety-critical situations without a full and competent review.
    23  */
    23  */
    24 
    24 
    25 #include "datatype_functions.hh"
    25 #include "datatype_functions.hh"
    26 #include "../absyntax_utils/absyntax_utils.hh"
    26 #include "../absyntax_utils/absyntax_utils.hh"
       
    27 #include <algorithm>
    27 
    28 
    28 
    29 
    29 
    30 
    30 
    31 
    31 
    32 
   169 };
   170 };
   170 
   171 
   171 /* Search for a datatype inside a candidate_datatypes list.
   172 /* Search for a datatype inside a candidate_datatypes list.
   172  * Returns: position of datatype in the list, or -1 if not found.
   173  * Returns: position of datatype in the list, or -1 if not found.
   173  */
   174  */
   174 int search_in_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes) {
   175 int search_in_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes) {
   175 	if (NULL == datatype) 
   176 	if (NULL == datatype) 
   176 		return -1;
   177 		return -1;
   177 
   178 
   178 	for(unsigned int i = 0; i < candidate_datatypes.size(); i++)
   179 	for(unsigned int i = 0; i < candidate_datatypes.size(); i++)
   179 		if (is_type_equal(datatype, candidate_datatypes[i]))
   180 		if (is_type_equal(datatype, candidate_datatypes[i]))
   190  * into the candidate_datatype_list of another symbol (to)
   191  * into the candidate_datatype_list of another symbol (to)
   191  */
   192  */
   192 void copy_candidate_datatype_list(symbol_c *from, symbol_c *to) {
   193 void copy_candidate_datatype_list(symbol_c *from, symbol_c *to) {
   193 	if ((NULL == from) || (NULL == to))
   194 	if ((NULL == from) || (NULL == to))
   194 		return;
   195 		return;
   195 
   196 	std::copy(from->candidate_datatypes.begin(), from->candidate_datatypes.end(), to->candidate_datatypes.begin());
   196 	for(unsigned int i = 0; i < from->candidate_datatypes.size(); i++)
       
   197 		to->candidate_datatypes.push_back(from->candidate_datatypes[i]);
       
   198 }
   197 }
   199 
   198 
   200 
   199 
   201 
   200 
   202 
   201