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

📄 cplus-dem.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	    {	      /* Read the return type. */	      string return_type;	      string_init (&return_type);	      (*mangled)++;	      success = do_type (work, mangled, &return_type);	      APPEND_BLANK (&return_type);	      string_prepends (declp, &return_type);	      string_delete (&return_type);	      break;	    }	  else	    /* At the outermost level, we cannot have a return type specified,	       so if we run into another '_' at this point we are dealing with	       a mangled name that is either bogus, or has been mangled by	       some algorithm we don't know how to deal with.  So just	       reject the entire demangling.  */            /* However, "_nnn" is an expected suffix for alternate entry point               numbered nnn for a function, with HP aCC, so skip over that               without reporting failure. pai/1997-09-04 */            if (HP_DEMANGLING)              {                (*mangled)++;                while (**mangled && ISDIGIT ((unsigned char)**mangled))                  (*mangled)++;              }            else	      success = 0;	  break;	case 'H':	  if (AUTO_DEMANGLING || GNU_DEMANGLING)	    {	      /* A G++ template function.  Read the template arguments. */	      success = demangle_template (work, mangled, declp, 0, 0,					   0);	      if (!(work->constructor & 1))		expect_return_type = 1;	      (*mangled)++;	      break;	    }	  else	    /* fall through */	    {;}	default:	  if (AUTO_DEMANGLING || GNU_DEMANGLING)	    {	      /* Assume we have stumbled onto the first outermost function		 argument token, and start processing args.  */	      func_done = 1;	      success = demangle_args (work, mangled, declp);	    }	  else	    {	      /* Non-GNU demanglers use a specific token to mark the start		 of the outermost function argument tokens.  Typically 'F',		 for ARM/HP-demangling, for example.  So if we find something		 we are not prepared for, it must be an error.  */	      success = 0;	    }	  break;	}      /*	if (AUTO_DEMANGLING || GNU_DEMANGLING)	*/      {	if (success && expect_func)	  {	    func_done = 1;              if (LUCID_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING)                {                  forget_types (work);                }	    success = demangle_args (work, mangled, declp);	    /* Since template include the mangling of their return types,	       we must set expect_func to 0 so that we don't try do	       demangle more arguments the next time we get here.  */	    expect_func = 0;	  }      }    }  if (success && !func_done)    {      if (AUTO_DEMANGLING || GNU_DEMANGLING)	{	  /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and	     bar__3fooi is 'foo::bar(int)'.  We get here when we find the	     first case, and need to ensure that the '(void)' gets added to	     the current declp.  Note that with ARM/HP, the first case	     represents the name of a static data member 'foo::bar',	     which is in the current declp, so we leave it alone.  */	  success = demangle_args (work, mangled, declp);	}    }  if (success && PRINT_ARG_TYPES)    {      if (work->static_type)	string_append (declp, " static");      if (work->type_quals != TYPE_UNQUALIFIED)	{	  APPEND_BLANK (declp);	  string_append (declp, qualifier_string (work->type_quals));	}    }  return (success);}#if 0static intdemangle_method_args (work, mangled, declp)     struct work_stuff *work;     const char **mangled;     string *declp;{  int success = 0;  if (work -> static_type)    {      string_append (declp, *mangled + 1);      *mangled += strlen (*mangled);      success = 1;    }  else    {      success = demangle_args (work, mangled, declp);    }  return (success);}#endifstatic intdemangle_template_template_parm (work, mangled, tname)     struct work_stuff *work;     const char **mangled;     string *tname;{  int i;  int r;  int need_comma = 0;  int success = 1;  string temp;  string_append (tname, "template <");  /* get size of template parameter list */  if (get_count (mangled, &r))    {      for (i = 0; i < r; i++)	{	  if (need_comma)	    {	      string_append (tname, ", ");	    }	    /* Z for type parameters */	    if (**mangled == 'Z')	      {		(*mangled)++;		string_append (tname, "class");	      }	      /* z for template parameters */	    else if (**mangled == 'z')	      {		(*mangled)++;		success =		  demangle_template_template_parm (work, mangled, tname);		if (!success)		  {		    break;		  }	      }	    else	      {		/* temp is initialized in do_type */		success = do_type (work, mangled, &temp);		if (success)		  {		    string_appends (tname, &temp);		  }		string_delete(&temp);		if (!success)		  {		    break;		  }	      }	  need_comma = 1;	}    }  if (tname->p[-1] == '>')    string_append (tname, " ");  string_append (tname, "> class");  return (success);}static intdemangle_expression (work, mangled, s, tk)     struct work_stuff *work;     const char** mangled;     string* s;     type_kind_t tk;{  int need_operator = 0;  int success;  success = 1;  string_appendn (s, "(", 1);  (*mangled)++;  while (success && **mangled != 'W' && **mangled != '\0')    {      if (need_operator)	{	  size_t i;	  size_t len;	  success = 0;	  len = strlen (*mangled);	  for (i = 0; i < ARRAY_SIZE (optable); ++i)	    {	      size_t l = strlen (optable[i].in);	      if (l <= len		  && memcmp (optable[i].in, *mangled, l) == 0)		{		  string_appendn (s, " ", 1);		  string_append (s, optable[i].out);		  string_appendn (s, " ", 1);		  success = 1;		  (*mangled) += l;		  break;		}	    }	  if (!success)	    break;	}      else	need_operator = 1;      success = demangle_template_value_parm (work, mangled, s, tk);    }  if (**mangled != 'W')    success = 0;  else    {      string_appendn (s, ")", 1);      (*mangled)++;    }  return success;}static intdemangle_integral_value (work, mangled, s)     struct work_stuff *work;     const char** mangled;     string* s;{  int success;  if (**mangled == 'E')    success = demangle_expression (work, mangled, s, tk_integral);  else if (**mangled == 'Q' || **mangled == 'K')    success = demangle_qualified (work, mangled, s, 0, 1);  else    {      int value;      /* By default, we let the number decide whether we shall consume an	 underscore.  */      int consume_following_underscore = 0;      int leave_following_underscore = 0;      success = 0;      /* Negative numbers are indicated with a leading `m'.  */      if (**mangled == 'm')	{	  string_appendn (s, "-", 1);	  (*mangled)++;	}      else if (mangled[0][0] == '_' && mangled[0][1] == 'm')	{	  /* Since consume_count_with_underscores does not handle the	     `m'-prefix we must do it here, using consume_count and	     adjusting underscores: we have to consume the underscore	     matching the prepended one.  */	  consume_following_underscore = 1;	  string_appendn (s, "-", 1);	  (*mangled) += 2;	}      else if (**mangled == '_')	{	  /* Do not consume a following underscore;	     consume_following_underscore will consume what should be	     consumed.  */	  leave_following_underscore = 1;	}      /* We must call consume_count if we expect to remove a trailing	 underscore, since consume_count_with_underscores expects	 the leading underscore (that we consumed) if it is to handle	 multi-digit numbers.  */      if (consume_following_underscore)	value = consume_count (mangled);      else	value = consume_count_with_underscores (mangled);      if (value != -1)	{	  char buf[INTBUF_SIZE];	  sprintf (buf, "%d", value);	  string_append (s, buf);	  /* Numbers not otherwise delimited, might have an underscore	     appended as a delimeter, which we should skip.	     ??? This used to always remove a following underscore, which	     is wrong.  If other (arbitrary) cases are followed by an	     underscore, we need to do something more radical.  */	  if ((value > 9 || consume_following_underscore)	      && ! leave_following_underscore	      && **mangled == '_')	    (*mangled)++;	  /* All is well.  */	  success = 1;	}    }  return success;}/* Demangle the real value in MANGLED.  */static intdemangle_real_value (work, mangled, s)     struct work_stuff *work;     const char **mangled;     string* s;{  if (**mangled == 'E')    return demangle_expression (work, mangled, s, tk_real);  if (**mangled == 'm')    {      string_appendn (s, "-", 1);      (*mangled)++;    }  while (ISDIGIT ((unsigned char)**mangled))    {      string_appendn (s, *mangled, 1);      (*mangled)++;    }  if (**mangled == '.') /* fraction */    {      string_appendn (s, ".", 1);      (*mangled)++;      while (ISDIGIT ((unsigned char)**mangled))	{	  string_appendn (s, *mangled, 1);	  (*mangled)++;	}    }  if (**mangled == 'e') /* exponent */    {      string_appendn (s, "e", 1);      (*mangled)++;      while (ISDIGIT ((unsigned char)**mangled))	{	  string_appendn (s, *mangled, 1);	  (*mangled)++;	}    }  return 1;}static intdemangle_template_value_parm (work, mangled, s, tk)     struct work_stuff *work;     const char **mangled;     string* s;     type_kind_t tk;{  int success = 1;  if (**mangled == 'Y')    {      /* The next argument is a template parameter. */      int idx;      (*mangled)++;      idx = consume_count_with_underscores (mangled);      if (idx == -1	  || (work->tmpl_argvec && idx >= work->ntmpl_args)	  || consume_count_with_underscores (mangled) == -1)	return -1;      if (work->tmpl_argvec)	string_append (s, work->tmpl_argvec[idx]);      else	string_append_template_idx (s, idx);    }  else if (tk == tk_integral)    success = demangle_integral_value (work, mangled, s);  else if (tk == tk_char)    {      char tmp[2];      int val;      if (**mangled == 'm')	{	  string_appendn (s, "-", 1);	  (*mangled)++;	}      string_appendn (s, "'", 1);      val = consume_count(mangled);      if (val <= 0)	success = 0;      else	{	  tmp[0] = (char)val;	  tmp[1] = '\0';	  string_appendn (s, &tmp[0], 1);	  string_appendn (s, "'", 1);	}    }  else if (tk == tk_bool)    {      int val = consume_count (mangled);      if (val == 0)	string_appendn (s, "false", 5);      else if (val == 1)	string_appendn (s, "true", 4);      else	success = 0;    }  else if (tk == tk_real)    success = demangle_real_value (work, mangled, s);  else if (tk == tk_pointer || tk == tk_reference)    {      if (**mangled == 'Q')	success = demangle_qualified (work, mangled, s,				      /*isfuncname=*/0, 				      /*append=*/1);      else	{	  int symbol_len  = consume_count (mangled);	  if (symbol_len == -1)	    return -1;	  if (symbol_len == 0)	    string_appendn (s, "0", 1);	  else	    {	      char *p = xmalloc (symbol_len + 1), *q;	      strncpy (p, *mangled, symbol_len);	      p [symbol_len] = '\0';	      /* We use cplus_demangle here, rather than		 internal_cplus_demangle, because the name of the entity		 mangled here does not make use of any of the squangling		 or type-code information we have built up thus far; it is		 mangled independently.  */	      q = cplus_demangle (p, work->options);	      if (tk == tk_pointer)		string_appendn (s, "&", 1);	      /* FIXME: Pointer-to-member constants should get a		 qualifying class name here.  */	      if (q)		{		  string_append (s, q);		  free (q);		}	      else		string_append (s, p);	      free (p);	    }	  *mangled += symbol_len;	}    }  return success;}/* Demangle the template name in MANGLED.  The full name of the   template (e.g., S<int>) is placed in TNAME.  The name without the   template parameters (e.g. S) is placed in TRAWNAME if TRAWNAME is   non-NULL.  If IS_TYPE is nonzero, this template is a type template,   not a function template.  If both IS_TYPE and REMEMBER are nonzero,   the template is remembered in the list of back-referenceable   types.  */static intdemangle_template (work, mangled, tname, trawname, is_type, remember)     struct work_stuff *work;     const char **mangled;     string *tname;     string *trawname;     int is_type;     int remember;{  int i;  int r;  int need_comma = 0;  int success = 0;  const char *start;  int is_java_array = 0;  string temp;  int bindex = 0;  (*mangled)++;

⌨️ 快捷键说明

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