osprey/libiberty/cp-demangle.c File Reference

#include <sys/types.h>
#include <stdio.h>
#include <ctype.h>
#include "ansidecl.h"
#include "libiberty.h"
#include "dyn-string.h"
#include "demangle.h"

Include dependency graph for cp-demangle.c:

Go to the source code of this file.

Data Types

type  string_list_def
type  substitution_def
type  template_arg_list_def
type  demangling_def

Defines

#define DEMANGLE_TRACE(PRODUCTION, DM)
#define IS_DIGIT(CHAR)   ((CHAR) >= '0' && (CHAR) <= '9')
#define IS_ALPHA(CHAR)
#define ANONYMOUS_NAMESPACE_PREFIX   "_GLOBAL_"
#define NAMESPACE_SEPARATOR   (dm->style == DMGL_JAVA ? "." : "::")
#define STATUS_OK   NULL
#define STATUS_ERROR   "Error."
#define STATUS_UNIMPLEMENTED   "Unimplemented."
#define STATUS_INTERNAL_ERROR   "Internal error."
#define STATUS_ALLOCATION_FAILED   status_allocation_failed
#define STATUS_NO_ERROR(STATUS)   ((STATUS) == STATUS_OK)
#define RETURN_IF_ERROR(EXPR)
#define dyn_string_last_char(DS)   (dyn_string_buf (DS)[dyn_string_length (DS) - 1])
#define dyn_string_append_space(DS)
#define current_position(DM)   ((DM)->next - (DM)->name)
#define peek_char(DM)   (*((DM)->next))
#define peek_char_next(DM)   (peek_char (DM) == '\0' ? '\0' : (*((DM)->next + 1)))
#define next_char(DM)   (*((DM)->next)++)
#define end_of_name_p(DM)   (peek_char (DM) == '\0')
#define advance_char(DM)   (++(DM)->next)
#define result_string(DM)   (&(DM)->result->string)
#define result_caret_pos(DM)
#define result_add_string(DM, STRING)
#define result_add(DM, CSTR)
#define result_add_char(DM, CHAR)
#define result_insert_string(DM, POS, STRING)
#define result_insert(DM, POS, CSTR)
#define result_insert_char(DM, POS, CHAR)
#define result_length(DM)   dyn_string_length (&(DM)->result->string)
#define result_open_template_list(DM)   result_add_separated_char(DM, '<')
#define result_close_template_list(DM)   result_add_separated_char(DM, '>')
#define BFT_NO_RETURN_TYPE   NULL

Typedefs

typedef struct string_list_defstring_list_t
typedef struct
template_arg_list_def
template_arg_list_t
typedef struct demangling_defdemangling_t
typedef const char * status_t

Functions/Subroutines

static status_t int_to_dyn_string PARAMS ((int, dyn_string_t))
static string_list_t
string_list_new 
PARAMS ((int))
static void string_list_delete PARAMS ((string_list_t))
static status_t
result_add_separated_char 
PARAMS ((demangling_t, int))
static status_t result_push PARAMS ((demangling_t))
static status_t substitution_add PARAMS ((demangling_t, int, int))
static dyn_string_t
substitution_get 
PARAMS ((demangling_t, int, int *))
static template_arg_list_t
template_arg_list_new 
PARAMS ((void))
static void
template_arg_list_delete 
PARAMS ((template_arg_list_t))
static void
template_arg_list_add_arg 
PARAMS ((template_arg_list_t, string_list_t))
static string_list_t
template_arg_list_get_arg 
PARAMS ((template_arg_list_t, int))
static void push_template_arg_list PARAMS ((demangling_t, template_arg_list_t))
static demangling_t demangling_new PARAMS ((const char *, int))
static status_t int_to_dyn_string (int value, dyn_string_t ds)
static string_list_t string_list_new (int length)
static void string_list_delete (string_list_t node)
static status_t result_add_separated_char (demangling_t dm, int character)
static status_t result_push (demangling_t dm)
static string_list_t result_pop (demangling_t dm)
static int result_get_caret (demangling_t dm)
static void result_set_caret (demangling_t dm, int position)
static void result_shift_caret (demangling_t dm, int position_offset)
static int result_previous_char_is_space (demangling_t dm)
static int substitution_start (demangling_t dm)
static status_t substitution_add (demangling_t dm, int start_position, int template_p)
static dyn_string_t substitution_get (demangling_t dm, int n, int *template_p)
static template_arg_list_t template_arg_list_new ()
static void template_arg_list_delete (template_arg_list_t list)
static void template_arg_list_add_arg (template_arg_list_t arg_list, string_list_t arg)
static string_list_t template_arg_list_get_arg (template_arg_list_t arg_list, int index)
static void push_template_arg_list (demangling_t dm, template_arg_list_t arg_list)
static void pop_to_template_arg_list (demangling_t dm, template_arg_list_t arg_list)
static template_arg_list_t current_template_arg_list (demangling_t dm)
static demangling_t demangling_new (char *name, int style) const
static void demangling_delete (demangling_t dm)
static status_t demangle_name PARAMS ((demangling_t, int *))
static status_t demangle_number PARAMS ((demangling_t, int *, int, int))
static status_t
demangle_number_literally 
PARAMS ((demangling_t, dyn_string_t, int, int))
static status_t demangle_identifier PARAMS ((demangling_t, int, dyn_string_t))
static status_t
demangle_operator_name 
PARAMS ((demangling_t, int, int *, int *))
static status_t demangle_type_ptr PARAMS ((demangling_t, int *, int))
static status_t
demangle_CV_qualifiers 
PARAMS ((demangling_t, dyn_string_t))
static status_t cp_demangle PARAMS ((const char *, dyn_string_t, int))
static status_t cp_demangle_type PARAMS ((const char *, dyn_string_t))
static status_t demangle_char (demangling_t dm, int c)
static status_t demangle_mangled_name (demangling_t dm)
static status_t demangle_encoding (demangling_t dm)
static status_t demangle_name (demangling_t dm, int *encode_return_type)
static status_t demangle_nested_name (demangling_t dm, int *encode_return_type)
static status_t demangle_prefix (demangling_t dm, int *encode_return_type)
static status_t demangle_unqualified_name (demangling_t dm, int *suppress_return_type)
static status_t demangle_source_name (demangling_t dm)
static status_t demangle_number (demangling_t dm, int *value, int base, int is_signed)
static status_t demangle_number_literally (demangling_t dm, dyn_string_t str, int base, int is_signed)
static status_t demangle_identifier (demangling_t dm, int length, dyn_string_t identifier)
static status_t demangle_operator_name (demangling_t dm, int short_name, int *num_args, int *type_arg)
static status_t demangle_nv_offset (demangling_t dm)
static status_t demangle_v_offset (demangling_t dm)
static status_t demangle_call_offset (demangling_t dm)
static status_t demangle_special_name (demangling_t dm)
static status_t demangle_ctor_dtor_name (demangling_t dm)
static status_t demangle_type_ptr (demangling_t dm, int *insert_pos, int substitution_start)
static status_t demangle_type (demangling_t dm)
static status_t demangle_builtin_type (demangling_t dm)
static status_t demangle_CV_qualifiers (demangling_t dm, dyn_string_t qualifiers)
static status_t demangle_function_type (demangling_t dm, int *function_name_pos)
static status_t demangle_bare_function_type (demangling_t dm, int *return_type_pos)
static status_t demangle_class_enum_type (demangling_t dm, int *encode_return_type)
static status_t demangle_array_type (demangling_t dm, int *ptr_insert_pos)
static status_t demangle_template_param (demangling_t dm)
static status_t demangle_template_args (demangling_t dm)
static status_t demangle_literal (demangling_t dm)
static status_t demangle_template_arg (demangling_t dm)
static status_t demangle_expression (demangling_t dm)
static status_t demangle_scope_expression (demangling_t dm)
static status_t demangle_expr_primary (demangling_t dm)
static status_t demangle_substitution (demangling_t dm, int *template_p)
static status_t demangle_local_name (demangling_t dm)
static status_t demangle_discriminator (demangling_t dm, int suppress_first)
static status_t cp_demangle (char *name, dyn_string_t result, int style) const
static status_t cp_demangle_type (char *type_name, dyn_string_t result) const
char * cplus_demangle_v3 (char *mangled, int options) const
char * java_demangle_v3 (char *mangled) const
static demangling_t demangle_v3_with_details (char *name) const
enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (char *name) const
enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (char *name) const

Variables

static int flag_verbose
static int flag_strict
static const char *const status_allocation_failed = "Allocation failed."
static const char *const builtin_type_names [26]
static const char *const java_builtin_type_names [26]


Define Documentation

#define advance_char ( DM   )     (++(DM)->next)

#define ANONYMOUS_NAMESPACE_PREFIX   "_GLOBAL_"

Definition at line 84 of file cp-demangle.c.

#define BFT_NO_RETURN_TYPE   NULL

Definition at line 961 of file cp-demangle.c.

Referenced by demangle_bare_function_type(), and demangle_encoding().

#define current_position ( DM   )     ((DM)->next - (DM)->name)

Definition at line 290 of file cp-demangle.c.

#define DEMANGLE_TRACE ( PRODUCTION,
DM   ) 

#define dyn_string_append_space ( DS   ) 

Value:

((dyn_string_length (DS) > 0                                      \
        && dyn_string_last_char (DS) != ' ')                            \
       ? dyn_string_append_char ((DS), ' ')                             \
       : 1)

Definition at line 283 of file cp-demangle.c.

Referenced by demangle_bare_function_type(), and demangle_CV_qualifiers().

#define dyn_string_last_char ( DS   )     (dyn_string_buf (DS)[dyn_string_length (DS) - 1])

Definition at line 278 of file cp-demangle.c.

#define end_of_name_p ( DM   )     (peek_char (DM) == '\0')

#define IS_ALPHA ( CHAR   ) 

Value:

(((CHAR) >= 'a' && (CHAR) <= 'z')                                     \
   || ((CHAR) >= 'A' && (CHAR) <= 'Z'))

Definition at line 78 of file cp-demangle.c.

#define IS_DIGIT ( CHAR   )     ((CHAR) >= '0' && (CHAR) <= '9')

Definition at line 77 of file cp-demangle.c.

#define NAMESPACE_SEPARATOR   (dm->style == DMGL_JAVA ? "." : "::")

Definition at line 87 of file cp-demangle.c.

Referenced by demangle_prefix().

#define next_char ( DM   )     (*((DM)->next)++)

#define peek_char ( DM   )     (*((DM)->next))

#define peek_char_next ( DM   )     (peek_char (DM) == '\0' ? '\0' : (*((DM)->next + 1)))

#define result_add ( DM,
CSTR   ) 

#define result_add_char ( DM,
CHAR   ) 

#define result_add_string ( DM,
STRING   ) 

#define result_caret_pos ( DM   ) 

#define result_close_template_list ( DM   )     result_add_separated_char(DM, '>')

Definition at line 363 of file cp-demangle.c.

Referenced by demangle_template_args().

#define result_insert ( DM,
POS,
CSTR   ) 

Value:

(dyn_string_insert_cstr (&(DM)->result->string, (POS), (CSTR))        \
   ? STATUS_OK : STATUS_ALLOCATION_FAILED)

Definition at line 345 of file cp-demangle.c.

Referenced by demangle_type_ptr().

#define result_insert_char ( DM,
POS,
CHAR   ) 

Value:

Definition at line 350 of file cp-demangle.c.

Referenced by demangle_type_ptr().

#define result_insert_string ( DM,
POS,
STRING   ) 

Value:

Definition at line 339 of file cp-demangle.c.

Referenced by demangle_type_ptr().

#define result_length ( DM   )     dyn_string_length (&(DM)->result->string)

Definition at line 355 of file cp-demangle.c.

Referenced by ffecom_gen_sfuncdef_(), and sxt_sequence().

#define result_open_template_list ( DM   )     result_add_separated_char(DM, '<')

Definition at line 362 of file cp-demangle.c.

Referenced by demangle_template_args().

#define result_string ( DM   )     (&(DM)->result->string)

#define RETURN_IF_ERROR ( EXPR   ) 

#define STATUS_ALLOCATION_FAILED   status_allocation_failed

#define STATUS_ERROR   "Error."

#define STATUS_INTERNAL_ERROR   "Internal error."

Definition at line 211 of file cp-demangle.c.

Referenced by demangle_number_literally().

#define STATUS_NO_ERROR ( STATUS   )     ((STATUS) == STATUS_OK)

#define STATUS_OK   NULL

#define STATUS_UNIMPLEMENTED   "Unimplemented."

Definition at line 210 of file cp-demangle.c.

Referenced by demangle_literal().


Typedef Documentation

Definition at line 201 of file cp-demangle.c.

typedef const char* status_t

Definition at line 205 of file cp-demangle.c.

Definition at line 119 of file cp-demangle.c.

Definition at line 148 of file cp-demangle.c.


Function Documentation

static status_t cp_demangle ( char *  name,
dyn_string_t  result,
int  style 
) const [static]

static status_t cp_demangle_type ( char*  type_name,
dyn_string_t  result 
) const [static]

char* cplus_demangle_v3 ( char*  mangled,
int  options 
) const

static template_arg_list_t current_template_arg_list ( demangling_t  dm  )  [static]

static status_t demangle_array_type ( demangling_t  dm,
int *  ptr_insert_pos 
) [static]

static status_t demangle_bare_function_type ( demangling_t  dm,
int *  return_type_pos 
) [static]

static status_t demangle_builtin_type ( demangling_t  dm  )  [static]

static status_t demangle_call_offset ( demangling_t  dm  )  [static]

static status_t demangle_char ( demangling_t  dm,
int  c 
) [static]

static status_t demangle_class_enum_type ( demangling_t  dm,
int *  encode_return_type 
) [static]

Definition at line 2845 of file cp-demangle.c.

References demangle_name(), DEMANGLE_TRACE, RETURN_IF_ERROR, and STATUS_OK.

Referenced by demangle_type().

static status_t demangle_ctor_dtor_name ( demangling_t  dm  )  [static]

static status_t demangle_CV_qualifiers ( demangling_t  dm,
dyn_string_t  qualifiers 
) [static]

static status_t demangle_discriminator ( demangling_t  dm,
int  suppress_first 
) [static]

static status_t demangle_encoding ( demangling_t  dm  )  [static]

static status_t demangle_expr_primary ( demangling_t  dm  )  [static]

static status_t demangle_expression ( demangling_t  dm  )  [static]

static status_t demangle_function_type ( demangling_t  dm,
int *  function_name_pos 
) [static]

static status_t demangle_identifier ( demangling_t  dm,
int  length,
dyn_string_t  identifier 
) [static]

static status_t demangle_literal ( demangling_t  dm  )  [static]

static status_t demangle_local_name ( demangling_t  dm  )  [static]

static status_t demangle_mangled_name ( demangling_t  dm  )  [static]

static status_t demangle_name ( demangling_t  dm,
int *  encode_return_type 
) [static]

static status_t demangle_nested_name ( demangling_t  dm,
int *  encode_return_type 
) [static]

static status_t demangle_number ( demangling_t  dm,
int *  value,
int  base,
int  is_signed 
) [static]

static status_t demangle_number_literally ( demangling_t  dm,
dyn_string_t  str,
int  base,
int  is_signed 
) [static]

static status_t demangle_nv_offset ( demangling_t  dm  )  [static]

static status_t demangle_operator_name ( demangling_t  dm,
int  short_name,
int *  num_args,
int *  type_arg 
) [static]

static status_t demangle_prefix ( demangling_t  dm,
int *  encode_return_type 
) [static]

static status_t demangle_scope_expression ( demangling_t  dm  )  [static]

static status_t demangle_source_name ( demangling_t  dm  )  [static]

static status_t demangle_special_name ( demangling_t  dm  )  [static]

static status_t demangle_substitution ( demangling_t  dm,
int *  template_p 
) [static]

static status_t demangle_template_arg ( demangling_t  dm  )  [static]

static status_t demangle_template_args ( demangling_t  dm  )  [static]

static status_t demangle_template_param ( demangling_t  dm  )  [static]

static status_t demangle_type ( demangling_t  dm  )  [static]

static status_t demangle_type_ptr ( demangling_t  dm,
int *  insert_pos,
int  substitution_start 
) [static]

static status_t demangle_unqualified_name ( demangling_t  dm,
int *  suppress_return_type 
) [static]

static demangling_t demangle_v3_with_details ( char *  name  )  const [static]

static status_t demangle_v_offset ( demangling_t  dm  )  [static]

static void demangling_delete ( demangling_t  dm  )  [static]

static demangling_t demangling_new ( char *  name,
int  style 
) const [static]

static status_t int_to_dyn_string ( int  value,
dyn_string_t  ds 
) [static]

Definition at line 369 of file cp-demangle.c.

References digit, dyn_string_append_char(), i, STATUS_ALLOCATION_FAILED, and STATUS_OK.

Referenced by demangle_discriminator().

enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor ( char *  name  )  const

enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor ( char *  name  )  const

char* java_demangle_v3 ( char*  mangled  )  const

static status_t cp_demangle_type PARAMS ( (const char *, dyn_string_t  )  [static]

static status_t cp_demangle PARAMS ( (const char *, dyn_string_t, int)   )  [static]

static status_t demangle_CV_qualifiers PARAMS ( (demangling_t, dyn_string_t  )  [static]

static status_t demangle_type_ptr PARAMS ( (demangling_t, int *, int)   )  [static]

static status_t demangle_operator_name PARAMS ( (demangling_t, int, int *, int *)   )  [static]

static status_t demangle_identifier PARAMS ( (demangling_t, int, dyn_string_t  )  [static]

static status_t demangle_number_literally PARAMS ( (demangling_t, dyn_string_t, int, int)   )  [static]

static status_t demangle_number PARAMS ( (demangling_t, int *, int, int)   )  [static]

static status_t demangle_name PARAMS ( (demangling_t, int *)   )  [static]

static demangling_t demangling_new PARAMS ( (const char *, int)   )  [static]

static void push_template_arg_list PARAMS ( (demangling_t, template_arg_list_t  )  [static]

static string_list_t template_arg_list_get_arg PARAMS ( (template_arg_list_t, int)   )  [static]

static void template_arg_list_add_arg PARAMS ( (template_arg_list_t, string_list_t  )  [static]

static void template_arg_list_delete PARAMS ( (template_arg_list_t  )  [static]

static template_arg_list_t template_arg_list_new PARAMS ( (void  )  [static, read]

Definition at line 77 of file cplus-dem.c.

static dyn_string_t substitution_get PARAMS ( (demangling_t, int, int *)   )  [static]

static status_t substitution_add PARAMS ( (demangling_t, int, int)   )  [static]

static status_t result_push PARAMS ( (demangling_t  )  [static]

static status_t result_add_separated_char PARAMS ( (demangling_t, int)   )  [static]

static void string_list_delete PARAMS ( (string_list_t  )  [static]

static string_list_t string_list_new PARAMS ( (int)   )  [static]

static status_t int_to_dyn_string PARAMS ( (int, dyn_string_t  )  [static]

static void pop_to_template_arg_list ( demangling_t  dm,
template_arg_list_t  arg_list 
) [static]

static void push_template_arg_list ( demangling_t  dm,
template_arg_list_t  arg_list 
) [static]

Definition at line 741 of file cp-demangle.c.

References fprintf(), and template_arg_list_def::next.

Referenced by demangle_template_args().

static status_t result_add_separated_char ( demangling_t  dm,
int  character 
) [static]

static int result_get_caret ( demangling_t  dm  )  [static]

Definition at line 505 of file cp-demangle.c.

References result_string.

Referenced by demangle_type().

static string_list_t result_pop ( demangling_t  dm  )  [static]

static int result_previous_char_is_space ( demangling_t  dm  )  [static]

Definition at line 538 of file cp-demangle.c.

References dyn_string_buf, pos(), result, result_caret_pos, and result_string.

Referenced by demangle_type_ptr().

static status_t result_push ( demangling_t  dm  )  [static]

static void result_set_caret ( demangling_t  dm,
int  position 
) [static]

Definition at line 515 of file cp-demangle.c.

References result_string.

Referenced by demangle_type().

static void result_shift_caret ( demangling_t  dm,
int  position_offset 
) [static]

Definition at line 526 of file cp-demangle.c.

References result_string.

Referenced by demangle_nested_name(), and demangle_type().

static void string_list_delete ( string_list_t  node  )  [static]

Definition at line 436 of file cp-demangle.c.

References dyn_string_delete(), next, and NULL.

Referenced by demangling_delete(), and template_arg_list_delete().

static string_list_t string_list_new ( int  length  )  [static]

Definition at line 421 of file cp-demangle.c.

References dyn_string_init(), malloc, NULL, and s.

Referenced by result_push().

static status_t substitution_add ( demangling_t  dm,
int  start_position,
int  template_p 
) [static]

static dyn_string_t substitution_get ( demangling_t  dm,
int  n,
int *  template_p 
) [static]

Definition at line 623 of file cp-demangle.c.

References NULL, sub, substitution_def::template_p, and substitution_def::text.

Referenced by demangle_substitution().

static int substitution_start ( demangling_t  dm  )  [static]

Definition at line 551 of file cp-demangle.c.

References result_caret_pos.

Referenced by demangle_name(), demangle_prefix(), and demangle_type().

static void template_arg_list_add_arg ( template_arg_list_t  arg_list,
string_list_t  arg 
) [static]

Definition at line 700 of file cp-demangle.c.

References NULL.

Referenced by demangle_template_args().

static void template_arg_list_delete ( template_arg_list_t  list  )  [static]

Definition at line 687 of file cp-demangle.c.

References free(), NULL, and string_list_delete().

Referenced by demangling_delete(), and pop_to_template_arg_list().

static string_list_t template_arg_list_get_arg ( template_arg_list_t  arg_list,
int  index 
) [static]

Definition at line 719 of file cp-demangle.c.

References NULL.

Referenced by demangle_template_param().

static template_arg_list_t template_arg_list_new (  )  [static]


Variable Documentation

const char* const builtin_type_names[26] [static]

Initial value:

 
{
  "signed char",              
  "bool",                     
  "char",                     
  "double",                   
  "long double",              
  "float",                    
  "__float128",               
  "unsigned char",            
  "int",                      
  "unsigned",                 
  NULL,                       
  "long",                     
  "unsigned long",            
  "__int128",                 
  "unsigned __int128",        
  NULL,                       
  NULL,                       
  NULL,                       
  "short",                    
  "unsigned short",           
  NULL,                       
  "void",                     
  "wchar_t",                  
  "long long",                
  "unsigned long long",       
  "..."                       
}

Definition at line 2564 of file cp-demangle.c.

int flag_strict [static]

Definition at line 98 of file cp-demangle.c.

Referenced by demangle_identifier(), and demangle_special_name().

int flag_verbose [static]

const char* const java_builtin_type_names[26] [static]

Initial value:

 
{
  "signed char",                
  "boolean",    
  "byte",       
  "double",                     
  "long double",                
  "float",                      
  "__float128",                 
  "unsigned char",              
  "int",                        
  "unsigned",                   
  NULL,                         
  "long",                       
  "unsigned long",              
  "__int128",                   
  "unsigned __int128",          
  NULL,                         
  NULL,                         
  NULL,                         
  "short",                      
  "unsigned short",             
  NULL,                         
  "void",                       
  "char",    
  "long",  
  "unsigned long long",         
  "..."                         
}

Definition at line 2597 of file cp-demangle.c.

const char* const status_allocation_failed = "Allocation failed." [static]

Definition at line 214 of file cp-demangle.c.


Generated on Wed Apr 8 15:02:33 2009 for Open64 by  doxygen 1.5.6