⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 call.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 5 页
字号:
  if (codel == REAL_TYPE)    {      if (coder == REAL_TYPE)	{	  if (TYPE_MAIN_VARIANT (type)	      == TYPE_MAIN_VARIANT (type_promotes_to (parmtype)))	    h.code = PROMO_CODE;	  else	    h.code = STD_CODE;	    	  return h;	}      else if (INTEGRAL_CODE_P (coder))	{	  h.code = STD_CODE;	  h.distance = 0;	  return h;	}    }  /* Convert arrays which have not previously been converted.  */#if 0  if (codel == ARRAY_TYPE)    codel = POINTER_TYPE;#endif  if (coder == ARRAY_TYPE)    {      coder = POINTER_TYPE;      if (parm)	{	  parm = decay_conversion (parm);	  parmtype = TREE_TYPE (parm);	}      else	parmtype = build_pointer_type (TREE_TYPE (parmtype));    }  /* Conversions among pointers */  if (codel == POINTER_TYPE && coder == POINTER_TYPE)    {      register tree ttl = TYPE_MAIN_VARIANT (TREE_TYPE (type));      register tree ttr = TYPE_MAIN_VARIANT (TREE_TYPE (parmtype));      int penalty = 4 * (ttl != ttr);      /* Anything converts to void *.  Since this may be `const void *'	 (etc.) use VOID_TYPE instead of void_type_node.  Otherwise, the	 targets must be the same, except that we do allow (at some cost)	 conversion between signed and unsigned pointer types.  */      if ((TREE_CODE (ttl) == METHOD_TYPE	   || TREE_CODE (ttl) == FUNCTION_TYPE)	  && TREE_CODE (ttl) == TREE_CODE (ttr))	{	  if (comptypes (ttl, ttr, -1))	    {	      h.code = penalty ? STD_CODE : 0;	      h.distance =  0;	    }	  else	    h.code = EVIL_CODE;	  return h;	}#if 1      if (TREE_CODE (ttl) != VOID_TYPE	  && (TREE_CODE (ttr) != VOID_TYPE || !parm || !integer_zerop (parm)))	{	  if (TREE_UNSIGNED (ttl) != TREE_UNSIGNED (ttr))	    {	      ttl = unsigned_type (ttl);	      ttr = unsigned_type (ttr);	      penalty = 10;	    }	  if (comp_target_types (type, parmtype, 1) <= 0)	    return EVIL_RETURN (h);	}#else      if (!(TREE_CODE (ttl) == VOID_TYPE	    || TREE_CODE (ttr) == VOID_TYPE	    || (TREE_UNSIGNED (ttl) ^ TREE_UNSIGNED (ttr)		&& (ttl = unsigned_type (ttl),		    ttr = unsigned_type (ttr),		    penalty = 10, 0))	    || (comp_target_types (ttl, ttr, 0) > 0)))	return EVIL_RETURN (h);#endif      if (penalty == 10 || ttr == ttl)	{	  tree tmp1 = TREE_TYPE (type), tmp2 = TREE_TYPE (parmtype);	  /* If one was unsigned but the other wasn't, then we need to	     do a standard conversion from T to unsigned T.  */	  if (penalty == 10)	    h.code = PROMO_CODE; /* was STD_CODE */	  else	    h.code = 0;	  /* Note conversion from `T*' to `const T*',	                       or `T*' to `volatile T*'.  */	  if (ttl == ttr	      && ((TYPE_READONLY (tmp1) != TREE_READONLY (tmp2))		  || (TYPE_VOLATILE (tmp1) != TYPE_VOLATILE (tmp2))))	    h.code |= QUAL_CODE;	  h.distance = 0;	  return h;	}      if (TREE_CODE (ttl) == RECORD_TYPE && TREE_CODE (ttr) == RECORD_TYPE)	{	  int b_or_d = get_base_distance (ttl, ttr, 0, 0);	  if (b_or_d < 0)	    {	      b_or_d = get_base_distance (ttr, ttl, 0, 0);	      if (b_or_d < 0)		return EVIL_RETURN (h);	      h.distance = -b_or_d;	    }	  else	    h.distance = b_or_d;	  h.code = STD_CODE;	  return h;	}      /* If converting from a `class*' to a `void*', make it	 less favorable than any inheritance relationship.  */      if (TREE_CODE (ttl) == VOID_TYPE && IS_AGGR_TYPE (ttr))	{	  h.code = STD_CODE;	  h.distance = CLASSTYPE_MAX_DEPTH (ttr)+1;	  return h;	}      h.code = penalty ? STD_CODE : PROMO_CODE;      /* Catch things like `const char *' -> `const void *'	 vs `const char *' -> `void *'.  */      if (ttl != ttr)	{	  tree tmp1 = TREE_TYPE (type), tmp2 = TREE_TYPE (parmtype);	  if ((TYPE_READONLY (tmp1) != TREE_READONLY (tmp2))	      || (TYPE_VOLATILE (tmp1) != TYPE_VOLATILE (tmp2)))	    h.code |= QUAL_CODE;	}      return h;    }  if (codel == POINTER_TYPE && coder == INTEGER_TYPE)    {      /* This is not a bad match, but don't let it beat	 integer-enum combinations.  */      if (parm && integer_zerop (parm))	{	  h.code = STD_CODE;	  h.distance = 0;	  return h;	}    }  /* C++: Since the `this' parameter of a signature member function     is represented as a signature pointer to handle default implementations     correctly, we can have the case that `type' is a signature pointer     while `parmtype' is a pointer to a signature table.  We don't really     do any conversions in this case, so just return 0.  */  if (codel == RECORD_TYPE && coder == POINTER_TYPE      && IS_SIGNATURE_POINTER (type) && IS_SIGNATURE (TREE_TYPE (parmtype)))    return ZERO_RETURN (h);  if (codel == RECORD_TYPE && coder == RECORD_TYPE)    {      int b_or_d = get_base_distance (type, parmtype, 0, 0);      if (b_or_d < 0)	{	  b_or_d = get_base_distance (parmtype, type, 0, 0);	  if (b_or_d < 0)	    return EVIL_RETURN (h);	  h.distance = -b_or_d;	}      else	h.distance = b_or_d;      h.code = STD_CODE;      return h;    }  return EVIL_RETURN (h);}/* A clone of build_type_conversion for checking user-defined conversions in   overload resolution.  */intuser_harshness (type, parmtype, parm)     register tree type, parmtype;     tree parm;{  tree conv;  tree winner = NULL_TREE;  int code;  {    tree typename = build_typename_overload (type);    if (lookup_fnfields (TYPE_BINFO (parmtype), typename, 0))      return 0;  }			  for (conv = lookup_conversions (parmtype); conv; conv = TREE_CHAIN (conv))    {      struct harshness_code tmp;      if (winner && TREE_PURPOSE (winner) == TREE_PURPOSE (conv))	continue;      if (tmp = convert_harshness (type, TREE_VALUE (conv), NULL_TREE),	  tmp.code < USER_CODE && tmp.distance >= 0)	{	  if (winner)	    return EVIL_CODE;	  else	    {	      winner = conv;	      code = tmp.code;	    }	}    }  if (winner)    return code;  return -1;}intcan_convert (to, from)     tree to, from;{  struct harshness_code h;  h = convert_harshness (to, from, NULL_TREE);  return h.code < USER_CODE && h.distance >= 0;}intcan_convert_arg (to, from, arg)     tree to, from, arg;{  struct harshness_code h;  h = convert_harshness (to, from, arg);  return h.code < USER_CODE && h.distance >= 0;}#ifdef DEBUG_MATCHINGstatic char *print_harshness (h)     struct harshness_code *h;{  static char buf[1024];  char tmp[1024];  bzero (buf, 1024 * sizeof (char));  strcat (buf, "codes=[");  if (h->code & EVIL_CODE)    strcat (buf, "EVIL");  if (h->code & CONST_CODE)    strcat (buf, " CONST");  if (h->code & ELLIPSIS_CODE)    strcat (buf, " ELLIPSIS");  if (h->code & USER_CODE)    strcat (buf, " USER");  if (h->code & STD_CODE)    strcat (buf, " STD");  if (h->code & PROMO_CODE)    strcat (buf, " PROMO");  if (h->code & QUAL_CODE)    strcat (buf, " QUAL");  if (h->code & TRIVIAL_CODE)    strcat (buf, " TRIVIAL");  if (buf[0] == '\0')    strcat (buf, "0");  sprintf (tmp, "] distance=%d int_penalty=%d", h->distance, h->int_penalty);  strcat (buf, tmp);  return buf;}#endif/* Algorithm: For each argument, calculate how difficult it is to   make FUNCTION accept that argument.  If we can easily tell that   FUNCTION won't be acceptable to one of the arguments, then we   don't need to compute the ease of converting the other arguments,   since it will never show up in the intersection of all arguments'   favorite functions.   Conversions between builtin and user-defined types are allowed, but   no function involving such a conversion is preferred to one which   does not require such a conversion.  Furthermore, such conversions   must be unique.  */voidcompute_conversion_costs (function, tta_in, cp, arglen)     tree function;     tree tta_in;     struct candidate *cp;     int arglen;{  tree ttf_in = TYPE_ARG_TYPES (TREE_TYPE (function));  tree ttf = ttf_in;  tree tta = tta_in;  /* Start out with no strikes against.  */  int evil_strikes = 0;  int ellipsis_strikes = 0;  int user_strikes = 0;  int b_or_d_strikes = 0;  int easy_strikes = 0;  int strike_index = 0, win;  struct harshness_code lose;  extern int cp_silent;#ifdef GATHER_STATISTICS  n_compute_conversion_costs++;#endif#ifndef DEBUG_MATCHING  /* We don't emit any warnings or errors while trying out each candidate.  */  cp_silent = 1;#endif  cp->function = function;  cp->arg = tta ? TREE_VALUE (tta) : NULL_TREE;  cp->u.bad_arg = 0;		/* optimistic!  */  cp->h.code = 0;  cp->h.distance = 0;  cp->h.int_penalty = 0;  bzero ((char *) cp->harshness,	 (cp->h_len + 1) * sizeof (struct harshness_code));  while (ttf && tta)    {      struct harshness_code h;      if (ttf == void_list_node)	break;      if (type_unknown_p (TREE_VALUE (tta)))	{	  	  /* Must perform some instantiation here.  */	  tree rhs = TREE_VALUE (tta);	  tree lhstype = TREE_VALUE (ttf);	  /* Keep quiet about possible contravariance violations.  */	  int old_inhibit_warnings = inhibit_warnings;	  inhibit_warnings = 1;	  /* @@ This is to undo what `grokdeclarator' does to	     parameter types.  It really should go through	     something more general.  */	  TREE_TYPE (tta) = unknown_type_node;	  rhs = instantiate_type (lhstype, rhs, 0);	  inhibit_warnings = old_inhibit_warnings;	  if (TREE_CODE (rhs) == ERROR_MARK)	    h.code = EVIL_CODE;	  else	    h = convert_harshness (lhstype, TREE_TYPE (rhs), rhs);	}      else	{#ifdef DEBUG_MATCHING	  static tree old_function = NULL_TREE;	  if (!old_function || function != old_function)	    {	      cp_error ("trying %D", function);	      old_function = function;	    }	  cp_error ("      doing (%T) %E against arg %T",		    TREE_TYPE (TREE_VALUE (tta)), TREE_VALUE (tta),		    TREE_VALUE (ttf));#endif	  h = convert_harshness (TREE_VALUE (ttf),				 TREE_TYPE (TREE_VALUE (tta)),				 TREE_VALUE (tta));#ifdef DEBUG_MATCHING	  cp_error ("     evaluated %s", print_harshness (&h));#endif	}      cp->harshness[strike_index] = h;      if ((h.code & EVIL_CODE)	  || ((h.code & STD_CODE) && h.distance < 0))	{	  cp->u.bad_arg = strike_index;	  evil_strikes = 1;	}     else if (h.code & ELLIPSIS_CODE)       ellipsis_strikes += 1;#if 0      /* This is never set by `convert_harshness'.  */      else if (h.code & USER_CODE)	{	  user_strikes += 1;	}#endif      else	{	  if ((h.code & STD_CODE) && h.distance)	    {	      if (h.distance > b_or_d_strikes)		b_or_d_strikes = h.distance;	    }	  else	    easy_strikes += (h.code & (STD_CODE|PROMO_CODE|TRIVIAL_CODE));	  cp->h.code |= h.code;	  /* Make sure we communicate this.  */	  cp->h.int_penalty += h.int_penalty;	}      ttf = TREE_CHAIN (ttf);      tta = TREE_CHAIN (tta);      strike_index += 1;    }  if (tta)    {      /* ran out of formals, and parmlist is fixed size.  */      if (ttf /* == void_type_node */)	{	  cp->h.code = EVIL_CODE;	  cp->u.bad_arg = -1;	  cp_silent = 0;	  return;	}      else	{	  struct harshness_code h;	  int l = list_length (tta);	  ellipsis_strikes += l;	  h.code = ELLIPSIS_CODE;	  h.distance = 0;	  h.int_penalty = 0;	  for (; l; --l)	    cp->harshness[strike_index++] = h;	}    }  else if (ttf && ttf != void_list_node)    {      /* ran out of actuals, and no defaults.  */      if (TREE_PURPOSE (ttf) == NULL_TREE)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -