stage3/fill_candidate_datatypes.cc
changeset 467 4910eaa1206a
parent 465 b52ec62773db
child 470 d2cd05c5e01a
equal deleted inserted replaced
466:d97a29b7fa8b 467:4910eaa1206a
   299 	 * correct.
   299 	 * correct.
   300 	 * For now, we will simply let the narrow_candidate_datatypes_c verify if the datatypes are compatible (something that should be done
   300 	 * For now, we will simply let the narrow_candidate_datatypes_c verify if the datatypes are compatible (something that should be done
   301 	 * here).
   301 	 * here).
   302 	 */
   302 	 */
   303 	if (NULL != prev_il_instruction)
   303 	if (NULL != prev_il_instruction)
   304 		copy_candidate_datatype_list(prev_il_instruction/*from*/, il_instruction/*to*/);
   304 		il_instruction->candidate_datatypes = prev_il_instruction->candidate_datatypes; 
   305 
   305 
   306 	if (debug) std::cout << "handle_implicit_il_fb_call() [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << il_instruction->candidate_datatypes.size() << " result.\n";
   306 	if (debug) std::cout << "handle_implicit_il_fb_call() [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << il_instruction->candidate_datatypes.size() << " result.\n";
   307 }
   307 }
   308 
   308 
   309 
   309 
   847 		else                                          prev_il_instruction = &fake_prev_il_instruction;
   847 		else                                          prev_il_instruction = &fake_prev_il_instruction;
   848 		symbol->il_instruction->accept(*this);
   848 		symbol->il_instruction->accept(*this);
   849 		prev_il_instruction = NULL;
   849 		prev_il_instruction = NULL;
   850 
   850 
   851 		/* This object has (inherits) the same candidate datatypes as the il_instruction */
   851 		/* This object has (inherits) the same candidate datatypes as the il_instruction */
   852 		copy_candidate_datatype_list(symbol->il_instruction /*from*/, symbol /*to*/);	
   852 		symbol->candidate_datatypes = symbol->il_instruction->candidate_datatypes;
   853 	}
   853 	}
   854 
   854 
   855 	return NULL;
   855 	return NULL;
   856 }
   856 }
   857 
   857 
   865 	/* recursive call to fill the candidate data types list */
   865 	/* recursive call to fill the candidate data types list */
   866 	il_operand = symbol->il_operand;
   866 	il_operand = symbol->il_operand;
   867 	symbol->il_simple_operator->accept(*this);
   867 	symbol->il_simple_operator->accept(*this);
   868 	il_operand = NULL;
   868 	il_operand = NULL;
   869 	/* This object has (inherits) the same candidate datatypes as the il_simple_operator */
   869 	/* This object has (inherits) the same candidate datatypes as the il_simple_operator */
   870 	copy_candidate_datatype_list(symbol->il_simple_operator /*from*/, symbol /*to*/);
   870 	symbol->candidate_datatypes = symbol->il_simple_operator->candidate_datatypes;
   871 	return NULL;
   871 	return NULL;
   872 }
   872 }
   873 
   873 
   874 
   874 
   875 /* | function_name [il_operand_list] */
   875 /* | function_name [il_operand_list] */
   938   prev_il_instruction = prev_il_instruction_backup;
   938   prev_il_instruction = prev_il_instruction_backup;
   939   symbol->il_expr_operator->accept(*this);
   939   symbol->il_expr_operator->accept(*this);
   940   il_operand = NULL;
   940   il_operand = NULL;
   941   
   941   
   942   /* This object has the same candidate datatypes as the il_expr_operator. */
   942   /* This object has the same candidate datatypes as the il_expr_operator. */
   943   copy_candidate_datatype_list(symbol->il_expr_operator/*from*/, symbol/*to*/);
   943   symbol->candidate_datatypes = symbol->il_expr_operator->candidate_datatypes;
   944   return NULL;
   944   return NULL;
   945 }
   945 }
   946 
   946 
   947 
   947 
   948 void *fill_candidate_datatypes_c::visit(il_jump_operation_c *symbol) {
   948 void *fill_candidate_datatypes_c::visit(il_jump_operation_c *symbol) {
   949   /* recursive call to fill the candidate data types list */
   949   /* recursive call to fill the candidate data types list */
   950   il_operand = NULL;
   950   il_operand = NULL;
   951   symbol->il_jump_operator->accept(*this);
   951   symbol->il_jump_operator->accept(*this);
   952   il_operand = NULL;
   952   il_operand = NULL;
   953   /* This object has the same candidate datatypes as the il_jump_operator. */
   953   /* This object has the same candidate datatypes as the il_jump_operator. */
   954   copy_candidate_datatype_list(symbol->il_jump_operator/*from*/, symbol/*to*/);
   954   symbol->candidate_datatypes = symbol->il_jump_operator->candidate_datatypes;
   955   return NULL;
   955   return NULL;
   956 }
   956 }
   957 
   957 
   958 
   958 
   959 /*   il_call_operator prev_declared_fb_name
   959 /*   il_call_operator prev_declared_fb_name
   996 	 *       IL instructions may be handled correctly and debuged.
   996 	 *       IL instructions may be handled correctly and debuged.
   997 	 *       Doing this is actually safe, as the parameter_list will still contain errors that will be found by
   997 	 *       Doing this is actually safe, as the parameter_list will still contain errors that will be found by
   998 	 *       print_datatypes_error_c, so the code will never reach stage 4!
   998 	 *       print_datatypes_error_c, so the code will never reach stage 4!
   999 	 */
   999 	 */
  1000 	symbol->il_call_operator->accept(*this);
  1000 	symbol->il_call_operator->accept(*this);
  1001 	copy_candidate_datatype_list(symbol->il_call_operator/*from*/, symbol/*to*/);
  1001 	symbol->candidate_datatypes = symbol->il_call_operator->candidate_datatypes;
  1002 
  1002 
  1003 	if (debug) std::cout << "FB [] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1003 	if (debug) std::cout << "FB [] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1004 	return NULL;
  1004 	return NULL;
  1005 }
  1005 }
  1006 
  1006 
  1038     
  1038     
  1039   for(int i = 0; i < symbol->n; i++)
  1039   for(int i = 0; i < symbol->n; i++)
  1040     symbol->elements[i]->accept(*this);
  1040     symbol->elements[i]->accept(*this);
  1041 
  1041 
  1042   /* This object has (inherits) the same candidate datatypes as the last il_instruction */
  1042   /* This object has (inherits) the same candidate datatypes as the last il_instruction */
  1043   copy_candidate_datatype_list(symbol->elements[symbol->n-1] /*from*/, symbol /*to*/);	
  1043   symbol->candidate_datatypes = symbol->elements[symbol->n-1]->candidate_datatypes;
  1044   
  1044   
  1045   if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
  1045   if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
  1046   return NULL;
  1046   return NULL;
  1047 }
  1047 }
  1048 
  1048 
  1056   else                                          prev_il_instruction = symbol->prev_il_instruction[0];
  1056   else                                          prev_il_instruction = symbol->prev_il_instruction[0];
  1057   symbol->il_simple_instruction->accept(*this);
  1057   symbol->il_simple_instruction->accept(*this);
  1058   prev_il_instruction = NULL;
  1058   prev_il_instruction = NULL;
  1059 
  1059 
  1060   /* This object has (inherits) the same candidate datatypes as the il_simple_instruction it points to */
  1060   /* This object has (inherits) the same candidate datatypes as the il_simple_instruction it points to */
  1061   copy_candidate_datatype_list(symbol->il_simple_instruction /*from*/, symbol /*to*/);	
  1061   symbol->candidate_datatypes = symbol->il_simple_instruction->candidate_datatypes;
  1062   return NULL;
  1062   return NULL;
  1063 }
  1063 }
  1064 
  1064 
  1065 
  1065 
  1066 /*
  1066 /*