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

📄 cp-demangle.c

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
    {    case DEMANGLE_COMPONENT_NAME:      printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s);      return;    case DEMANGLE_COMPONENT_TEMPLATE_PARAM:      printf ("template parameter %ld\n", dc->u.s_number.number);      return;    case DEMANGLE_COMPONENT_CTOR:      printf ("constructor %d\n", (int) dc->u.s_ctor.kind);      d_dump (dc->u.s_ctor.name, indent + 2);      return;    case DEMANGLE_COMPONENT_DTOR:      printf ("destructor %d\n", (int) dc->u.s_dtor.kind);      d_dump (dc->u.s_dtor.name, indent + 2);      return;    case DEMANGLE_COMPONENT_SUB_STD:      printf ("standard substitution %s\n", dc->u.s_string.string);      return;    case DEMANGLE_COMPONENT_BUILTIN_TYPE:      printf ("builtin type %s\n", dc->u.s_builtin.type->name);      return;    case DEMANGLE_COMPONENT_OPERATOR:      printf ("operator %s\n", dc->u.s_operator.op->name);      return;    case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:      printf ("extended operator with %d args\n",	      dc->u.s_extended_operator.args);      d_dump (dc->u.s_extended_operator.name, indent + 2);      return;    case DEMANGLE_COMPONENT_QUAL_NAME:      printf ("qualified name\n");      break;    case DEMANGLE_COMPONENT_LOCAL_NAME:      printf ("local name\n");      break;    case DEMANGLE_COMPONENT_TYPED_NAME:      printf ("typed name\n");      break;    case DEMANGLE_COMPONENT_TEMPLATE:      printf ("template\n");      break;    case DEMANGLE_COMPONENT_VTABLE:      printf ("vtable\n");      break;    case DEMANGLE_COMPONENT_VTT:      printf ("VTT\n");      break;    case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:      printf ("construction vtable\n");      break;    case DEMANGLE_COMPONENT_TYPEINFO:      printf ("typeinfo\n");      break;    case DEMANGLE_COMPONENT_TYPEINFO_NAME:      printf ("typeinfo name\n");      break;    case DEMANGLE_COMPONENT_TYPEINFO_FN:      printf ("typeinfo function\n");      break;    case DEMANGLE_COMPONENT_THUNK:      printf ("thunk\n");      break;    case DEMANGLE_COMPONENT_VIRTUAL_THUNK:      printf ("virtual thunk\n");      break;    case DEMANGLE_COMPONENT_COVARIANT_THUNK:      printf ("covariant thunk\n");      break;    case DEMANGLE_COMPONENT_JAVA_CLASS:      printf ("java class\n");      break;    case DEMANGLE_COMPONENT_GUARD:      printf ("guard\n");      break;    case DEMANGLE_COMPONENT_REFTEMP:      printf ("reference temporary\n");      break;    case DEMANGLE_COMPONENT_HIDDEN_ALIAS:      printf ("hidden alias\n");      break;    case DEMANGLE_COMPONENT_RESTRICT:      printf ("restrict\n");      break;    case DEMANGLE_COMPONENT_VOLATILE:      printf ("volatile\n");      break;    case DEMANGLE_COMPONENT_CONST:      printf ("const\n");      break;    case DEMANGLE_COMPONENT_RESTRICT_THIS:      printf ("restrict this\n");      break;    case DEMANGLE_COMPONENT_VOLATILE_THIS:      printf ("volatile this\n");      break;    case DEMANGLE_COMPONENT_CONST_THIS:      printf ("const this\n");      break;    case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:      printf ("vendor type qualifier\n");      break;    case DEMANGLE_COMPONENT_POINTER:      printf ("pointer\n");      break;    case DEMANGLE_COMPONENT_REFERENCE:      printf ("reference\n");      break;    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:      printf ("rvalue reference\n");      break;    case DEMANGLE_COMPONENT_COMPLEX:      printf ("complex\n");      break;    case DEMANGLE_COMPONENT_IMAGINARY:      printf ("imaginary\n");      break;    case DEMANGLE_COMPONENT_VENDOR_TYPE:      printf ("vendor type\n");      break;    case DEMANGLE_COMPONENT_FUNCTION_TYPE:      printf ("function type\n");      break;    case DEMANGLE_COMPONENT_ARRAY_TYPE:      printf ("array type\n");      break;    case DEMANGLE_COMPONENT_PTRMEM_TYPE:      printf ("pointer to member type\n");      break;    case DEMANGLE_COMPONENT_ARGLIST:      printf ("argument list\n");      break;    case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:      printf ("template argument list\n");      break;    case DEMANGLE_COMPONENT_CAST:      printf ("cast\n");      break;    case DEMANGLE_COMPONENT_UNARY:      printf ("unary operator\n");      break;    case DEMANGLE_COMPONENT_BINARY:      printf ("binary operator\n");      break;    case DEMANGLE_COMPONENT_BINARY_ARGS:      printf ("binary operator arguments\n");      break;    case DEMANGLE_COMPONENT_TRINARY:      printf ("trinary operator\n");      break;    case DEMANGLE_COMPONENT_TRINARY_ARG1:      printf ("trinary operator arguments 1\n");      break;    case DEMANGLE_COMPONENT_TRINARY_ARG2:      printf ("trinary operator arguments 1\n");      break;    case DEMANGLE_COMPONENT_LITERAL:      printf ("literal\n");      break;    case DEMANGLE_COMPONENT_LITERAL_NEG:      printf ("negative literal\n");      break;    case DEMANGLE_COMPONENT_JAVA_RESOURCE:      printf ("java resource\n");      break;    case DEMANGLE_COMPONENT_COMPOUND_NAME:      printf ("compound name\n");      break;    case DEMANGLE_COMPONENT_CHARACTER:      printf ("character '%c'\n",  dc->u.s_character.character);      return;    }  d_dump (d_left (dc), indent + 2);  d_dump (d_right (dc), indent + 2);}#endif /* CP_DEMANGLE_DEBUG *//* Fill in a DEMANGLE_COMPONENT_NAME.  */CP_STATIC_IF_GLIBCPP_V3intcplus_demangle_fill_name (struct demangle_component *p, const char *s, int len){  if (p == NULL || s == NULL || len == 0)    return 0;  p->type = DEMANGLE_COMPONENT_NAME;  p->u.s_name.s = s;  p->u.s_name.len = len;  return 1;}/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR.  */CP_STATIC_IF_GLIBCPP_V3intcplus_demangle_fill_extended_operator (struct demangle_component *p, int args,                                       struct demangle_component *name){  if (p == NULL || args < 0 || name == NULL)    return 0;  p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR;  p->u.s_extended_operator.args = args;  p->u.s_extended_operator.name = name;  return 1;}/* Fill in a DEMANGLE_COMPONENT_CTOR.  */CP_STATIC_IF_GLIBCPP_V3intcplus_demangle_fill_ctor (struct demangle_component *p,                          enum gnu_v3_ctor_kinds kind,                          struct demangle_component *name){  if (p == NULL      || name == NULL      || (kind < gnu_v3_complete_object_ctor	  && kind > gnu_v3_complete_object_allocating_ctor))    return 0;  p->type = DEMANGLE_COMPONENT_CTOR;  p->u.s_ctor.kind = kind;  p->u.s_ctor.name = name;  return 1;}/* Fill in a DEMANGLE_COMPONENT_DTOR.  */CP_STATIC_IF_GLIBCPP_V3intcplus_demangle_fill_dtor (struct demangle_component *p,                          enum gnu_v3_dtor_kinds kind,                          struct demangle_component *name){  if (p == NULL      || name == NULL      || (kind < gnu_v3_deleting_dtor	  && kind > gnu_v3_base_object_dtor))    return 0;  p->type = DEMANGLE_COMPONENT_DTOR;  p->u.s_dtor.kind = kind;  p->u.s_dtor.name = name;  return 1;}/* Add a new component.  */static struct demangle_component *d_make_empty (struct d_info *di){  struct demangle_component *p;  if (di->next_comp >= di->num_comps)    return NULL;  p = &di->comps[di->next_comp];  ++di->next_comp;  return p;}/* Add a new generic component.  */static struct demangle_component *d_make_comp (struct d_info *di, enum demangle_component_type type,             struct demangle_component *left,             struct demangle_component *right){  struct demangle_component *p;  /* We check for errors here.  A typical error would be a NULL return     from a subroutine.  We catch those here, and return NULL     upward.  */  switch (type)    {      /* These types require two parameters.  */    case DEMANGLE_COMPONENT_QUAL_NAME:    case DEMANGLE_COMPONENT_LOCAL_NAME:    case DEMANGLE_COMPONENT_TYPED_NAME:    case DEMANGLE_COMPONENT_TEMPLATE:    case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:    case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:    case DEMANGLE_COMPONENT_PTRMEM_TYPE:    case DEMANGLE_COMPONENT_UNARY:    case DEMANGLE_COMPONENT_BINARY:    case DEMANGLE_COMPONENT_BINARY_ARGS:    case DEMANGLE_COMPONENT_TRINARY:    case DEMANGLE_COMPONENT_TRINARY_ARG1:    case DEMANGLE_COMPONENT_TRINARY_ARG2:    case DEMANGLE_COMPONENT_LITERAL:    case DEMANGLE_COMPONENT_LITERAL_NEG:    case DEMANGLE_COMPONENT_COMPOUND_NAME:      if (left == NULL || right == NULL)	return NULL;      break;      /* These types only require one parameter.  */    case DEMANGLE_COMPONENT_VTABLE:    case DEMANGLE_COMPONENT_VTT:    case DEMANGLE_COMPONENT_TYPEINFO:    case DEMANGLE_COMPONENT_TYPEINFO_NAME:    case DEMANGLE_COMPONENT_TYPEINFO_FN:    case DEMANGLE_COMPONENT_THUNK:    case DEMANGLE_COMPONENT_VIRTUAL_THUNK:    case DEMANGLE_COMPONENT_COVARIANT_THUNK:    case DEMANGLE_COMPONENT_JAVA_CLASS:    case DEMANGLE_COMPONENT_GUARD:    case DEMANGLE_COMPONENT_REFTEMP:    case DEMANGLE_COMPONENT_HIDDEN_ALIAS:    case DEMANGLE_COMPONENT_POINTER:    case DEMANGLE_COMPONENT_REFERENCE:    case DEMANGLE_COMPONENT_RVALUE_REFERENCE:    case DEMANGLE_COMPONENT_COMPLEX:    case DEMANGLE_COMPONENT_IMAGINARY:    case DEMANGLE_COMPONENT_VENDOR_TYPE:    case DEMANGLE_COMPONENT_ARGLIST:    case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST:    case DEMANGLE_COMPONENT_CAST:    case DEMANGLE_COMPONENT_JAVA_RESOURCE:      if (left == NULL)	return NULL;      break;      /* This needs a right parameter, but the left parameter can be	 empty.  */    case DEMANGLE_COMPONENT_ARRAY_TYPE:      if (right == NULL)	return NULL;      break;      /* These are allowed to have no parameters--in some cases they	 will be filled in later.  */    case DEMANGLE_COMPONENT_FUNCTION_TYPE:    case DEMANGLE_COMPONENT_RESTRICT:    case DEMANGLE_COMPONENT_VOLATILE:    case DEMANGLE_COMPONENT_CONST:    case DEMANGLE_COMPONENT_RESTRICT_THIS:    case DEMANGLE_COMPONENT_VOLATILE_THIS:    case DEMANGLE_COMPONENT_CONST_THIS:      break;      /* Other types should not be seen here.  */    default:      return NULL;    }  p = d_make_empty (di);  if (p != NULL)    {      p->type = type;      p->u.s_binary.left = left;      p->u.s_binary.right = right;    }  return p;}/* Add a new name component.  */static struct demangle_component *d_make_name (struct d_info *di, const char *s, int len){  struct demangle_component *p;  p = d_make_empty (di);  if (! cplus_demangle_fill_name (p, s, len))    return NULL;  return p;}/* Add a new builtin type component.  */static struct demangle_component *d_make_builtin_type (struct d_info *di,                     const struct demangle_builtin_type_info *type){  struct demangle_component *p;  if (type == NULL)    return NULL;  p = d_make_empty (di);  if (p != NULL)    {      p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;      p->u.s_builtin.type = type;    }  return p;}/* Add a new operator component.  */static struct demangle_component *d_make_operator (struct d_info *di, const struct demangle_operator_info *op){  struct demangle_component *p;  p = d_make_empty (di);  if (p != NULL)    {      p->type = DEMANGLE_COMPONENT_OPERATOR;      p->u.s_operator.op = op;    }  return p;}/* Add a new extended operator component.  */static struct demangle_component *d_make_extended_operator (struct d_info *di, int args,                          struct demangle_component *name){  struct demangle_component *p;  p = d_make_empty (di);  if (! cplus_demangle_fill_extended_operator (p, args, name))    return NULL;  return p;}/* Add a new constructor component.  */static struct demangle_component *d_make_ctor (struct d_info *di, enum gnu_v3_ctor_kinds kind,             struct demangle_component *name){  struct demangle_component *p;  p = d_make_empty (di);  if (! cplus_demangle_fill_ctor (p, kind, name))    return NULL;  return p;}/* Add a new destructor component.  */static struct demangle_component *d_make_dtor (struct d_info *di, enum gnu_v3_dtor_kinds kind,             struct demangle_component *name){  struct demangle_component *p;  p = d_make_empty (di);  if (! cplus_demangle_fill_dtor (p, kind, name))    return NULL;  return p;}/* Add a new template parameter.  */static struct demangle_component *d_make_template_param (struct d_info *di, long i){  struct demangle_component *p;  p = d_make_empty (di);  if (p != NULL)    {      p->type = DEMANGLE_COMPONENT_TEMPLATE_PARAM;      p->u.s_number.number = i;    }  return p;}/* Add a new standard substitution component.  */static struct demangle_component *d_make_sub (struct d_info *di, const char *name, int len){  struct demangle_component *p;  p = d_make_empty (di);  if (p != NULL)    {      p->type = DEMANGLE_COMPONENT_SUB_STD;      p->u.s_string.string = name;      p->u.s_string.len = len;    }  return p;}/* <mangled-name> ::= _Z <encoding>   TOP_LEVEL is non-zero when called at the top level.  */CP_STATIC_IF_GLIBCPP_V3struct demangle_component *cplus_demangle_mangled_name (struct d_info *di, int top_level){  if (! d_check_char (di, '_'))    return NULL;

⌨️ 快捷键说明

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