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

📄 xref.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 2 页
字号:
    {      cls = "CLASSID";      fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n",	       filename(xf), lineno,name,	       (cur_scope != NULL ? cur_scope->lid : 0),	       cls, fctname(fndecl), buf);    }}/* Output a reference to a call to NAME in FNDECL.  */voidGNU_xref_call (fndecl, name)   tree fndecl;   const char *name;{  XREF_FILE xf;  char buf[1024];  const char *s;  if (!doing_xref) return;  xf = find_file (input_filename);  if (xf == NULL) return;  name = fixname (name, buf);  for (s = name; *s != 0; ++s)    if (*s == '_' && s[1] == '_') break;  if (*s != 0) GNU_xref_ref (fndecl, name);  fprintf (xref_file, "CAL %s %d %s %s\n",	   filename (xf), lineno, name, fctname (fndecl));}/* Output cross-reference info about FNDECL.  If non-NULL,   ARGS are the arguments for the function (i.e., before the FUNCTION_DECL   has been fully built).  */voidGNU_xref_function (fndecl, args)   tree fndecl;   tree args;{  XREF_FILE xf;  int ct;  char buf[1024];  if (!doing_xref) return;  xf = find_file (input_filename);  if (xf == NULL) return;  ct = 0;  buf[0] = 0;  if (args == NULL) args = DECL_ARGUMENTS (fndecl);  GNU_xref_decl (NULL, fndecl);  for ( ; args != NULL; args = TREE_CHAIN (args))    {      GNU_xref_decl (fndecl,args);      if (ct != 0) strcat (buf,",");      strcat (buf, declname (args));      ++ct;    }  fprintf (xref_file, "PRC %s %d %s %d %d %s\n",	   filename(xf), lineno, declname(fndecl),	   (cur_scope != NULL ? cur_scope->lid : 0),	   ct, buf);}/* Output cross-reference info about an assignment to NAME.  */voidGNU_xref_assign(name)   tree name;{  XREF_FILE xf;  if (!doing_xref) return;  xf = find_file(input_filename);  if (xf == NULL) return;  gen_assign(xf, name);}static voidgen_assign(xf, name)   XREF_FILE xf;   tree name;{  const char *s;  s = NULL;  switch (TREE_CODE (name))    {    case IDENTIFIER_NODE :      s = IDENTIFIER_POINTER(name);      break;    case VAR_DECL :      s = declname(name);      break;    case COMPONENT_REF :      gen_assign(xf, TREE_OPERAND(name, 0));      gen_assign(xf, TREE_OPERAND(name, 1));      break;    case INDIRECT_REF :    case OFFSET_REF :    case ARRAY_REF :    case BUFFER_REF :      gen_assign(xf, TREE_OPERAND(name, 0));      break;    case COMPOUND_EXPR :      gen_assign(xf, TREE_OPERAND(name, 1));      break;      default :      break;    }  if (s != NULL)    fprintf(xref_file, "ASG %s %d %s\n", filename(xf), lineno, s);}static const char *classname (cls)     tree cls;{  if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 't')    cls = TYPE_NAME (cls);  if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 'd')    cls = DECL_NAME (cls);  if (cls && TREE_CODE (cls) == IDENTIFIER_NODE)    return IDENTIFIER_POINTER (cls);  return "?";}/* Output cross-reference info about a class hierarchy.   CLS is the class type of interest.  BASE is a baseclass   for CLS.  PUB and VIRT give the access info about   the class derivation.  FRND is nonzero iff BASE is a friend   of CLS.   ??? Needs to handle nested classes.  */voidGNU_xref_hier(cls, base, pub, virt, frnd)   tree cls;   tree base;   int pub;   int virt;   int frnd;{  XREF_FILE xf;  if (!doing_xref) return;  xf = find_file(input_filename);  if (xf == NULL) return;  fprintf(xref_file, "HIE %s %d %s %s %d %d %d\n",	  filename(xf), lineno, classname (cls), classname (base), 	  pub, virt, frnd);}/* Output cross-reference info about class members.  CLS   is the containing type; FLD is the class member.  */voidGNU_xref_member(cls, fld)   tree cls;   tree fld;{  XREF_FILE xf;  const char *prot;  int confg, pure;  const char *d;#ifdef XREF_SHORT_MEMBER_NAMES  int i;#endif  char buf[1024], bufa[1024];  if (!doing_xref) return;  xf = find_file(fld->decl.filename);  if (xf == NULL) return;  if (TREE_PRIVATE (fld)) prot = "PRIVATE";  else if (TREE_PROTECTED(fld)) prot = "PROTECTED";  else prot = "PUBLIC";  confg = 0;  if (TREE_CODE (fld) == FUNCTION_DECL && DECL_CONST_MEMFUNC_P(fld))    confg = 1;  else if (TREE_CODE (fld) == CONST_DECL)    confg = 1;  pure = 0;  if (TREE_CODE (fld) == FUNCTION_DECL && DECL_ABSTRACT_VIRTUAL_P(fld))    pure = 1;  d = IDENTIFIER_POINTER(cls);  sprintf(buf, "%d%s", (int) strlen(d), d);#ifdef XREF_SHORT_MEMBER_NAMES  i = strlen(buf);#endif  strcpy(bufa, declname(fld));#ifdef XREF_SHORT_MEMBER_NAMES  for (p = &bufa[1]; *p != 0; ++p)    {      if (p[0] == '_' && p[1] == '_' && p[2] >= '0' && p[2] <= '9') {	if (strncmp(&p[2], buf, i) == 0) *p = 0;	break;      }      else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && p[3] >= '0' && p[3] <= '9') {	if (strncmp(&p[3], buf, i) == 0) *p = 0;	break;      }    }#endif  fprintf(xref_file, "MEM %s %d %s %s %s %d %d %d %d %d %d %d\n",	  filename(xf), fld->decl.linenum, d,  bufa,  prot,	  (TREE_CODE (fld) == FUNCTION_DECL ? 0 : 1),	  (DECL_INLINE (fld) ? 1 : 0),	  (DECL_LANG_SPECIFIC(fld) && DECL_FRIEND_P(fld) ? 1 : 0),	  (DECL_VINDEX(fld) ? 1 : 0),	  (TREE_STATIC(fld) ? 1 : 0),	  pure, confg);}/* Find file entry given name.  */static XREF_FILEfind_file(name)   const char *name;{  XREF_FILE xf;  for (xf = all_files; xf != NULL; xf = xf->next) {    if (STREQL(name, xf->name)) break;  }  return xf;}/* Return filename for output purposes.  */static const char *filename(xf)   XREF_FILE xf;{  if (xf == NULL) {    last_file = NULL;    return "*";  }  if (last_file == xf) return "*";  last_file = xf;  return xf->outname;}/* Return function name for output purposes.  */static const char *fctname(fndecl)   tree fndecl;{  static char fctbuf[1024];  const char *s;  if (fndecl == NULL && last_fndecl == NULL) return "*";  if (fndecl == NULL)    {      last_fndecl = NULL;      return "*TOP*";    }  if (fndecl == last_fndecl) return "*";  last_fndecl = fndecl;  s = declname(fndecl);  s = fixname(s, fctbuf);  return s;}/* Return decl name for output purposes.  */static const char *declname(dcl)   tree dcl;{  if (DECL_NAME (dcl) == NULL) return "?";  if (DECL_ASSEMBLER_NAME (dcl))    return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (dcl));  else    return IDENTIFIER_POINTER (DECL_NAME (dcl));}/* Simplify a type string by removing unneeded parenthesis.  */static voidsimplify_type(typ)   char *typ;{  char *s;  int lvl, i;  i = strlen(typ);  while (i > 0 && ISSPACE((unsigned char) typ[i-1])) typ[--i] = 0;  if (i > 7 && STREQL(&typ[i-5], "const"))    {      typ[i-5] = 0;      i -= 5;    }  if (typ[i-1] != ')') return;  s = &typ[i-2];  lvl = 1;  while (*s != 0) {    if (*s == ')') ++lvl;    else if (*s == '(')      {	--lvl;	if (lvl == 0)	  {	    s[1] = ')';	    s[2] = 0;	    break;	  }      }    --s;  }  if (*s != 0 && s[-1] == ')')    {      --s;      --s;      if (*s == '(') s[2] = 0;      else if (*s == ':') {	while (*s != '(') --s;	s[1] = ')';	s[2] = 0;      }    }}/* Fixup a function name (take care of embedded spaces).  */static const char *fixname(nam, buf)   const char *nam;   char *buf;{  const char *s;  char *t;  int fg;  s = nam;  t = buf;  fg = 0;  while (*s != 0)    {      if (*s == ' ')	{	  *t++ = '\36';	  ++fg;	}      else *t++ = *s;      ++s;    }  *t = 0;  if (fg == 0) return nam;  return buf;}/* Open file for xreffing.  */static voidopen_xref_file(file)   const char *file;{  const char *s;  char *t;#ifdef XREF_FILE_NAME  XREF_FILE_NAME (xref_name, file);#else  s = rindex (file, '/');  if (s == NULL)    sprintf (xref_name, ".%s.gxref", file);  else    {      ++s;      strcpy (xref_name, file);      t = rindex (xref_name, '/');      ++t;      *t++ = '.';      strcpy (t, s);      strcat (t, ".gxref");    }#endif /* no XREF_FILE_NAME */  xref_file = fopen(xref_name, "w");  if (xref_file == NULL)    {      error("Can't create cross-reference file `%s'", xref_name);      doing_xref = 0;    }}

⌨️ 快捷键说明

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