stage3/fill_candidate_datatypes.cc
changeset 465 b52ec62773db
parent 464 319ee8b218f3
child 467 4910eaa1206a
equal deleted inserted replaced
464:319ee8b218f3 465:b52ec62773db
    61 			return widen_table[k].result;
    61 			return widen_table[k].result;
    62 	return NULL;
    62 	return NULL;
    63 }
    63 }
    64 
    64 
    65 
    65 
    66 
    66 /* add a data type to a candidate data type list, while guaranteeing no duplicate entries! */
       
    67 /* Returns true if it really did add the datatype to the list, or false if it was already present in the list! */
       
    68 bool fill_candidate_datatypes_c::add_datatype_to_candidate_list(symbol_c *symbol, symbol_c *datatype) {
       
    69   if (search_in_candidate_datatype_list(datatype, symbol->candidate_datatypes) >= 0) 
       
    70     /* already in the list, Just return! */
       
    71     return false;
       
    72   
       
    73   /* not yet in the candidate data type list, so we insert it now! */
       
    74   symbol->candidate_datatypes.push_back(datatype);
       
    75   return true;
       
    76 }
       
    77     
       
    78     
       
    79     
       
    80     
    67 
    81 
    68 /* returns true if compatible function/FB invocation, otherwise returns false */
    82 /* returns true if compatible function/FB invocation, otherwise returns false */
    69 /* Assumes that the candidate_datatype lists of all the parameters being passed haved already been filled in */
    83 /* Assumes that the candidate_datatype lists of all the parameters being passed haved already been filled in */
    70 /*
    84 /*
    71  * All parameters being passed to the called function MUST be in the parameter list to which f_call points to!
    85  * All parameters being passed to the called function MUST be in the parameter list to which f_call points to!
   223 	 * compilation is aborted in stage3 (in print_datatypes_error_c).
   237 	 * compilation is aborted in stage3 (in print_datatypes_error_c).
   224 	 */
   238 	 */
   225 	if (function_symtable.multiplicity(fcall_data.function_name) == 1) {
   239 	if (function_symtable.multiplicity(fcall_data.function_name) == 1) {
   226 		f_decl = function_symtable.get_value(lower);
   240 		f_decl = function_symtable.get_value(lower);
   227 		returned_parameter_type = base_type(f_decl->type_name);
   241 		returned_parameter_type = base_type(f_decl->type_name);
   228 		fcall_data.candidate_functions.push_back(f_decl);
   242 		if (add_datatype_to_candidate_list(fcall, returned_parameter_type))
   229 		fcall->    candidate_datatypes.push_back(returned_parameter_type);
   243 			/* we only add it to the function declaration list if this entry was not already present in the candidate datatype list! */
       
   244 			fcall_data.candidate_functions.push_back(f_decl);
       
   245 		
   230 	}
   246 	}
   231 	for(; lower != upper; lower++) {
   247 	for(; lower != upper; lower++) {
   232 		bool compatible = false;
   248 		bool compatible = false;
   233 		
   249 		
   234 		f_decl = function_symtable.get_value(lower);
   250 		f_decl = function_symtable.get_value(lower);
   237 		if (NULL != fcall_data.   formal_operand_list) compatible=   match_formal_call(fcall, f_decl);
   253 		if (NULL != fcall_data.   formal_operand_list) compatible=   match_formal_call(fcall, f_decl);
   238 		if (compatible) {
   254 		if (compatible) {
   239 			/* Add the data type returned by the called functions. 
   255 			/* Add the data type returned by the called functions. 
   240 			 * However, only do this if this data type is not already present in the candidate_datatypes list_c
   256 			 * However, only do this if this data type is not already present in the candidate_datatypes list_c
   241 			 */
   257 			 */
   242 			/* TODO
   258 			returned_parameter_type = base_type(f_decl->type_name);		
   243 			 * call  int search_in_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes);
   259 			if (add_datatype_to_candidate_list(fcall, returned_parameter_type))
   244 			 * instead of using for loop!
   260 				/* we only add it to the function declaration list if this entry was not already present in the candidate datatype list! */
   245 			 */
       
   246 			unsigned int k;
       
   247 			returned_parameter_type = base_type(f_decl->type_name);
       
   248 			for(k = 0; k < fcall->candidate_datatypes.size(); k++) {
       
   249 				if (is_type_equal(returned_parameter_type, fcall->candidate_datatypes[k]))
       
   250 					break;
       
   251 			}
       
   252 			if (k >= fcall->candidate_datatypes.size()) {
       
   253 				fcall->    candidate_datatypes.push_back(returned_parameter_type);
       
   254 				fcall_data.candidate_functions.push_back(f_decl);
   261 				fcall_data.candidate_functions.push_back(f_decl);
   255 			}
       
   256 		}
   262 		}
   257 	}
   263 	}
   258 	if (debug) std::cout << "end_function() [" << fcall->candidate_datatypes.size() << "] result.\n";
   264 	if (debug) std::cout << "end_function() [" << fcall->candidate_datatypes.size() << "] result.\n";
   259 	return;
   265 	return;
   260 }
   266 }
   319 void *fill_candidate_datatypes_c::visit(real_c *symbol) {
   325 void *fill_candidate_datatypes_c::visit(real_c *symbol) {
   320 	int calc_size;
   326 	int calc_size;
   321 
   327 
   322 	calc_size = sizeoftype(symbol);
   328 	calc_size = sizeoftype(symbol);
   323 	if (calc_size <= sizeoftype(&search_constant_type_c::real_type_name))
   329 	if (calc_size <= sizeoftype(&search_constant_type_c::real_type_name))
   324 		symbol->candidate_datatypes.push_back(&search_constant_type_c::real_type_name);
   330 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::real_type_name);
   325 	if (calc_size <= sizeoftype(&search_constant_type_c::lreal_type_name))
   331 	if (calc_size <= sizeoftype(&search_constant_type_c::lreal_type_name))
   326 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lreal_type_name);
   332 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lreal_type_name);
   327 	if (debug) std::cout << "ANY_REAL [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   333 	if (debug) std::cout << "ANY_REAL [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   328 	return NULL;
   334 	return NULL;
   329 }
   335 }
   330 
   336 
   331 void *fill_candidate_datatypes_c::visit(integer_c *symbol) {
   337 void *fill_candidate_datatypes_c::visit(integer_c *symbol) {
   332 	int calc_size;
   338 	int calc_size;
   333 
   339 
   334 	calc_size = sizeoftype(symbol);
   340 	calc_size = sizeoftype(symbol);
   335 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   341 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   336 	        symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   342 	        add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   337 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   343 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   338 		symbol->candidate_datatypes.push_back(&search_constant_type_c::byte_type_name);
   344 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name);
   339 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   345 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   340 		symbol->candidate_datatypes.push_back(&search_constant_type_c::word_type_name);
   346 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name);
   341 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   347 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   342 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dword_type_name);
   348 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name);
   343 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   349 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   344 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lword_type_name);
   350 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name);
   345 
   351 
   346 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   352 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   347 		symbol->candidate_datatypes.push_back(&search_constant_type_c::sint_type_name);
   353 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name);
   348 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   354 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   349 		symbol->candidate_datatypes.push_back(&search_constant_type_c::int_type_name);
   355 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name);
   350 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   356 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   351 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dint_type_name);
   357 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name);
   352 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   358 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   353 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lint_type_name);
   359 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name);
   354 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   360 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   355 		symbol->candidate_datatypes.push_back(&search_constant_type_c::usint_type_name);
   361 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::usint_type_name);
   356 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   362 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   357 		symbol->candidate_datatypes.push_back(&search_constant_type_c::uint_type_name);
   363 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::uint_type_name);
   358 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   364 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   359 		symbol->candidate_datatypes.push_back(&search_constant_type_c::udint_type_name);
   365 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::udint_type_name);
   360 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   366 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   361 		symbol->candidate_datatypes.push_back(&search_constant_type_c::ulint_type_name);
   367 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name);
   362 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   368 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   363 	return NULL;
   369 	return NULL;
   364 }
   370 }
   365 
   371 
   366 void *fill_candidate_datatypes_c::visit(neg_real_c *symbol) {
   372 void *fill_candidate_datatypes_c::visit(neg_real_c *symbol) {
   367 	if (sizeoftype(symbol) <= sizeoftype(&search_constant_type_c::real_type_name))
   373 	if (sizeoftype(symbol) <= sizeoftype(&search_constant_type_c::real_type_name))
   368 		symbol->candidate_datatypes.push_back(&search_constant_type_c::real_type_name);
   374 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::real_type_name);
   369 	symbol->candidate_datatypes.push_back(&search_constant_type_c::lreal_type_name);
   375 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::lreal_type_name);
   370 	if (debug) std::cout << "neg ANY_REAL [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   376 	if (debug) std::cout << "neg ANY_REAL [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   371 	return NULL;
   377 	return NULL;
   372 }
   378 }
   373 
   379 
   374 void *fill_candidate_datatypes_c::visit(neg_integer_c *symbol) {
   380 void *fill_candidate_datatypes_c::visit(neg_integer_c *symbol) {
   375 	int calc_size;
   381 	int calc_size;
   376 
   382 
   377 	calc_size = sizeoftype(symbol);
   383 	calc_size = sizeoftype(symbol);
   378 	if (calc_size <= sizeoftype(&search_constant_type_c::int_type_name))
   384 	if (calc_size <= sizeoftype(&search_constant_type_c::int_type_name))
   379 		symbol->candidate_datatypes.push_back(&search_constant_type_c::int_type_name);
   385 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name);
   380 	if (calc_size <= sizeoftype(&search_constant_type_c::sint_type_name))
   386 	if (calc_size <= sizeoftype(&search_constant_type_c::sint_type_name))
   381 		symbol->candidate_datatypes.push_back(&search_constant_type_c::sint_type_name);
   387 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name);
   382 	if (calc_size <= sizeoftype(&search_constant_type_c::dint_type_name))
   388 	if (calc_size <= sizeoftype(&search_constant_type_c::dint_type_name))
   383 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dint_type_name);
   389 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name);
   384 	if (calc_size <= sizeoftype(&search_constant_type_c::lint_type_name))
   390 	if (calc_size <= sizeoftype(&search_constant_type_c::lint_type_name))
   385 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lint_type_name);
   391 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name);
   386 	if (debug) std::cout << "neg ANY_INT [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   392 	if (debug) std::cout << "neg ANY_INT [" << symbol->candidate_datatypes.size() << "]" << std::endl;
   387 	return NULL;
   393 	return NULL;
   388 }
   394 }
   389 
   395 
   390 void *fill_candidate_datatypes_c::visit(binary_integer_c *symbol) {
   396 void *fill_candidate_datatypes_c::visit(binary_integer_c *symbol) {
   391 	int calc_size;
   397 	int calc_size;
   392 
   398 
   393 	calc_size = sizeoftype(symbol);
   399 	calc_size = sizeoftype(symbol);
   394 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   400 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   395 	        symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   401 	        add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   396 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   402 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   397 		symbol->candidate_datatypes.push_back(&search_constant_type_c::byte_type_name);
   403 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name);
   398 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   404 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   399 		symbol->candidate_datatypes.push_back(&search_constant_type_c::word_type_name);
   405 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name);
   400 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   406 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   401 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dword_type_name);
   407 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name);
   402 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   408 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   403 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lword_type_name);
   409 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name);
   404 	
   410 	
   405 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   411 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   406 		symbol->candidate_datatypes.push_back(&search_constant_type_c::sint_type_name);
   412 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name);
   407 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   413 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   408 		symbol->candidate_datatypes.push_back(&search_constant_type_c::int_type_name);
   414 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name);
   409 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   415 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   410 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dint_type_name);
   416 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name);
   411 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   417 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   412 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lint_type_name);
   418 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name);
   413 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   419 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   414 		symbol->candidate_datatypes.push_back(&search_constant_type_c::usint_type_name);
   420 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::usint_type_name);
   415 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   421 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   416 		symbol->candidate_datatypes.push_back(&search_constant_type_c::uint_type_name);
   422 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::uint_type_name);
   417 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   423 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   418 		symbol->candidate_datatypes.push_back(&search_constant_type_c::udint_type_name);
   424 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::udint_type_name);
   419 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   425 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   420 		symbol->candidate_datatypes.push_back(&search_constant_type_c::ulint_type_name);
   426 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name);
   421 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   427 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   422 	return NULL;
   428 	return NULL;
   423 }
   429 }
   424 
   430 
   425 void *fill_candidate_datatypes_c::visit(octal_integer_c *symbol) {
   431 void *fill_candidate_datatypes_c::visit(octal_integer_c *symbol) {
   426 	int calc_size;
   432 	int calc_size;
   427 
   433 
   428 	calc_size = sizeoftype(symbol);
   434 	calc_size = sizeoftype(symbol);
   429 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   435 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   430 	        symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   436 	        add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   431 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   437 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   432 		symbol->candidate_datatypes.push_back(&search_constant_type_c::byte_type_name);
   438 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name);
   433 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   439 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   434 		symbol->candidate_datatypes.push_back(&search_constant_type_c::word_type_name);
   440 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name);
   435 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   441 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   436 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dword_type_name);
   442 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name);
   437 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   443 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   438 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lword_type_name);
   444 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name);
   439 
   445 
   440 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   446 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   441 		symbol->candidate_datatypes.push_back(&search_constant_type_c::sint_type_name);
   447 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name);
   442 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   448 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   443 		symbol->candidate_datatypes.push_back(&search_constant_type_c::int_type_name);
   449 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name);
   444 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   450 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   445 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dint_type_name);
   451 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name);
   446 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   452 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   447 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lint_type_name);
   453 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name);
   448 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   454 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   449 		symbol->candidate_datatypes.push_back(&search_constant_type_c::usint_type_name);
   455 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::usint_type_name);
   450 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   456 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   451 		symbol->candidate_datatypes.push_back(&search_constant_type_c::uint_type_name);
   457 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::uint_type_name);
   452 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   458 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   453 		symbol->candidate_datatypes.push_back(&search_constant_type_c::udint_type_name);
   459 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::udint_type_name);
   454 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   460 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   455 		symbol->candidate_datatypes.push_back(&search_constant_type_c::ulint_type_name);
   461 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name);
   456 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   462 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   457 	return NULL;
   463 	return NULL;
   458 }
   464 }
   459 
   465 
   460 void *fill_candidate_datatypes_c::visit(hex_integer_c *symbol) {
   466 void *fill_candidate_datatypes_c::visit(hex_integer_c *symbol) {
   461 	int calc_size;
   467 	int calc_size;
   462 
   468 
   463 	calc_size = sizeoftype(symbol);
   469 	calc_size = sizeoftype(symbol);
   464 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   470 	if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name))
   465 	        symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   471 	        add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   466 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   472 	if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name))
   467 		symbol->candidate_datatypes.push_back(&search_constant_type_c::byte_type_name);
   473 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name);
   468 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   474 	if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name))
   469 		symbol->candidate_datatypes.push_back(&search_constant_type_c::word_type_name);
   475 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name);
   470 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   476 	if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name))
   471 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dword_type_name);
   477 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name);
   472 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   478 	if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name))
   473 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lword_type_name);
   479 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name);
   474 
   480 
   475 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   481 	if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name))
   476 		symbol->candidate_datatypes.push_back(&search_constant_type_c::sint_type_name);
   482 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name);
   477 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   483 	if (calc_size < sizeoftype(&search_constant_type_c::int_type_name))
   478 		symbol->candidate_datatypes.push_back(&search_constant_type_c::int_type_name);
   484 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name);
   479 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   485 	if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name))
   480 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dint_type_name);
   486 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name);
   481 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   487 	if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name))
   482 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lint_type_name);
   488 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name);
   483 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   489 	if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name))
   484 		symbol->candidate_datatypes.push_back(&search_constant_type_c::usint_type_name);
   490 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::usint_type_name);
   485 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   491 	if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name))
   486 		symbol->candidate_datatypes.push_back(&search_constant_type_c::uint_type_name);
   492 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::uint_type_name);
   487 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   493 	if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name))
   488 		symbol->candidate_datatypes.push_back(&search_constant_type_c::udint_type_name);
   494 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::udint_type_name);
   489 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   495 	if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name))
   490 		symbol->candidate_datatypes.push_back(&search_constant_type_c::ulint_type_name);
   496 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name);
   491 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   497 	if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl;
   492 	return NULL;
   498 	return NULL;
   493 }
   499 }
   494 
   500 
   495 // SYM_REF2(integer_literal_c, type, value)
   501 // SYM_REF2(integer_literal_c, type, value)
   496 void *fill_candidate_datatypes_c::visit(integer_literal_c *symbol) {
   502 void *fill_candidate_datatypes_c::visit(integer_literal_c *symbol) {
   497 	symbol->value->accept(*this);
   503 	symbol->value->accept(*this);
   498 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   504 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   499 		symbol->candidate_datatypes.push_back(symbol->type);
   505 		add_datatype_to_candidate_list(symbol, symbol->type);
   500 	if (debug) std::cout << "INT_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   506 	if (debug) std::cout << "INT_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   501 	return NULL;
   507 	return NULL;
   502 }
   508 }
   503 
   509 
   504 void *fill_candidate_datatypes_c::visit(real_literal_c *symbol) {
   510 void *fill_candidate_datatypes_c::visit(real_literal_c *symbol) {
   505 	symbol->value->accept(*this);
   511 	symbol->value->accept(*this);
   506 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   512 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   507 		symbol->candidate_datatypes.push_back(symbol->type);
   513 		add_datatype_to_candidate_list(symbol, symbol->type);
   508 	if (debug) std::cout << "REAL_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   514 	if (debug) std::cout << "REAL_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   509 	return NULL;
   515 	return NULL;
   510 }
   516 }
   511 
   517 
   512 void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {
   518 void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {
   513 	symbol->value->accept(*this);
   519 	symbol->value->accept(*this);
   514 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   520 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   515 		symbol->candidate_datatypes.push_back(symbol->type);
   521 		add_datatype_to_candidate_list(symbol, symbol->type);
   516 	return NULL;
   522 	return NULL;
   517 }
   523 }
   518 
   524 
   519 void *fill_candidate_datatypes_c::visit(boolean_literal_c *symbol) {
   525 void *fill_candidate_datatypes_c::visit(boolean_literal_c *symbol) {
   520  	symbol->value->accept(*this);
   526  	symbol->value->accept(*this);
   521  	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   527  	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   522 		/* if an explicit datat type has been provided (e.g. SAFEBOOL#true), check whether
   528 		/* if an explicit datat type has been provided (e.g. SAFEBOOL#true), check whether
   523 		 * the possible datatypes of the value is consistent with the desired type.
   529 		 * the possible datatypes of the value is consistent with the desired type.
   524 		 */
   530 		 */
   525 		symbol->candidate_datatypes.push_back(symbol->type);
   531 		add_datatype_to_candidate_list(symbol, symbol->type);
   526 	else {
   532 	else {
   527 		/* Then only a literal TRUE or FALSE was given! */
   533 		/* Then only a literal TRUE or FALSE was given! */
   528 		/* In this case, symbol->type will be NULL!     */
   534 		/* In this case, symbol->type will be NULL!     */
   529 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   535 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   530 		symbol->candidate_datatypes.push_back(&search_constant_type_c::safebool_type_name);
   536 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::safebool_type_name);
   531 	}
   537 	}
   532 	return NULL;
   538 	return NULL;
   533 }
   539 }
   534 
   540 
   535 void *fill_candidate_datatypes_c::visit(boolean_true_c *symbol) {
   541 void *fill_candidate_datatypes_c::visit(boolean_true_c *symbol) {
   536 	symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   542 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   537 	symbol->candidate_datatypes.push_back(&search_constant_type_c::safebool_type_name);
   543 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::safebool_type_name);
   538 	return NULL;
   544 	return NULL;
   539 }
   545 }
   540 
   546 
   541 void *fill_candidate_datatypes_c::visit(boolean_false_c *symbol) {
   547 void *fill_candidate_datatypes_c::visit(boolean_false_c *symbol) {
   542 	symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   548 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   543 	symbol->candidate_datatypes.push_back(&search_constant_type_c::safebool_type_name);
   549 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::safebool_type_name);
   544 	return NULL;
   550 	return NULL;
   545 }
   551 }
   546 
   552 
   547 /*******************************/
   553 /*******************************/
   548 /* B.1.2.2   Character Strings */
   554 /* B.1.2.2   Character Strings */
   549 /*******************************/
   555 /*******************************/
   550 void *fill_candidate_datatypes_c::visit(double_byte_character_string_c *symbol) {
   556 void *fill_candidate_datatypes_c::visit(double_byte_character_string_c *symbol) {
   551 	symbol->candidate_datatypes.push_back(&search_constant_type_c::wstring_type_name);
   557 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::wstring_type_name);
   552 	return NULL;
   558 	return NULL;
   553 }
   559 }
   554 
   560 
   555 void *fill_candidate_datatypes_c::visit(single_byte_character_string_c *symbol) {
   561 void *fill_candidate_datatypes_c::visit(single_byte_character_string_c *symbol) {
   556 	symbol->candidate_datatypes.push_back(&search_constant_type_c::string_type_name);
   562 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::string_type_name);
   557 	return NULL;
   563 	return NULL;
   558 }
   564 }
   559 
   565 
   560 /***************************/
   566 /***************************/
   561 /* B 1.2.3 - Time Literals */
   567 /* B 1.2.3 - Time Literals */
   565 /************************/
   571 /************************/
   566 void *fill_candidate_datatypes_c::visit(duration_c *symbol) {
   572 void *fill_candidate_datatypes_c::visit(duration_c *symbol) {
   567 	/* TODO: check whether the literal follows the rules specified in section '2.2.3.1 Duration' of the standard! */
   573 	/* TODO: check whether the literal follows the rules specified in section '2.2.3.1 Duration' of the standard! */
   568 	
   574 	
   569 	/* Either of the following two lines is correct. Each of them will have advantages and drawbacks during compiler debugging. Use whichever suits you best... */
   575 	/* Either of the following two lines is correct. Each of them will have advantages and drawbacks during compiler debugging. Use whichever suits you best... */
   570 	symbol->candidate_datatypes.push_back(&search_constant_type_c::time_type_name);
   576 	add_datatype_to_candidate_list(symbol, &search_constant_type_c::time_type_name);
   571 // 	symbol->candidate_datatypes.push_back(symbol->type_name);
   577 // 	symbol->candidate_datatypes.push_back(symbol->type_name);
   572 	if (debug) std::cout << "TIME_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   578 	if (debug) std::cout << "TIME_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   573 	return NULL;
   579 	return NULL;
   574 }
   580 }
   575 
   581 
   576 /************************************/
   582 /************************************/
   577 /* B 1.2.3.2 - Time of day and Date */
   583 /* B 1.2.3.2 - Time of day and Date */
   578 /************************************/
   584 /************************************/
   579 void *fill_candidate_datatypes_c::visit(time_of_day_c *symbol) {
   585 void *fill_candidate_datatypes_c::visit(time_of_day_c *symbol) {
   580 	symbol->candidate_datatypes.push_back(symbol->type_name);
   586 	add_datatype_to_candidate_list(symbol, symbol->type_name);
   581 	return NULL;
   587 	return NULL;
   582 }
   588 }
   583 
   589 
   584 void *fill_candidate_datatypes_c::visit(date_c *symbol) {
   590 void *fill_candidate_datatypes_c::visit(date_c *symbol) {
   585 	symbol->candidate_datatypes.push_back(symbol->type_name);
   591 	add_datatype_to_candidate_list(symbol, symbol->type_name);
   586 	return NULL;
   592 	return NULL;
   587 }
   593 }
   588 
   594 
   589 void *fill_candidate_datatypes_c::visit(date_and_time_c *symbol) {
   595 void *fill_candidate_datatypes_c::visit(date_and_time_c *symbol) {
   590 	symbol->candidate_datatypes.push_back(symbol->type_name);
   596 	add_datatype_to_candidate_list(symbol, symbol->type_name);
   591 	return NULL;
   597 	return NULL;
   592 }
   598 }
   593 
   599 
   594 /**********************/
   600 /**********************/
   595 /* B 1.3 - Data types */
   601 /* B 1.3 - Data types */
   604 	symbol->upper_limit->accept(*this);
   610 	symbol->upper_limit->accept(*this);
   605 	
   611 	
   606 	for (unsigned int u = 0; u < symbol->upper_limit->candidate_datatypes.size(); u++) {
   612 	for (unsigned int u = 0; u < symbol->upper_limit->candidate_datatypes.size(); u++) {
   607 		for(unsigned int l = 0; l < symbol->lower_limit->candidate_datatypes.size(); l++) {
   613 		for(unsigned int l = 0; l < symbol->lower_limit->candidate_datatypes.size(); l++) {
   608 			if (is_type_equal(symbol->upper_limit->candidate_datatypes[u], symbol->lower_limit->candidate_datatypes[l]))
   614 			if (is_type_equal(symbol->upper_limit->candidate_datatypes[u], symbol->lower_limit->candidate_datatypes[l]))
   609 				symbol->candidate_datatypes.push_back(symbol->lower_limit->candidate_datatypes[l]);
   615 				add_datatype_to_candidate_list(symbol, symbol->lower_limit->candidate_datatypes[l]);
   610 		}
   616 		}
   611 	}
   617 	}
   612 	return NULL;
   618 	return NULL;
   613 }
   619 }
   614 
   620 
   632 		if (enumerated_type == enumerated_value_symtable.end_value())
   638 		if (enumerated_type == enumerated_value_symtable.end_value())
   633 			enumerated_type = NULL;
   639 			enumerated_type = NULL;
   634 	}
   640 	}
   635 	enumerated_type = base_type(enumerated_type);
   641 	enumerated_type = base_type(enumerated_type);
   636 	if (NULL != enumerated_type)
   642 	if (NULL != enumerated_type)
   637 		symbol->candidate_datatypes.push_back(enumerated_type);
   643 		add_datatype_to_candidate_list(symbol, enumerated_type);
   638 
   644 
   639 	if (debug) std::cout << "ENUMERATE [" << symbol->candidate_datatypes.size() << "]\n";
   645 	if (debug) std::cout << "ENUMERATE [" << symbol->candidate_datatypes.size() << "]\n";
   640 	return NULL;
   646 	return NULL;
   641 }
   647 }
   642 
   648 
   645 /* B 1.4 - Variables */
   651 /* B 1.4 - Variables */
   646 /*********************/
   652 /*********************/
   647 void *fill_candidate_datatypes_c::visit(symbolic_variable_c *symbol) {
   653 void *fill_candidate_datatypes_c::visit(symbolic_variable_c *symbol) {
   648 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   654 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   649 	if (NULL != result)
   655 	if (NULL != result)
   650 		symbol->candidate_datatypes.push_back(result);
   656 		add_datatype_to_candidate_list(symbol, result);
   651 	if (debug) std::cout << "VAR [" << symbol->candidate_datatypes.size() << "]\n";
   657 	if (debug) std::cout << "VAR [" << symbol->candidate_datatypes.size() << "]\n";
   652 	return NULL;
   658 	return NULL;
   653 }
   659 }
   654 
   660 
   655 /********************************************/
   661 /********************************************/
   664 	 * if (symbol->value[0] == '\0') ERROR;
   670 	 * if (symbol->value[0] == '\0') ERROR;
   665 	 * if (symbol->value[1] == '\0') ERROR;
   671 	 * if (symbol->value[1] == '\0') ERROR;
   666 	 */
   672 	 */
   667 	switch (symbol->value[2]) {
   673 	switch (symbol->value[2]) {
   668 	case 'X': // bit - 1 bit
   674 	case 'X': // bit - 1 bit
   669 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   675 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   670 		break;
   676 		break;
   671 
   677 
   672 	case 'B': // byte - 8 bits
   678 	case 'B': // byte - 8 bits
   673 		symbol->candidate_datatypes.push_back(&search_constant_type_c::byte_type_name);
   679 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name);
   674 		break;
   680 		break;
   675 
   681 
   676 	case 'W': // word - 16 bits
   682 	case 'W': // word - 16 bits
   677 		symbol->candidate_datatypes.push_back(&search_constant_type_c::word_type_name);
   683 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name);
   678 		break;
   684 		break;
   679 
   685 
   680 	case 'D': // double word - 32 bits
   686 	case 'D': // double word - 32 bits
   681 		symbol->candidate_datatypes.push_back(&search_constant_type_c::dword_type_name);
   687 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name);
   682 		break;
   688 		break;
   683 
   689 
   684 	case 'L': // long word - 64 bits
   690 	case 'L': // long word - 64 bits
   685 		symbol->candidate_datatypes.push_back(&search_constant_type_c::lword_type_name);
   691 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name);
   686 		break;
   692 		break;
   687 
   693 
   688 	default:  // if none of the above, then the empty string was used <=> boolean
   694 	default:  // if none of the above, then the empty string was used <=> boolean
   689 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
   695 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
   690 		break;
   696 		break;
   691 	}
   697 	}
   692 	return NULL;
   698 	return NULL;
   693 }
   699 }
   694 
   700 
   701 	/* get the declaration of the data type __stored__ in the array... */
   707 	/* get the declaration of the data type __stored__ in the array... */
   702 	/* if we were to want the data type of the array itself, then we should call_param_name
   708 	/* if we were to want the data type of the array itself, then we should call_param_name
   703 	 * search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable)
   709 	 * search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable)
   704 	 */
   710 	 */
   705 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   711 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   706 	if (NULL != result) symbol->candidate_datatypes.push_back(result);
   712 	if (NULL != result) add_datatype_to_candidate_list(symbol, result);
   707 	
   713 	
   708 	/* recursively call the subscript list, so we can check the data types of the expressions used for the subscripts */
   714 	/* recursively call the subscript list, so we can check the data types of the expressions used for the subscripts */
   709 	symbol->subscript_list->accept(*this);
   715 	symbol->subscript_list->accept(*this);
   710 
   716 
   711 	if (debug) std::cout << "ARRAY_VAR [" << symbol->candidate_datatypes.size() << "]\n";	
   717 	if (debug) std::cout << "ARRAY_VAR [" << symbol->candidate_datatypes.size() << "]\n";	
   729 /* NOTE: We do not need to recursively determine the data types of each field_selector, as the search_varfb_instance_type
   735 /* NOTE: We do not need to recursively determine the data types of each field_selector, as the search_varfb_instance_type
   730  * will do that for us. So we determine the candidate datatypes only for the full structured_variable.
   736  * will do that for us. So we determine the candidate datatypes only for the full structured_variable.
   731  */
   737  */
   732 void *fill_candidate_datatypes_c::visit(structured_variable_c *symbol) {
   738 void *fill_candidate_datatypes_c::visit(structured_variable_c *symbol) {
   733 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   739 	symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol);
   734 	if (NULL != result) symbol->candidate_datatypes.push_back(result);
   740 	if (NULL != result) add_datatype_to_candidate_list(symbol, result);
   735 	return NULL;
   741 	return NULL;
   736 }
   742 }
   737 
   743 
   738 /************************************/
   744 /************************************/
   739 /* B 1.5 Program organization units */
   745 /* B 1.5 Program organization units */
   743 /*********************/
   749 /*********************/
   744 void *fill_candidate_datatypes_c::visit(function_declaration_c *symbol) {
   750 void *fill_candidate_datatypes_c::visit(function_declaration_c *symbol) {
   745 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   751 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   746 	symbol->var_declarations_list->accept(*this);
   752 	symbol->var_declarations_list->accept(*this);
   747 	if (debug) printf("Filling candidate data types list in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
   753 	if (debug) printf("Filling candidate data types list in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
   748 	il_parenthesis_level = 0;
   754 // 	il_parenthesis_level = 0;
   749 	symbol->function_body->accept(*this);
   755 	symbol->function_body->accept(*this);
   750 	delete search_varfb_instance_type;
   756 	delete search_varfb_instance_type;
   751 	search_varfb_instance_type = NULL;
   757 	search_varfb_instance_type = NULL;
   752 	return NULL;
   758 	return NULL;
   753 }
   759 }
   757 /***************************/
   763 /***************************/
   758 void *fill_candidate_datatypes_c::visit(function_block_declaration_c *symbol) {
   764 void *fill_candidate_datatypes_c::visit(function_block_declaration_c *symbol) {
   759 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   765 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   760 	symbol->var_declarations->accept(*this);
   766 	symbol->var_declarations->accept(*this);
   761 	if (debug) printf("Filling candidate data types list in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
   767 	if (debug) printf("Filling candidate data types list in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
   762 	il_parenthesis_level = 0;
   768 // 	il_parenthesis_level = 0;
   763 	symbol->fblock_body->accept(*this);
   769 	symbol->fblock_body->accept(*this);
   764 	delete search_varfb_instance_type;
   770 	delete search_varfb_instance_type;
   765 	search_varfb_instance_type = NULL;
   771 	search_varfb_instance_type = NULL;
   766 	return NULL;
   772 	return NULL;
   767 }
   773 }
   771 /**********************/
   777 /**********************/
   772 void *fill_candidate_datatypes_c::visit(program_declaration_c *symbol) {
   778 void *fill_candidate_datatypes_c::visit(program_declaration_c *symbol) {
   773 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   779 	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
   774 	symbol->var_declarations->accept(*this);
   780 	symbol->var_declarations->accept(*this);
   775 	if (debug) printf("Filling candidate data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
   781 	if (debug) printf("Filling candidate data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
   776 	il_parenthesis_level = 0;
   782 // 	il_parenthesis_level = 0;
   777 	symbol->function_block_body->accept(*this);
   783 	symbol->function_block_body->accept(*this);
   778 	delete search_varfb_instance_type;
   784 	delete search_varfb_instance_type;
   779 	search_varfb_instance_type = NULL;
   785 	search_varfb_instance_type = NULL;
   780 	return NULL;
   786 	return NULL;
   781 }
   787 }
   799 /***********************************/
   805 /***********************************/
   800 
   806 
   801 /*| instruction_list il_instruction */
   807 /*| instruction_list il_instruction */
   802 // SYM_LIST(instruction_list_c)
   808 // SYM_LIST(instruction_list_c)
   803 void *fill_candidate_datatypes_c::visit(instruction_list_c *symbol) {
   809 void *fill_candidate_datatypes_c::visit(instruction_list_c *symbol) {
   804 	/* In order to execute the narrow algoritm ll the data type candidates correctly
   810 	/* In order to fill the data type candidates correctly
   805 	 * Ä©n IL instruction lists containing JMPs to labels that come before the JMP instruction
   811 	 * in IL instruction lists containing JMPs to labels that come before the JMP instruction
   806 	 * itself, we need to run the fill candidate datatypes algorithm twice on the Instruction List.
   812 	 * itself, we need to run the fill candidate datatypes algorithm twice on the Instruction List.
   807 	 * e.g.:  ...
   813 	 * e.g.:  ...
   808 	 *          ld 23
   814 	 *          ld 23
   809 	 *   label1:st byte_var
   815 	 *   label1:st byte_var
   810 	 *          ld 34
   816 	 *          ld 34
   914 
   920 
   915 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
   921 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
   916 // SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list);
   922 // SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list);
   917 void *fill_candidate_datatypes_c::visit(il_expression_c *symbol) {
   923 void *fill_candidate_datatypes_c::visit(il_expression_c *symbol) {
   918   symbol_c *prev_il_instruction_backup = prev_il_instruction;
   924   symbol_c *prev_il_instruction_backup = prev_il_instruction;
   919   il_parenthesis_level++;
   925 //   il_parenthesis_level++;
   920   
   926   
   921   if (NULL != symbol->il_operand)
   927   if (NULL != symbol->il_operand)
   922     symbol->il_operand->accept(*this);
   928     symbol->il_operand->accept(*this);
   923 
   929 
   924   if(symbol->simple_instr_list != NULL)
   930   if(symbol->simple_instr_list != NULL)
   925     symbol->simple_instr_list->accept(*this);
   931     symbol->simple_instr_list->accept(*this);
   926 
   932 
   927   il_parenthesis_level--;
   933 //   il_parenthesis_level--;
   928   if (il_parenthesis_level < 0) ERROR;
   934 //   if (il_parenthesis_level < 0) ERROR;
   929   
   935   
   930   /* Now check the if the data type semantics of operation are correct,  */
   936   /* Now check the if the data type semantics of operation are correct,  */
   931   il_operand = symbol->simple_instr_list;
   937   il_operand = symbol->simple_instr_list;
   932   prev_il_instruction = prev_il_instruction_backup;
   938   prev_il_instruction = prev_il_instruction_backup;
   933   symbol->il_expr_operator->accept(*this);
   939   symbol->il_expr_operator->accept(*this);
  1066 /*******************/
  1072 /*******************/
  1067 /* B 2.2 Operators */
  1073 /* B 2.2 Operators */
  1068 /*******************/
  1074 /*******************/
  1069 void *fill_candidate_datatypes_c::visit(LD_operator_c *symbol) {
  1075 void *fill_candidate_datatypes_c::visit(LD_operator_c *symbol) {
  1070 	for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) {
  1076 	for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) {
  1071 		symbol->candidate_datatypes.push_back(il_operand->candidate_datatypes[i]);
  1077 		add_datatype_to_candidate_list(symbol, il_operand->candidate_datatypes[i]);
  1072 	}
  1078 	}
  1073 	if (debug) std::cout << "LD [" <<  il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1079 	if (debug) std::cout << "LD [" <<  il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1074 	return NULL;
  1080 	return NULL;
  1075 }
  1081 }
  1076 
  1082 
  1077 void *fill_candidate_datatypes_c::visit(LDN_operator_c *symbol) {
  1083 void *fill_candidate_datatypes_c::visit(LDN_operator_c *symbol) {
  1078 	for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) {
  1084 	for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) {
  1079 		if      (is_ANY_BIT_compatible(il_operand->candidate_datatypes[i]))
  1085 		if      (is_ANY_BIT_compatible(il_operand->candidate_datatypes[i]))
  1080 			symbol->candidate_datatypes.push_back(il_operand->candidate_datatypes[i]);
  1086 			add_datatype_to_candidate_list(symbol, il_operand->candidate_datatypes[i]);
  1081 	}
  1087 	}
  1082 	if (debug) std::cout << "LDN [" << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1088 	if (debug) std::cout << "LDN [" << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1083 	return NULL;
  1089 	return NULL;
  1084 }
  1090 }
  1085 
  1091 
  1090 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1096 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1091 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1097 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1092 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1098 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1093 			operand_type = il_operand->candidate_datatypes[j];
  1099 			operand_type = il_operand->candidate_datatypes[j];
  1094 			if (is_type_equal(prev_instruction_type, operand_type))
  1100 			if (is_type_equal(prev_instruction_type, operand_type))
  1095 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1101 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1096 		}
  1102 		}
  1097 	}
  1103 	}
  1098 	if (debug) std::cout << "ST [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1104 	if (debug) std::cout << "ST [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1099 	return NULL;
  1105 	return NULL;
  1100 }
  1106 }
  1106 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1112 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1107 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1113 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1108 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1114 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1109 			operand_type = il_operand->candidate_datatypes[j];
  1115 			operand_type = il_operand->candidate_datatypes[j];
  1110 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BIT_compatible(operand_type))
  1116 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BIT_compatible(operand_type))
  1111 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1117 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1112 		}
  1118 		}
  1113 	}
  1119 	}
  1114 	if (debug) std::cout << "STN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1120 	if (debug) std::cout << "STN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1115 	return NULL;
  1121 	return NULL;
  1116 }
  1122 }
  1128 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1134 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1129 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1135 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1130 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1136 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1131 			operand_type = il_operand->candidate_datatypes[j];
  1137 			operand_type = il_operand->candidate_datatypes[j];
  1132 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
  1138 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
  1133 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1139 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1134 		}
  1140 		}
  1135 	}
  1141 	}
  1136 	if (debug) std::cout << "S [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1142 	if (debug) std::cout << "S [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1137 	return NULL;
  1143 	return NULL;
  1138 }
  1144 }
  1146 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1152 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1147 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1153 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1148 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1154 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1149 			operand_type = il_operand->candidate_datatypes[j];
  1155 			operand_type = il_operand->candidate_datatypes[j];
  1150 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
  1156 			if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type))
  1151 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1157 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1152 		}
  1158 		}
  1153 	}
  1159 	}
  1154 	if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1160 	if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1155 	return NULL;
  1161 	return NULL;
  1156 }
  1162 }
  1205 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1211 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1206 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1212 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1207 			operand_type = il_operand->candidate_datatypes[j];
  1213 			operand_type = il_operand->candidate_datatypes[j];
  1208 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1214 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1209 					is_ANY_BIT_compatible(operand_type))
  1215 					is_ANY_BIT_compatible(operand_type))
  1210 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1216 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1211 		}
  1217 		}
  1212 	}
  1218 	}
  1213 	if (debug) std::cout <<  "AND [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1219 	if (debug) std::cout <<  "AND [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1214 	return NULL;
  1220 	return NULL;
  1215 }
  1221 }
  1222 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1228 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1223 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1229 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1224 			operand_type = il_operand->candidate_datatypes[j];
  1230 			operand_type = il_operand->candidate_datatypes[j];
  1225 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1231 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1226 					is_ANY_BIT_compatible(operand_type))
  1232 					is_ANY_BIT_compatible(operand_type))
  1227 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1233 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1228 		}
  1234 		}
  1229 	}
  1235 	}
  1230 	if (debug) std::cout <<  "OR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1236 	if (debug) std::cout <<  "OR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1231 	return NULL;
  1237 	return NULL;
  1232 }
  1238 }
  1239 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1245 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1240 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1246 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1241 			operand_type = il_operand->candidate_datatypes[j];
  1247 			operand_type = il_operand->candidate_datatypes[j];
  1242 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1248 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1243 					is_ANY_BIT_compatible(operand_type))
  1249 					is_ANY_BIT_compatible(operand_type))
  1244 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1250 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1245 		}
  1251 		}
  1246 	}
  1252 	}
  1247 	if (debug) std::cout <<  "XOR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1253 	if (debug) std::cout <<  "XOR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1248 	return NULL;
  1254 	return NULL;
  1249 }
  1255 }
  1256 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1262 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1257 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1263 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1258 			operand_type = il_operand->candidate_datatypes[j];
  1264 			operand_type = il_operand->candidate_datatypes[j];
  1259 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1265 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1260 					is_ANY_BIT_compatible(operand_type))
  1266 					is_ANY_BIT_compatible(operand_type))
  1261 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1267 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1262 		}
  1268 		}
  1263 	}
  1269 	}
  1264 	if (debug) std::cout <<  "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1270 	if (debug) std::cout <<  "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1265 	return NULL;
  1271 	return NULL;
  1266 }
  1272 }
  1273 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1279 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1274 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1280 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1275 			operand_type = il_operand->candidate_datatypes[j];
  1281 			operand_type = il_operand->candidate_datatypes[j];
  1276 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1282 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1277 					is_ANY_BIT_compatible(operand_type))
  1283 					is_ANY_BIT_compatible(operand_type))
  1278 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1284 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1279 		}
  1285 		}
  1280 	}
  1286 	}
  1281 	if (debug) std::cout <<  "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1287 	if (debug) std::cout <<  "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1282 	return NULL;
  1288 	return NULL;
  1283 }
  1289 }
  1290 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1296 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1291 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1297 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1292 			operand_type = il_operand->candidate_datatypes[j];
  1298 			operand_type = il_operand->candidate_datatypes[j];
  1293 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1299 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1294 					is_ANY_BIT_compatible(operand_type))
  1300 					is_ANY_BIT_compatible(operand_type))
  1295 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1301 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1296 		}
  1302 		}
  1297 	}
  1303 	}
  1298 	if (debug) std::cout <<  "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1304 	if (debug) std::cout <<  "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1299 	return NULL;
  1305 	return NULL;
  1300 }
  1306 }
  1307 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1313 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1308 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1314 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1309 			operand_type = il_operand->candidate_datatypes[j];
  1315 			operand_type = il_operand->candidate_datatypes[j];
  1310 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1316 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1311 					is_ANY_NUM_compatible(prev_instruction_type))
  1317 					is_ANY_NUM_compatible(prev_instruction_type))
  1312 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1318 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1313 			else {
  1319 			else {
  1314 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_ADD_table);
  1320 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_ADD_table);
  1315 				if (result)
  1321 				if (result)
  1316 					symbol->candidate_datatypes.push_back(result);
  1322 					add_datatype_to_candidate_list(symbol, result);
  1317 
  1323 
  1318 			}
  1324 			}
  1319 		}
  1325 		}
  1320 	}
  1326 	}
  1321 	if (debug) std::cout <<  "ADD [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1327 	if (debug) std::cout <<  "ADD [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1330 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1336 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1331 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1337 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1332 			operand_type = il_operand->candidate_datatypes[j];
  1338 			operand_type = il_operand->candidate_datatypes[j];
  1333 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1339 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1334 					is_ANY_NUM_compatible(prev_instruction_type))
  1340 					is_ANY_NUM_compatible(prev_instruction_type))
  1335 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1341 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1336 			else {
  1342 			else {
  1337 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_SUB_table);
  1343 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_SUB_table);
  1338 				if (result)
  1344 				if (result)
  1339 					symbol->candidate_datatypes.push_back(result);
  1345 					add_datatype_to_candidate_list(symbol, result);
  1340 			}
  1346 			}
  1341 		}
  1347 		}
  1342 	}
  1348 	}
  1343 	if (debug) std::cout <<  "SUB [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1349 	if (debug) std::cout <<  "SUB [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1344 	return NULL;
  1350 	return NULL;
  1352 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1358 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1353 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1359 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1354 			operand_type = il_operand->candidate_datatypes[j];
  1360 			operand_type = il_operand->candidate_datatypes[j];
  1355 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1361 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1356 					is_ANY_NUM_compatible(prev_instruction_type))
  1362 					is_ANY_NUM_compatible(prev_instruction_type))
  1357 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1363 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1358 			else {
  1364 			else {
  1359 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_MUL_table);
  1365 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_MUL_table);
  1360 				if (result)
  1366 				if (result)
  1361 					symbol->candidate_datatypes.push_back(result);
  1367 					add_datatype_to_candidate_list(symbol, result);
  1362 			}
  1368 			}
  1363 		}
  1369 		}
  1364 	}
  1370 	}
  1365 	if (debug) std::cout <<  "MUL [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1371 	if (debug) std::cout <<  "MUL [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1366 	return NULL;
  1372 	return NULL;
  1374 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1380 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1375 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1381 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1376 			operand_type = il_operand->candidate_datatypes[j];
  1382 			operand_type = il_operand->candidate_datatypes[j];
  1377 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1383 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1378 					is_ANY_NUM_compatible(prev_instruction_type))
  1384 					is_ANY_NUM_compatible(prev_instruction_type))
  1379 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1385 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1380 			else {
  1386 			else {
  1381 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_DIV_table);
  1387 				symbol_c *result = widening_conversion(prev_instruction_type, operand_type, widen_DIV_table);
  1382 				if (result)
  1388 				if (result)
  1383 					symbol->candidate_datatypes.push_back(result);
  1389 					add_datatype_to_candidate_list(symbol, result);
  1384 			}
  1390 			}
  1385 		}
  1391 		}
  1386 	}
  1392 	}
  1387 	if (debug) std::cout <<  "DIV [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1393 	if (debug) std::cout <<  "DIV [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1388 	return NULL;
  1394 	return NULL;
  1396 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1402 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1397 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1403 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
  1398 			operand_type = il_operand->candidate_datatypes[j];
  1404 			operand_type = il_operand->candidate_datatypes[j];
  1399 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1405 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1400 					is_ANY_INT_compatible(prev_instruction_type))
  1406 					is_ANY_INT_compatible(prev_instruction_type))
  1401 				symbol->candidate_datatypes.push_back(prev_instruction_type);
  1407 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1402 		}
  1408 		}
  1403 	}
  1409 	}
  1404 	if (debug) std::cout <<  "MOD [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1410 	if (debug) std::cout <<  "MOD [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1405 	return NULL;
  1411 	return NULL;
  1406 }
  1412 }
  1416 				found = true;
  1422 				found = true;
  1417 				break;
  1423 				break;
  1418 			}
  1424 			}
  1419 		}
  1425 		}
  1420 	}
  1426 	}
  1421 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1427 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1422 	return NULL;
  1428 	return NULL;
  1423 }
  1429 }
  1424 
  1430 
  1425 void *fill_candidate_datatypes_c::visit(GE_operator_c *symbol) {
  1431 void *fill_candidate_datatypes_c::visit(GE_operator_c *symbol) {
  1426 	bool found = false;
  1432 	bool found = false;
  1433 				found = true;
  1439 				found = true;
  1434 				break;
  1440 				break;
  1435 			}
  1441 			}
  1436 		}
  1442 		}
  1437 	}
  1443 	}
  1438 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1444 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1439 	return NULL;
  1445 	return NULL;
  1440 }
  1446 }
  1441 
  1447 
  1442 void *fill_candidate_datatypes_c::visit(EQ_operator_c *symbol) {
  1448 void *fill_candidate_datatypes_c::visit(EQ_operator_c *symbol) {
  1443 	bool found = false;
  1449 	bool found = false;
  1450 				found = true;
  1456 				found = true;
  1451 				break;
  1457 				break;
  1452 			}
  1458 			}
  1453 		}
  1459 		}
  1454 	}
  1460 	}
  1455 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1461 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1456 	return NULL;
  1462 	return NULL;
  1457 }
  1463 }
  1458 
  1464 
  1459 void *fill_candidate_datatypes_c::visit(LT_operator_c *symbol) {
  1465 void *fill_candidate_datatypes_c::visit(LT_operator_c *symbol) {
  1460 	bool found = false;
  1466 	bool found = false;
  1467 				found = true;
  1473 				found = true;
  1468 				break;
  1474 				break;
  1469 			}
  1475 			}
  1470 		}
  1476 		}
  1471 	}
  1477 	}
  1472 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1478 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1473 	return NULL;
  1479 	return NULL;
  1474 }
  1480 }
  1475 
  1481 
  1476 void *fill_candidate_datatypes_c::visit(LE_operator_c *symbol) {
  1482 void *fill_candidate_datatypes_c::visit(LE_operator_c *symbol) {
  1477 	bool found = false;
  1483 	bool found = false;
  1484 				found = true;
  1490 				found = true;
  1485 				break;
  1491 				break;
  1486 			}
  1492 			}
  1487 		}
  1493 		}
  1488 	}
  1494 	}
  1489 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1495 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1490 	return NULL;
  1496 	return NULL;
  1491 }
  1497 }
  1492 
  1498 
  1493 void *fill_candidate_datatypes_c::visit(NE_operator_c *symbol) {
  1499 void *fill_candidate_datatypes_c::visit(NE_operator_c *symbol) {
  1494 	bool found = false;
  1500 	bool found = false;
  1501 				found = true;
  1507 				found = true;
  1502 				break;
  1508 				break;
  1503 			}
  1509 			}
  1504 		}
  1510 		}
  1505 	}
  1511 	}
  1506 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1512 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1507 	return NULL;
  1513 	return NULL;
  1508 }
  1514 }
  1509 
  1515 
  1510 void *fill_candidate_datatypes_c::visit(CAL_operator_c *symbol) {
  1516 void *fill_candidate_datatypes_c::visit(CAL_operator_c *symbol) {
  1511 	if (NULL == prev_il_instruction) return NULL;
  1517 	if (NULL == prev_il_instruction) return NULL;
  1512 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1518 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1513 	        /* does not need to be bool type !! */
  1519 	        /* does not need to be bool type !! */
  1514 		symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1520 		add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1515 	}
  1521 	}
  1516 	if (debug) std::cout <<  "CAL [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1522 	if (debug) std::cout <<  "CAL [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1517 	return NULL;
  1523 	return NULL;
  1518 }
  1524 }
  1519 
  1525 
  1520 void *fill_candidate_datatypes_c::visit(CALC_operator_c *symbol) {
  1526 void *fill_candidate_datatypes_c::visit(CALC_operator_c *symbol) {
  1521 	if (NULL == prev_il_instruction) return NULL;
  1527 	if (NULL == prev_il_instruction) return NULL;
  1522 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1528 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1523 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1529 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1524 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1530 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1525 	}
  1531 	}
  1526 	if (debug) std::cout <<  "CALC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1532 	if (debug) std::cout <<  "CALC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1527 	return NULL;
  1533 	return NULL;
  1528 }
  1534 }
  1529 
  1535 
  1530 void *fill_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {
  1536 void *fill_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {
  1531 	if (NULL == prev_il_instruction) return NULL;
  1537 	if (NULL == prev_il_instruction) return NULL;
  1532 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1538 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1533 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1539 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1534 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1540 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1535 	}
  1541 	}
  1536 	if (debug) std::cout <<  "CALCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1542 	if (debug) std::cout <<  "CALCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1537 	return NULL;
  1543 	return NULL;
  1538 }
  1544 }
  1539 
  1545 
  1540 void *fill_candidate_datatypes_c::visit(RET_operator_c *symbol) {
  1546 void *fill_candidate_datatypes_c::visit(RET_operator_c *symbol) {
  1541 	if (NULL == prev_il_instruction) return NULL;
  1547 	if (NULL == prev_il_instruction) return NULL;
  1542 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1548 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1543 	        /* does not need to be bool type !! */
  1549 	        /* does not need to be bool type !! */
  1544 		symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1550 		add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1545 	}
  1551 	}
  1546 	if (debug) std::cout <<  "RET [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1552 	if (debug) std::cout <<  "RET [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1547 	return NULL;
  1553 	return NULL;
  1548 }
  1554 }
  1549 
  1555 
  1550 void *fill_candidate_datatypes_c::visit(RETC_operator_c *symbol) {
  1556 void *fill_candidate_datatypes_c::visit(RETC_operator_c *symbol) {
  1551 	if (NULL == prev_il_instruction) return NULL;
  1557 	if (NULL == prev_il_instruction) return NULL;
  1552 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1558 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1553 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1559 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1554 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1560 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1555 	}
  1561 	}
  1556 	if (debug) std::cout <<  "RETC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1562 	if (debug) std::cout <<  "RETC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1557 	return NULL;
  1563 	return NULL;
  1558 }
  1564 }
  1559 
  1565 
  1560 void *fill_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {
  1566 void *fill_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {
  1561 	if (NULL == prev_il_instruction) return NULL;
  1567 	if (NULL == prev_il_instruction) return NULL;
  1562 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1568 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1563 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1569 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1564 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1570 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1565 	}
  1571 	}
  1566 	if (debug) std::cout <<  "RETCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1572 	if (debug) std::cout <<  "RETCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1567 	return NULL;
  1573 	return NULL;
  1568 }
  1574 }
  1569 
  1575 
  1570 void *fill_candidate_datatypes_c::visit(JMP_operator_c *symbol) {
  1576 void *fill_candidate_datatypes_c::visit(JMP_operator_c *symbol) {
  1571 	if (NULL == prev_il_instruction) return NULL;
  1577 	if (NULL == prev_il_instruction) return NULL;
  1572 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1578 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1573 	        /* does not need to be bool type !! */
  1579 	        /* does not need to be bool type !! */
  1574 		symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1580 		add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1575 	}
  1581 	}
  1576 	if (debug) std::cout <<  "JMP [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1582 	if (debug) std::cout <<  "JMP [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1577 	return NULL;
  1583 	return NULL;
  1578 }
  1584 }
  1579 
  1585 
  1580 void *fill_candidate_datatypes_c::visit(JMPC_operator_c *symbol) {
  1586 void *fill_candidate_datatypes_c::visit(JMPC_operator_c *symbol) {
  1581 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1587 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1582 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1588 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1583 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1589 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1584 	}
  1590 	}
  1585 	if (debug) std::cout <<  "JMPC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1591 	if (debug) std::cout <<  "JMPC [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1586 	return NULL;
  1592 	return NULL;
  1587 }
  1593 }
  1588 
  1594 
  1589 void *fill_candidate_datatypes_c::visit(JMPCN_operator_c *symbol) {
  1595 void *fill_candidate_datatypes_c::visit(JMPCN_operator_c *symbol) {
  1590 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1596 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1591 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1597 		if (is_type(prev_il_instruction->candidate_datatypes[i], bool_type_name_c))
  1592 			symbol->candidate_datatypes.push_back(prev_il_instruction->candidate_datatypes[i]);
  1598 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1593 	}
  1599 	}
  1594 	if (debug) std::cout <<  "JMPCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1600 	if (debug) std::cout <<  "JMPCN [" << prev_il_instruction->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1595 	return NULL;
  1601 	return NULL;
  1596 }
  1602 }
  1597 /* Symbol class handled together with function call checks */
  1603 /* Symbol class handled together with function call checks */
  1611 	symbol->r_exp->accept(*this);
  1617 	symbol->r_exp->accept(*this);
  1612 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1618 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1613 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1619 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1614 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1620 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1615 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1621 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1616 				symbol->candidate_datatypes.push_back(symbol->l_exp->candidate_datatypes[i]);
  1622 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
  1617 		}
  1623 		}
  1618 	}
  1624 	}
  1619 	return NULL;
  1625 	return NULL;
  1620 }
  1626 }
  1621 
  1627 
  1626 
  1632 
  1627 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1633 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1628 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1634 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1629 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1635 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1630 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1636 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1631 				symbol->candidate_datatypes.push_back(symbol->l_exp->candidate_datatypes[i]);
  1637 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
  1632 		}
  1638 		}
  1633 	}
  1639 	}
  1634 	return NULL;
  1640 	return NULL;
  1635 }
  1641 }
  1636 
  1642 
  1641 
  1647 
  1642 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1648 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1643 		for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1649 		for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1644 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1650 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
  1645 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1651 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
  1646 				symbol->candidate_datatypes.push_back(symbol->l_exp->candidate_datatypes[i]);
  1652 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
  1647 		}
  1653 		}
  1648 	}
  1654 	}
  1649 	return NULL;
  1655 	return NULL;
  1650 }
  1656 }
  1651 
  1657 
  1662 				found = true;
  1668 				found = true;
  1663 				break;
  1669 				break;
  1664 			}
  1670 			}
  1665 		}
  1671 		}
  1666 	}
  1672 	}
  1667 	if (found) symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1673 	if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1668 	return NULL;
  1674 	return NULL;
  1669 }
  1675 }
  1670 
  1676 
  1671 
  1677 
  1672 void *fill_candidate_datatypes_c::visit(notequ_expression_c *symbol)  {
  1678 void *fill_candidate_datatypes_c::visit(notequ_expression_c *symbol)  {
  1682 				break;
  1688 				break;
  1683 			}
  1689 			}
  1684 		}
  1690 		}
  1685 	}
  1691 	}
  1686 	if (found)
  1692 	if (found)
  1687 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1693 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1688 	return NULL;
  1694 	return NULL;
  1689 }
  1695 }
  1690 
  1696 
  1691 
  1697 
  1692 void *fill_candidate_datatypes_c::visit(lt_expression_c *symbol) {
  1698 void *fill_candidate_datatypes_c::visit(lt_expression_c *symbol) {
  1702 				break;
  1708 				break;
  1703 			}
  1709 			}
  1704 		}
  1710 		}
  1705 	}
  1711 	}
  1706 	if (found)
  1712 	if (found)
  1707 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1713 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1708 	return NULL;
  1714 	return NULL;
  1709 }
  1715 }
  1710 
  1716 
  1711 
  1717 
  1712 void *fill_candidate_datatypes_c::visit(gt_expression_c *symbol) {
  1718 void *fill_candidate_datatypes_c::visit(gt_expression_c *symbol) {
  1722 				break;
  1728 				break;
  1723 			}
  1729 			}
  1724 		}
  1730 		}
  1725 	}
  1731 	}
  1726 	if (found)
  1732 	if (found)
  1727 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1733 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1728 	return NULL;
  1734 	return NULL;
  1729 }
  1735 }
  1730 
  1736 
  1731 void *fill_candidate_datatypes_c::visit(le_expression_c *symbol) {
  1737 void *fill_candidate_datatypes_c::visit(le_expression_c *symbol) {
  1732 	symbol->l_exp->accept(*this);
  1738 	symbol->l_exp->accept(*this);
  1741 				break;
  1747 				break;
  1742 			}
  1748 			}
  1743 		}
  1749 		}
  1744 	}
  1750 	}
  1745 	if (found)
  1751 	if (found)
  1746 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1752 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1747 	return NULL;
  1753 	return NULL;
  1748 }
  1754 }
  1749 
  1755 
  1750 void *fill_candidate_datatypes_c::visit(ge_expression_c *symbol) {
  1756 void *fill_candidate_datatypes_c::visit(ge_expression_c *symbol) {
  1751 	symbol->l_exp->accept(*this);
  1757 	symbol->l_exp->accept(*this);
  1760 				break;
  1766 				break;
  1761 			}
  1767 			}
  1762 		}
  1768 		}
  1763 	}
  1769 	}
  1764 	if (found)
  1770 	if (found)
  1765 		symbol->candidate_datatypes.push_back(&search_constant_type_c::bool_type_name);
  1771 		add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
  1766 	return NULL;
  1772 	return NULL;
  1767 }
  1773 }
  1768 
  1774 
  1769 void *fill_candidate_datatypes_c::visit(add_expression_c *symbol) {
  1775 void *fill_candidate_datatypes_c::visit(add_expression_c *symbol) {
  1770 	/* The following code is correct when handling the addition of 2 symbolic_variables
  1776 	/* The following code is correct when handling the addition of 2 symbolic_variables
  1795 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1801 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1796 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1802 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1797 			left_type = symbol->l_exp->candidate_datatypes[i];
  1803 			left_type = symbol->l_exp->candidate_datatypes[i];
  1798 			right_type = symbol->r_exp->candidate_datatypes[j];
  1804 			right_type = symbol->r_exp->candidate_datatypes[j];
  1799 			if (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1805 			if (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1800 				symbol->candidate_datatypes.push_back(left_type);
  1806 				add_datatype_to_candidate_list(symbol, left_type);
  1801 			else {
  1807 			else {
  1802 				symbol_c *result = widening_conversion(left_type, right_type, widen_ADD_table);
  1808 				symbol_c *result = widening_conversion(left_type, right_type, widen_ADD_table);
  1803 				if (result)
  1809 				if (result)
  1804 					symbol->candidate_datatypes.push_back(result);
  1810 					add_datatype_to_candidate_list(symbol, result);
  1805 			}
  1811 			}
  1806 		}
  1812 		}
  1807 	}
  1813 	}
  1808 	if (debug) std::cout <<  "+ [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1814 	if (debug) std::cout <<  "+ [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1809 	return NULL;
  1815 	return NULL;
  1818 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1824 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1819 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1825 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1820 			left_type = symbol->l_exp->candidate_datatypes[i];
  1826 			left_type = symbol->l_exp->candidate_datatypes[i];
  1821 			right_type = symbol->r_exp->candidate_datatypes[j];
  1827 			right_type = symbol->r_exp->candidate_datatypes[j];
  1822 			if (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1828 			if (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1823 				symbol->candidate_datatypes.push_back(left_type);
  1829 				add_datatype_to_candidate_list(symbol, left_type);
  1824 			else {
  1830 			else {
  1825 				symbol_c *result = widening_conversion(left_type, right_type, widen_SUB_table);
  1831 				symbol_c *result = widening_conversion(left_type, right_type, widen_SUB_table);
  1826 				if (result)
  1832 				if (result)
  1827 					symbol->candidate_datatypes.push_back(result);
  1833 					add_datatype_to_candidate_list(symbol, result);
  1828 			}
  1834 			}
  1829 		}
  1835 		}
  1830 	}
  1836 	}
  1831 	if (debug) std::cout <<  "- [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1837 	if (debug) std::cout <<  "- [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1832 	return NULL;
  1838 	return NULL;
  1841 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1847 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1842 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1848 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1843 			left_type = symbol->l_exp->candidate_datatypes[i];
  1849 			left_type = symbol->l_exp->candidate_datatypes[i];
  1844 			right_type = symbol->r_exp->candidate_datatypes[j];
  1850 			right_type = symbol->r_exp->candidate_datatypes[j];
  1845 			if      (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1851 			if      (is_type_equal(left_type, right_type) && is_ANY_NUM_compatible(left_type))
  1846 				symbol->candidate_datatypes.push_back(left_type);
  1852 				add_datatype_to_candidate_list(symbol, left_type);
  1847 			else {
  1853 			else {
  1848 				symbol_c *result = widening_conversion(left_type, right_type, widen_MUL_table);
  1854 				symbol_c *result = widening_conversion(left_type, right_type, widen_MUL_table);
  1849 				if (result)
  1855 				if (result)
  1850 					symbol->candidate_datatypes.push_back(result);
  1856 					add_datatype_to_candidate_list(symbol, result);
  1851 			}
  1857 			}
  1852 
  1858 
  1853 		}
  1859 		}
  1854 	}
  1860 	}
  1855 	if (debug) std::cout << "* [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1861 	if (debug) std::cout << "* [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1865 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1871 	for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1866 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1872 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1867 			left_type = symbol->l_exp->candidate_datatypes[i];
  1873 			left_type = symbol->l_exp->candidate_datatypes[i];
  1868 			right_type = symbol->r_exp->candidate_datatypes[j];
  1874 			right_type = symbol->r_exp->candidate_datatypes[j];
  1869 			if      (is_type_equal(left_type, right_type) && is_ANY_NUM_type(left_type))
  1875 			if      (is_type_equal(left_type, right_type) && is_ANY_NUM_type(left_type))
  1870 				symbol->candidate_datatypes.push_back(left_type);
  1876 				add_datatype_to_candidate_list(symbol, left_type);
  1871 			else {
  1877 			else {
  1872 				symbol_c *result = widening_conversion(left_type, right_type, widen_DIV_table);
  1878 				symbol_c *result = widening_conversion(left_type, right_type, widen_DIV_table);
  1873 				if (result)
  1879 				if (result)
  1874 					symbol->candidate_datatypes.push_back(result);
  1880 					add_datatype_to_candidate_list(symbol, result);
  1875 			}
  1881 			}
  1876 
  1882 
  1877 		}
  1883 		}
  1878 	}
  1884 	}
  1879 	if (debug) std::cout << "/ [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1885 	if (debug) std::cout << "/ [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1889 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1895 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1890 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1896 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  1891 			left_type = symbol->l_exp->candidate_datatypes[i];
  1897 			left_type = symbol->l_exp->candidate_datatypes[i];
  1892 			right_type = symbol->r_exp->candidate_datatypes[j];
  1898 			right_type = symbol->r_exp->candidate_datatypes[j];
  1893 			if (is_type_equal(left_type, right_type) && is_ANY_INT_compatible(left_type))
  1899 			if (is_type_equal(left_type, right_type) && is_ANY_INT_compatible(left_type))
  1894 				symbol->candidate_datatypes.push_back(left_type);
  1900 				add_datatype_to_candidate_list(symbol, left_type);
  1895 		}
  1901 		}
  1896 	}
  1902 	}
  1897 	if (debug) std::cout << "mod [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1903 	if (debug) std::cout << "mod [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1898 	return NULL;
  1904 	return NULL;
  1899 }
  1905 }
  1922 			break;
  1928 			break;
  1923 		}
  1929 		}
  1924 	}
  1930 	}
  1925 	if (! check_ok) return NULL;
  1931 	if (! check_ok) return NULL;
  1926 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1932 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  1927 		symbol->candidate_datatypes.push_back(symbol->l_exp->candidate_datatypes[i]);
  1933 		add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
  1928 	}
  1934 	}
  1929 	if (debug) std::cout << "** [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1935 	if (debug) std::cout << "** [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1930 	return NULL;
  1936 	return NULL;
  1931 }
  1937 }
  1932 
  1938 
  1957    *        So, that is what we do here!
  1963    *        So, that is what we do here!
  1958    */
  1964    */
  1959 	symbol->exp->accept(*this);
  1965 	symbol->exp->accept(*this);
  1960 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1966 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1961 		if (is_ANY_signed_MAGNITUDE_compatible(symbol->exp->candidate_datatypes[i]))
  1967 		if (is_ANY_signed_MAGNITUDE_compatible(symbol->exp->candidate_datatypes[i]))
  1962 			symbol->candidate_datatypes.push_back(symbol->exp->candidate_datatypes[i]);
  1968 			add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]);
  1963 	}
  1969 	}
  1964 	if (debug) std::cout << "neg [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1970 	if (debug) std::cout << "neg [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1965 	return NULL;
  1971 	return NULL;
  1966 }
  1972 }
  1967 
  1973 
  1968 
  1974 
  1969 void *fill_candidate_datatypes_c::visit(not_expression_c *symbol) {
  1975 void *fill_candidate_datatypes_c::visit(not_expression_c *symbol) {
  1970 	symbol->exp->accept(*this);
  1976 	symbol->exp->accept(*this);
  1971 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1977 	for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1972 		if      (is_ANY_BIT_compatible(symbol->exp->candidate_datatypes[i]))
  1978 		if      (is_ANY_BIT_compatible(symbol->exp->candidate_datatypes[i]))
  1973 			symbol->candidate_datatypes.push_back(symbol->exp->candidate_datatypes[i]);
  1979 			add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]);
  1974 	}
  1980 	}
  1975 	if (debug) std::cout << "not [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1981 	if (debug) std::cout << "not [" << symbol->exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1976 	return NULL;
  1982 	return NULL;
  1977 }
  1983 }
  1978 
  1984 
  2020 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  2026 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
  2021 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  2027 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
  2022 			left_type = symbol->l_exp->candidate_datatypes[i];
  2028 			left_type = symbol->l_exp->candidate_datatypes[i];
  2023 			right_type = symbol->r_exp->candidate_datatypes[j];
  2029 			right_type = symbol->r_exp->candidate_datatypes[j];
  2024 			if (is_type_equal(left_type, right_type))
  2030 			if (is_type_equal(left_type, right_type))
  2025 				symbol->candidate_datatypes.push_back(left_type);
  2031 				add_datatype_to_candidate_list(symbol, left_type);
  2026 		}
  2032 		}
  2027 	}
  2033 	}
  2028 	if (debug) std::cout << ":= [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  2034 	if (debug) std::cout << ":= [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  2029 	return NULL;
  2035 	return NULL;
  2030 }
  2036 }