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

📄 edg-decode.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
a block of information related to template parameter processing.*/{  if (temp_par_info != NULL) {    if (temp_par_info->set_final_specialization) {      /* Remember the location of the last specialization seen. */      temp_par_info->final_specialization = ptr;    } else if (temp_par_info->actual_template_args_until_final_specialization&&               ptr == temp_par_info->final_specialization) {      /* Stop doing the special processing for specializations when the         final specialization is reached. */      temp_par_info->actual_template_args_until_final_specialization = FALSE;    }  /* if */  }  /* if */}  /* note_specialization */static char get_char(char          *ptr,                     char          *base_ptr,                     unsigned long nchars)/*Get and return the character pointed to by ptr.  However, if nchars isnon-zero, the string from which the character is to be extracted startsat base_ptr and has length nchars.  An attempt to get a character pastthe end of the string returns a null character.*/{  char ch;  if (nchars > 0 && ptr >= base_ptr+nchars) {    ch = '\0';  } else {    ch = *ptr;  }  /* if */  return ch;}  /* get_char */static char *demangle_name(char                       *ptr,                           unsigned long              nchars,                           a_boolean                  stop_on_underscores,                           char                       *mclass,                           a_template_param_block_ptr temp_par_info,                           a_decode_control_block_ptr dctl)/*Demangle the name at ptr and output the demangled form.  Return a pointerto the character position following what was demangled.  A "name" isusually just a string of alphanumeric characters.  However, names ofconstructors, destructors, and operator functions require specialhandling, as do template entity names.  nchars indicates the numberof characters in the name, or is zero if the name is open-ended(it's ended by a null or double underscore).  A double underscoreends the name if stop_on_underscores is TRUE (though some sequencesbeginning with two underscores, e.g., "__pt", end the name even ifstop_on_underscores is FALSE).  mclass, when non-NULL, points tothe mangled form of the class of which this name is a member.When it's non-NULL, constructor and destructor names will be putout in the proper form (otherwise, they are left in their originalforms).  When temp_par_info != NULL, it points to a block thatcontrols output of extra information on template parameters.*/{  char      *p, *end_ptr = NULL;  a_boolean is_special_name = FALSE, is_pt, is_partial_spec = FALSE;  a_boolean partial_spec_output_suppressed = FALSE;  char      *demangled_name;  int       mangled_length;  /* See if the name is special in some way. */  if ((nchars == 0 || nchars >= 4) && ptr[0] == '_' && ptr[1] == '_') {    /* Name beginning with two underscores. */    p = ptr + 2;    if (start_of_id_is("ct", p)) {      /* Constructor. */      end_ptr = p + 2;      if (mclass == NULL) {        /* The mangled name for the class is not provided, so handle this as           a normal name. */      } else {        /* Output the class name for the constructor name. */        is_special_name = TRUE;        (void)full_demangle_type_name(mclass, /*base_name_only=*/TRUE,                                      /*temp_par_info=*/                                              (a_template_param_block_ptr)NULL,                                      dctl);      }  /* if */    } else if (start_of_id_is("dt", p)) {      /* Destructor. */      end_ptr = p + 2;      if (mclass == NULL) {        /* The mangled name for the class is not provided, so handle this as           a normal name. */      } else {        /* Output ~class-name for the destructor name. */        is_special_name = TRUE;        write_id_ch('~', dctl);        (void)full_demangle_type_name(mclass, /*base_name_only=*/TRUE,                                      /*temp_par_info=*/                                              (a_template_param_block_ptr)NULL,                                      dctl);      }  /* if */    } else if (start_of_id_is("op", p)) {      /* Conversion function.  Name looks like __opi__... where the part         after "op" encodes the type (e.g., "opi" is "operator int"). */      is_special_name = TRUE;      write_id_str("operator ", dctl);      end_ptr = demangle_type(p+2, dctl);    } else if (is_operator_function_name(p, &demangled_name,                                         &mangled_length)) {      /* Operator function. */      is_special_name = TRUE;      write_id_str("operator ", dctl);      write_id_str(demangled_name, dctl);      end_ptr = p + mangled_length;    } else if (nchars != 0 && start_of_id_is("N", p)) {      /* __Nxxxx: unnamed namespace name.  Put out "<unnamed>" and ignore         the characters after "__N". */      is_special_name = TRUE;      write_id_str("<unnamed>", dctl);      end_ptr = p + nchars - 2;    } else {      /* Something unrecognized. */    }  /* if */  }  /* if */  /* Here, end_ptr non-null means the end of the string has been found     already (because the name is special in some way). */  if (end_ptr == NULL) {    /* Not a special name. Find the end of the string and set end_ptr.       Also look for template-related things that terminate the name       earlier. */    for (p = ptr; ; p++) {      char ch = get_char(p, ptr, nchars);      /* Stop at the end of the string (real, or as indicated by nchars). */      if (ch == '\0') break;      /* Stop on a double underscore, but not one at the start of the string.         More than 2 underscores in a row does not terminate the string,         so that something like the name for "void f_()" (i.e., "f___Fv")         can be demangled successfully. */      if (ch == '_' && p != ptr &&          get_char(p+1, ptr, nchars) == '_' &&          get_char(p+2, ptr, nchars) != '_' &&          /* When stop_on_underscores is FALSE, stop only on "__tm", "__ps",             "__pt", or "__S".  Double underscores can appear in the middle             of some names, e.g., member names used as template arguments. */          (stop_on_underscores ||           (get_char(p+2, ptr, nchars) == 't' &&            get_char(p+3, ptr, nchars) == 'm') ||           (get_char(p+2, ptr, nchars) == 'p' &&            get_char(p+3, ptr, nchars) == 's') ||           (get_char(p+2, ptr, nchars) == 'p' &&            get_char(p+3, ptr, nchars) == 't') ||           get_char(p+2, ptr, nchars) == 'S')) {        break;      }  /* if */    }  /* for */    end_ptr = p;  }  /* if */  /* Here, end_ptr indicates the character after the end of the initial     part of the name. */  if (!is_special_name) {    /* Output the characters of the base name. */    for (p = ptr; p < end_ptr; p++) write_id_ch(*p, dctl);  }  /* if */  /* If there's a template argument list for a partial specialization     (beginning with "__ps__"), process it. */  if ((nchars == 0 || (end_ptr-ptr+6) < nchars) &&      start_of_id_is("__ps__", end_ptr)) {    /* Write the arguments.  This first argument list gives the arguments       that appear in the partial specialization declaration:         template <class T, class U> struct A { ... };         template <class T> struct A<T *, int> { ... };                                     ^^^^^^^^this argument list       This first argument list will be followed by another argument list       that gives the arguments according to the partial specialization.       For A<int *, int> according to the example above, the second       argument list is <int>.  The second argument list is scanned but       not put out, except when argument correspondences are output. */    end_ptr = demangle_template_arguments(end_ptr+6, /*partial_spec=*/TRUE,                                          temp_par_info, dctl);    note_specialization(end_ptr, temp_par_info);    is_partial_spec = TRUE;  }  /* if */  /* If there's a specialization indication ("__S"), ignore it. */  if (get_char(end_ptr, ptr, nchars)   == '_' &&      get_char(end_ptr+1, ptr, nchars) == '_' &&      get_char(end_ptr+2, ptr, nchars) == 'S') {    note_specialization(end_ptr, temp_par_info);    end_ptr += 3;  }  /* if */  /* If there's a template argument list (beginning with "__pt__" or "__tm__"),     process it. */  if ((nchars == 0 || (end_ptr-ptr+6) < nchars) &&      ((is_pt = start_of_id_is("__pt__", end_ptr)) ||       start_of_id_is("__tm__", end_ptr))) {    /* The "__pt__ form indicates an old-style mangled template name. */    if (is_pt && temp_par_info != NULL ) {      temp_par_info->use_old_form_for_template_output = TRUE;    }  /* if */    /* For the second argument list of a partial specialization,       process the argument list but suppress output. */    if (is_partial_spec && temp_par_info != NULL &&        !temp_par_info->output_only_correspondences) {      dctl->suppress_id_output++;      partial_spec_output_suppressed = TRUE;    }  /* if */    /* Write the arguments. */#ifndef WRS_ORIG					/* WRS LOCAL */    /* But not if we are printing an implicit Ctor/Dtor name! */    if (temp_par_info != NULL && temp_par_info->base_name_only)      dctl->suppress_id_output++;#endif    end_ptr = demangle_template_arguments(end_ptr+6, /*partial_spec=*/FALSE,                                          temp_par_info, dctl);#ifndef WRS_ORIG					/* WRS LOCAL */    if (temp_par_info != NULL && temp_par_info->base_name_only)      dctl->suppress_id_output--;#endif    if (partial_spec_output_suppressed) dctl->suppress_id_output--;    /* If there's a(nother) specialization indication ("__S"), ignore it. */    if (get_char(end_ptr, ptr, nchars)   == '_' &&        get_char(end_ptr+1, ptr, nchars) == '_' &&        get_char(end_ptr+2, ptr, nchars) == 'S') {      note_specialization(end_ptr, temp_par_info);      end_ptr += 3;    }  /* if */  }  /* if */  /* Check that we took exactly the characters we should have. */  if (((nchars != 0) ? (end_ptr-ptr == nchars) : (*end_ptr == '\0')) ||      (stop_on_underscores &&       get_char(end_ptr,   ptr, nchars) == '_' &&       get_char(end_ptr+1, ptr, nchars) == '_')) {    /* Okay. */  } else {    bad_mangled_name(dctl);  }  /* if */  return end_ptr;}  /* demangle_name */static char *demangle_function_local_indication(                                             char                       *ptr,                                             unsigned long              nchars,                                             a_decode_control_block_ptr dctl)/*Demangle the function name and block number in a function-local indication:    __L2__f__Fv               ^-- returned pointer points here          ^------- mangled function name       ^---------- block number within function (ptr points here on entry)ptr points to the character after the "__L".  If nchars is non-zero, itindicates the length of the string, starting from ptr.  Return a pointerto the character following the mangled function name.  Output a functionindication like "f(void)::".*/{  char          *p = ptr;  unsigned long block_number;  /* Get the block number. */  p = get_number(ptr, &block_number, dctl);  /* Check for the two underscores following the block number. */  if (p[0] != '_' || p[1] != '_') {    bad_mangled_name(dctl);  } else {    p += 2;  }  /* if */  /* Put out the function name. */  if (nchars != 0) nchars -= (p - ptr);  p = full_demangle_identifier(p, nchars, dctl);  /* Put out the block number if needed.  Block 0 is the top-level block     of the function, and need not be identified. */  if (block_number != 0) {    char buffer[30];    write_id_str("[block ", dctl);    (void)sprintf(buffer, "%lu", block_number);    write_id_str(buffer, dctl);    write_id_ch(']', dctl);  }  /* if */  write_id_str("::", dctl);  return p;}  /* demangle_function_local_indication */static char *demangle_name_with_preceding_length(                                   char                       *ptr,                                   a_template_param_block_ptr temp_par_info,                                   a_decode_control_block_ptr dctl)/*Demangle a name that is preceded by a length, e.g., "3abc" for the typename "abc".  Return a pointer to the character position following whatwas demangled.  When temp_par_info != NULL, it points to a block thatcontrols output of extra information on template parameters.*/{  char          *p = ptr;  char          *p2;  unsigned long nchars, nchars2;  a_boolean     has_function_local_info = FALSE;  /* Get the length. */  p = get_length(p, &nchars, dctl);  if (nchars >= 8) {    /* Look for a function-local indication, e.g., "__Ln__f" for block       "n" of function "f". */    for (p2 = p+1; p2+6 < p+nchars; p2++) {      if (p2[0] == '_' && p2[1] == '_' && p2[2] == 'L') {        has_function_local_info = TRUE;        nchars2 = nchars;        /* Set the length for the scan below to stop just before "__L". */        nchars = p2 - p;        p2 += 3;  /* Points to block number after "__L". */        nchars2 -= (p2 - p);        /* Scan and output the block number and function name. */        p2 = demangle_function_local_indication(p2, nchars2, dctl);        break;      }  /* if */    }  /* for */  }  /* if */  /* Demangle the name. */  p = demangle_name(p, nchars, /*stop_on_underscores=*/FALSE,                    (char *)NULL, temp_par_info, dctl);  if (has_function_local_info) p = p2;  return p;}  /* demangle_name_with_preceding_length */static char *demangle_simple_type_name(                                   char                       *ptr,                                   a_template_param_block_ptr temp_par_info,                                   a_decode_control_block_ptr dctl)/*Demangle a type name (or namespace name) consisting of a length followedby the name.  Return a pointer to the character position following whatwas demangled.  The name is not a nested name, but it can have templatearguments.  When temp_par_info != NULL, it points to a block thatcontrols output of extra information on template parameters.*/{  char *p = ptr;  if (*p == 'Z') {    /* A template parameter name. */    p = demangle_template_parameter_name(p, /*nontype=*/FALSE, dctl);  } else {    /* A simple mangled type name consists of digits indicating the length of       the name followed by the name itself, e.g., "3abc". */    p = demangle_name_with_preceding_length(p, temp_par_info, dctl);  }  /* if */  return p;}  /* demangle_simple_type_name */static char *full_demangle_type_name(char                       *ptr,

⌨️ 快捷键说明

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