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

📄 etoa_decode.c

📁 VxWorks BSP框架源代码包含头文件和驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
        /* Non-virtual function. */        /* The third component is a name preceded by its length, e.g.,           "1f".  Put out "&A::f", where "A" is the class type retrieved           from the type. */        write_id_ch('&', dctl);        /* Start at type+2 to skip the "C" for const and the "M" for           pointer-to-member. */        (void)demangle_type_name(type+2, dctl);        write_id_str("::", dctl);        /* Demangle the length and name. */        p = demangle_name_with_preceding_length(p, /*allow_member=*/FALSE,                                              (a_template_param_block_ptr)NULL,                                                dctl);      } else {        /* Not a non-virtual function.  The encoding for the third component           should be simply "0". */        if (*p != '0') {          bad_mangled_name(dctl);          goto end_of_routine;        }  /* if */        p++;        if (nchars == 1 && *index == '0') {          /* Null pointer constant.  Output "(type)0", that is, a zero cast             to the pointer-to-member type. */          write_id_ch('(', dctl);          (void)demangle_type(type, dctl);          write_id_str(")0", dctl);        } else {          /* Virtual function.  This case can't really be demangled properly,             because the mangled name doesn't have enough information.             Output "&A::virtual-function-n". */          write_id_ch('&', dctl);          /* Start at type+2 to skip the "C" for const and the "M" for             pointer-to-member. */          (void)demangle_type_name(type+2, dctl);          write_id_str("::", dctl);          write_id_str("virtual-function-", dctl);          /* Write the index number. */          for (; nchars > 0; nchars--, index++) write_id_ch(*index, dctl);        }  /* if */      }  /* if */    }  /* if */  } else if (*p == 'Z') {    /* A template parameter. */    p = demangle_template_parameter_name(p, /*nontype=*/TRUE, dctl);  } else if (*p == 'O') {    /* An operation. */    p = demangle_operation(p, dctl);  } else {    /* The constant starts with something unexpected. */    bad_mangled_name(dctl);  }  /* if */end_of_routine:  return p;}  /* demangle_constant */static char *demangle_operation(char                       *ptr,                                a_decode_control_block_ptr dctl)/*Demangle an operation in a constant expression (these come up in templatearguments and array sizes, in template function parameter lists) beginningat ptr, and output the demangled form.  Return a pointer to the characterposition following what was demangled.*/{  char          *p = ptr, *operator_str, *close_str = "";  int           op_length;  unsigned long num_operands;  a_boolean     takes_type;  /* An operation has the form       Opl2Z1ZZ2ZO <-- "Z1 + Z2", Z1/Z2 indicating nontype template parameters.                 ^---- "O" to end the operation encoding.              ^^^----- Second operand.           ^^^-------- First operand.          ^----------- Count of operands.        ^^------------ Operation, using same encoding as for operator                       function names.       ^-------------- "O" for operation.  */  p++;  /* Advance past the "O". */  /* Decode the operator name, e.g., "pl" is "+". */  operator_str = demangle_operator(p, &op_length, &takes_type);  if (operator_str == NULL) {    bad_mangled_name(dctl);  } else {    p += op_length;    /* Put parentheses around the operation. */    write_id_ch('(', dctl);    /* For a cast, sizeof, or __alignof__, get the type. */    if (takes_type) {      if (strcmp(operator_str, "cast") == 0) {        write_id_ch('(', dctl);        operator_str = "";      } else {        write_id_str(operator_str, dctl);      }  /* if */      if (*p == 'e') {        /* "e" indicates a sizeof (etc.) based on an expression.  Do not           scan the type.  Note that the expression is not present either. */        write_id_str("expr", dctl);        p++;      } else {        p = demangle_type(p, dctl);      }  /* if */      write_id_ch(')', dctl);    }  /* if */    /* Get the count of operands. */    p = get_single_digit_number(p, &num_operands, dctl);    /* sizeof and __alignof__ take zero operands. */    if (num_operands != 0) {      if (num_operands == 1) {        /* Unary operator -- operator comes first. */        write_id_str(operator_str, dctl);      }  /* if */      /* Process the first operand. */      p = demangle_constant(p, dctl);      if (num_operands > 1) {        /* Binary and ternary operators -- operator comes after first           operand. */        if (strcmp(operator_str, "[]") == 0) {          /* For subscripting, put one "[" between the operands and one             at the end. */          operator_str = "[";          close_str = "]";        }  /* if */        write_id_str(operator_str, dctl);        /* Process the second operand. */        p = demangle_constant(p, dctl);        if (num_operands > 2) {          /* Ternary operand -- "?". */          write_id_ch(':', dctl);          /* Process the third operand. */          p = demangle_constant(p, dctl);        }  /* if */      }  /* if */    }  /* if */    write_id_str(close_str, dctl);    write_id_ch(')', dctl);    /* Check for the final "O". */    if (*p != 'O') {      bad_mangled_name(dctl);    } else {      p++;    }  /* if */  }  /* if */  return p;}  /* demangle_operation */static void clear_template_param_block(a_template_param_block_ptr tpbp)/*Clear the fields of the indicated template parameter block.*/{  tpbp->nesting_level = 0;  tpbp->final_specialization = NULL;  tpbp->set_final_specialization = FALSE;  tpbp->actual_template_args_until_final_specialization = FALSE;  tpbp->output_only_correspondences = FALSE;  tpbp->first_correspondence = FALSE;  tpbp->use_old_form_for_template_output = FALSE;#if ENABLE_GNU_LIKE_OUTPUT  tpbp->base_name_only = FALSE;#endif}  /* clear_template_param_block */static char *demangle_template_arguments(                                      char                       *ptr,                                      a_boolean                  partial_spec,                                      a_template_param_block_ptr temp_par_info,                                      a_decode_control_block_ptr dctl)/*Demangle the template class arguments beginning at ptr and output thedemangled form.  Return a pointer to the character position following what wasdemangled.  ptr points to just past the "__tm__", "__ps__", or "__pt__"string.  partial_spec is TRUE if this is a partial-specializationparameter list ("__ps__").  When temp_par_info != NULL, it points to ablock that controls output of extra information on template parameters.*/{  char          *p = ptr, *arg_base;  unsigned long nchars, position;  a_boolean     nontype, skipped, unskipped;  if (temp_par_info != NULL && !partial_spec) temp_par_info->nesting_level++;  /* A template argument list looks like       __tm__3_ii               ^^---- Argument types.             ^------- Size of argument types, including the underscore.             ^------- ptr points here.     For the first argument list of a partial specialization, "__tm__" is     replaced by "__ps__".  For old-form mangling of templates, "__tm__"     is replaced by "__pt__".  */  write_id_ch('<', dctl);  /* Scan the size. */  p = get_length(p, &nchars, dctl);  arg_base = p;  p = advance_past_underscore(p, dctl);  /* Loop to process the arguments. */  for (position = 1;; position++) {    if (dctl->err_in_id) break;  /* Avoid infinite loops on errors. */    if (*p == '\0' || *p == '_') {      /* We ran off the end of the string. */      bad_mangled_name(dctl);      break;    }  /* if */    /* "X" identifies the beginning of a nontype argument. */    nontype = (*p == 'X');    skipped = unskipped = FALSE;    if (!partial_spec && temp_par_info != NULL &&        !temp_par_info->use_old_form_for_template_output &&        !temp_par_info->actual_template_args_until_final_specialization) {      /* Doing something special: writing out the template parameter name. */      if (temp_par_info->output_only_correspondences) {        /* This is the second pass, which writes out parameter/argument           correspondences, e.g., "T1=int".  Output has been suppressed           in general, and is turned on briefly here. */        dctl->suppress_id_output--;        unskipped = TRUE;        /* Put out a comma between entries and a left bracket preceding the           first entry. */        if (temp_par_info->first_correspondence) {          write_id_str(" [with ", dctl);          temp_par_info->first_correspondence = FALSE;        } else {          write_id_str(", ", dctl);        }  /* if */      }  /* if */      /* Write the template parameter name. */      write_template_parameter_name(temp_par_info->nesting_level, position,                                    nontype, dctl);      if (temp_par_info->output_only_correspondences) {        /* This is the second pass, to write out correspondences, so put the           argument value out after the parameter name. */        write_id_ch('=', dctl);      } else {        /* This is the first pass.  The argument value is skipped.  In           the second pass, its value will be written out. */        /* We still have to scan over the argument value, but suppress           output. */        dctl->suppress_id_output++;        skipped = TRUE;      }  /* if */    }  /* if */    /* Write the argument value. */    if (nontype) {      /* Nontype argument. */      char *saved_end_of_constant = dctl->end_of_constant;      p++;  /* Advance past the "X". */      /* Note the end position of the constant.  This is used to decide         that certain lengths are implausible as a way to resolve         ambiguities. */      dctl->end_of_constant = arg_base + nchars;      p = demangle_constant(p, dctl);      dctl->end_of_constant = saved_end_of_constant;    } else {      /* Type argument. */      p = demangle_type(p, dctl);    }  /* if */    if (skipped) dctl->suppress_id_output--;    if (unskipped) dctl->suppress_id_output++;    /* Stop after the last argument. */    if ((p - arg_base) >= nchars) break;    write_id_str(", ", dctl);  }  /* for */  write_id_ch('>', dctl);  return p;}  /* demangle_template_arguments */static char *demangle_operator(char      *ptr,                               int       *mangled_length,                               a_boolean *takes_type)/*Examine the first few characters at ptr to see if they are an encoding foran operator (e.g., "pl" for plus).  If so, return a pointer to a string forthe operator (e.g., "+"), set *mangled_length to the number of charactersin the encoding, and *takes_type to TRUE if the operator takes a typemodifier (e.g., cast).  If the first few characters are not an operatorencoding, return NULL.*/{  char *s;  int  len = 2;  *takes_type = FALSE;  /* The length-3 codes are tested first to avoid taking their first two     letters as one of the length-2 codes. */  if (start_of_id_is("apl", ptr)) {    s = "+=";    len = 3;  } else if (start_of_id_is("ami", ptr)) {    s = "-=";    len = 3;  } else if (start_of_id_is("amu", ptr)) {    s = "*=";    len = 3;  } else if (start_of_id_is("adv", ptr)) {    s = "/=";    len = 3;  } else if (start_of_id_is("amd", ptr)) {    s = "%=";    len = 3;  } else if (start_of_id_is("aer", ptr)) {    s = "^=";    len = 3;  } else if (start_of_id_is("aad", ptr)) {    s = "&=";    len = 3;  } else if (start_of_id_is("aor", ptr)) {    s = "|=";    len = 3;  } else if (start_of_id_is("ars", ptr)) {    s = ">>=";    len = 3;  } else if (start_of_id_is("als", ptr)) {    s = "<<=";    len = 3;  } else if (start_of_id_is("nwa", ptr)) {    s = "new[]";    len = 3;  } else if (start_of_id_is("dla", ptr)) {    s = "delete[]";    len = 3;  } else if (start_of_id_is("nw", ptr)) {    s = "new";  } else if (start_of_id_is("dl", ptr)) {    s = "delete";  } else if (start_of_id_is("pl", ptr)) {    s = "+";  } else if (start_of_id_is("mi", ptr)) {    s = "-";  } else if (start_of_id_is("ml", ptr)) {    s = "*";  } else if (start_of_id_is("dv", ptr)) {    s = "/";  } else if (start_of_id_is("md", ptr)) {    s = "%";  } else if (start_of_id_is("er", ptr)) {    s = "^";  } else if (start_of_id_is("ad", ptr)) {    s = "&";  } else if (start_of_id_is("or", ptr)) {    s = "|";  } else if (start_of_id_is("co", ptr)) {    s = "~";  } else if (start_of_id_is("nt", ptr)) {    s = "!";  } else if (start_of_id_is("as", ptr)) {    s = "=";  } else if (start_of_id_is("lt", ptr)) {    s = "<";  } else if (start_of_id_is("gt", ptr)) {

⌨️ 快捷键说明

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