예제 #1
0
ir_function_signature *
ir_function::matching_signature(const exec_list *actual_parameters)
{
   ir_function_signature *match = NULL;

   foreach_iter(exec_list_iterator, iter, signatures) {
      ir_function_signature *const sig =
	 (ir_function_signature *) iter.get();

      const int score = parameter_lists_match(& sig->parameters,
					      actual_parameters);

      if (score == 0)
	 return sig;

      if (score > 0) {
	 if (match != NULL)
	    return NULL;

	 match = sig;
      }
   }
예제 #2
0
ir_function_signature *
ir_function::matching_signature(const exec_list *actual_parameters,
			        bool *is_exact)
{
   ir_function_signature *match = NULL;
   bool multiple_inexact_matches = false;

   /* From page 42 (page 49 of the PDF) of the GLSL 1.20 spec:
    *
    * "If an exact match is found, the other signatures are ignored, and
    *  the exact match is used.  Otherwise, if no exact match is found, then
    *  the implicit conversions in Section 4.1.10 "Implicit Conversions" will
    *  be applied to the calling arguments if this can make their types match
    *  a signature.  In this case, it is a semantic error if there are
    *  multiple ways to apply these conversions to the actual arguments of a
    *  call such that the call can be made to match multiple signatures."
    */
   foreach_iter(exec_list_iterator, iter, signatures) {
      ir_function_signature *const sig =
	 (ir_function_signature *) iter.get();

      switch (parameter_lists_match(& sig->parameters, actual_parameters)) {
      case PARAMETER_LIST_EXACT_MATCH:
	 *is_exact = true;
	 return sig;
      case PARAMETER_LIST_INEXACT_MATCH:
	 if (match == NULL)
	    match = sig;
	 else
	    multiple_inexact_matches = true;
	 continue;
      case PARAMETER_LIST_NO_MATCH:
	 continue;
      default:
	 assert(false);
	 return NULL;
      }
   }