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

📄 cp-decl.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
   whose return type is defaulted, if warnings for this are desired.  */static int warn_about_return_type;/* Nonzero when starting a function declared `extern inline'.  */static int current_extern_inline;/* Nonzero means give `double' the same size as `float'.  */extern int flag_short_double;/* Nonzero means handle things in ANSI, instead of GNU fashion.  This   flag should be tested for language behavior that's different between   ANSI and GNU, but not so horrible as to merit a PEDANTIC label.  */extern int flag_ansi;/* Pointers to the base and current top of the language name stack.  */extern tree *current_lang_base, *current_lang_stack;/* C and C++ flags are in cp-decl2.c.  */char *language_string = "GNU C++";/* Set to 0 at beginning of a constructor, set to 1   if that function does an allocation before referencing its   instance variable.  */int current_function_assigns_this;int current_function_just_assigned_this;/* Set to 0 at beginning of a function.  Set non-zero when   store_parm_decls is called.  Don't call store_parm_decls   if this flag is non-zero!  */int current_function_parms_stored;/* Current end of entries in the gc obstack for stack pointer variables.  */int current_function_obstack_index;/* Flag saying whether we have used the obstack in this function or not.  */int current_function_obstack_usage;/* Flag used when debugging cp-spew.c */extern int spew_debug;/* Allocate a level of searching.  */struct stack_level *push_decl_level (stack, obstack)     struct stack_level *stack;     struct obstack *obstack;{  struct stack_level tem;  tem.prev = stack;  return push_stack_level (obstack, &tem, sizeof (tem));}/* Discard a level of decl allocation.  */static struct stack_level *pop_decl_level (stack)     struct stack_level *stack;{  tree *bp, *tp;  struct obstack *obstack = stack->obstack;  bp = stack->first;  tp = (tree *)obstack_next_free (obstack);  while (tp != bp)    {      --tp;      if (*tp != NULL_TREE)	IDENTIFIER_CLASS_VALUE (DECL_NAME (*tp)) = NULL_TREE;    }  return pop_stack_level (stack);}/* For each binding contour we allocate a binding_level structure * which records the names defined in that contour. * Contours include: *  0) the global one *  1) one for each function definition, *     where internal declarations of the parameters appear. *  2) one for each compound statement, *     to record its declarations. * * The current meaning of a name can be found by searching the levels from * the current one out to the global one. * * Off to the side, may be the class_binding_level.  This exists * only to catch class-local declarations.  It is otherwise * nonexistent. *  * Also there may be binding levels that catch cleanups that * must be run when exceptions occur. *//* Note that the information in the `names' component of the global contour   is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */struct binding_level  {    /* A chain of _DECL nodes for all variables, constants, functions,     * and typedef types.  These are in the reverse of the order supplied.     */    tree names;    /* A list of structure, union and enum definitions,     * for looking up tag names.     * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name,     * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE,     * or ENUMERAL_TYPE node.     *     * C++: the TREE_VALUE nodes can be simple types for component_bindings.     *     */    tree tags;    /* For each level, a list of shadowed outer-level local definitions       to be restored when this level is popped.       Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and       whose TREE_VALUE is its old definition (a kind of ..._DECL node).  */    tree shadowed;    /* Same, for IDENTIFIER_CLASS_VALUE.  */    tree class_shadowed;    /* Same, for IDENTIFIER_TYPE_VALUE.  */    tree type_shadowed;    /* For each level (except not the global one),       a chain of BLOCK nodes for all the levels       that were entered and exited one level down.  */    tree blocks;    /* The BLOCK node for this level, if one has been preallocated.       If 0, the BLOCK is allocated (if needed) when the level is popped.  */    tree this_block;    /* The binding level which this one is contained in (inherits from).  */    struct binding_level *level_chain;    /* Number of decls in `names' that have incomplete        structure or union types.  */    unsigned short n_incomplete;    /* 1 for the level that holds the parameters of a function.       2 for the level that holds a class declaration.       3 for levels that hold parameter declarations.  */    unsigned parm_flag : 4;    /* 1 means make a BLOCK for this level regardless of all else.       2 for temporary binding contours created by the compiler.  */    unsigned keep : 3;    /* Nonzero if this level "doesn't exist" for tags.  */    unsigned tag_transparent : 1;    /* Nonzero if this level can safely have additional       cleanup-needing variables added to it.  */    unsigned more_cleanups_ok : 1;    unsigned have_cleanups : 1;    /* Nonzero if this level can safely have additional       exception-raising statements added to it.  */    unsigned more_exceptions_ok : 1;    unsigned have_exceptions : 1;    /* Nonzero if we should accept any name as an identifier in       this scope.  This happens in some template definitions.  */    unsigned accept_any : 1;    /* Nonzero if this level is for completing a template class definition       inside a binding level that temporarily binds the parameters.  This       means that definitions here should not be popped off when unwinding       this binding level.  (Not actually implemented this way,       unfortunately.)  */    unsigned pseudo_global : 1;    /* Two bits left for this word.  */#if PARANOID    unsigned char depth;#endif  };#define NULL_BINDING_LEVEL (struct binding_level *) NULL  /* The binding level currently in effect.  */static struct binding_level *current_binding_level;/* The binding level of the current class, if any.  */static struct binding_level *class_binding_level;/* A chain of binding_level structures awaiting reuse.  */static struct binding_level *free_binding_level;/* The outermost binding level, for names of file scope.   This is created when the compiler is started and exists   through the entire run.  */static struct binding_level *global_binding_level;/* Binding level structures are initialized by copying this one.  */static struct binding_level clear_binding_level;/* Nonzero means unconditionally make a BLOCK for the next level pushed.  */static int keep_next_level_flag;#if PARANOID/* Perform sanity checking on binding levels.  Normally not needed.  */voidbinding_levels_sane (){  struct binding_level *b = current_binding_level;  static int n;  if (++n < 3)    return;  my_friendly_assert (global_binding_level != 0, 126);  my_friendly_assert (current_binding_level != 0, 127);  for (b = current_binding_level; b != global_binding_level; b = b->level_chain)    {      my_friendly_assert (b->level_chain != 0, 128);      my_friendly_assert (b->depth == 1 + b->level_chain->depth, 129);    }  if (class_binding_level)    for (b = class_binding_level;         b != global_binding_level && b != current_binding_level;         b = b->level_chain)    {      my_friendly_assert (b->level_chain != 0, 130);      my_friendly_assert (b->depth == 1 + b->level_chain->depth, 131);    }  my_friendly_assert (global_binding_level->depth == 0, 132);  my_friendly_assert (global_binding_level->level_chain == 0, 133);  return;}#else#define binding_levels_sane() ((void)(1))#endif#ifdef DEBUG_CP_BINDING_LEVELSint debug_bindings_indentation;#endifstatic void#if !PARANOID && defined (__GNUC__)__inline#endifpush_binding_level (newlevel, tag_transparent, keep)     struct binding_level *newlevel;     int tag_transparent, keep;{  binding_levels_sane();  /* Add this level to the front of the chain (stack) of levels that     are active.  */#ifdef DEBUG_CP_BINDING_LEVELS  indent_to (stderr, debug_bindings_indentation);  fprintf (stderr, "pushing binding level ");  fprintf (stderr, HOST_PTR_PRINTF, newlevel);  fprintf (stderr, "\n");#endif  *newlevel = clear_binding_level;  if (class_binding_level)    {      newlevel->level_chain = class_binding_level;      class_binding_level = 0;    }  else    {      newlevel->level_chain = current_binding_level;    }  current_binding_level = newlevel;  newlevel->tag_transparent = tag_transparent;  newlevel->more_cleanups_ok = 1;  newlevel->more_exceptions_ok = 1;  newlevel->keep = keep;#if PARANOID  newlevel->depth = (newlevel->level_chain		     ? newlevel->level_chain->depth + 1		     : 0);#endif  binding_levels_sane();}static void#if !PARANOID && defined (__GNUC__)__inline#endifpop_binding_level (){  binding_levels_sane();#ifdef DEBUG_CP_BINDING_LEVELS  indent_to (stderr, debug_bindings_indentation);  fprintf (stderr, "popping binding level ");  fprintf (stderr, HOST_PTR_PRINTF, current_binding_level);  fprintf (stderr, "\n");#endif  if (global_binding_level)    {      /* cannot pop a level, if there are none left to pop. */      if (current_binding_level == global_binding_level)	my_friendly_abort (123);    }  /* Pop the current level, and free the structure for reuse.  */  {    register struct binding_level *level = current_binding_level;    current_binding_level = current_binding_level->level_chain;    level->level_chain = free_binding_level;#ifdef DEBUG_CP_BINDING_LEVELS    memset (level, 0x69, sizeof (*level));#else    free_binding_level = level;#if PARANOID    level->depth = ~0;	/* ~0 assumes that the depth is unsigned. */#endif#endif    if (current_binding_level->parm_flag == 2)      {	class_binding_level = current_binding_level;	do	  {	    current_binding_level = current_binding_level->level_chain;	  }	while (current_binding_level->parm_flag == 2);      }  }  binding_levels_sane();}/* Nonzero if we are currently in the global binding level.  */intglobal_bindings_p (){  return current_binding_level == global_binding_level;}voidkeep_next_level (){  keep_next_level_flag = 1;}/* Nonzero if the current level needs to have a BLOCK made.  */intkept_level_p (){  return (current_binding_level->blocks != 0	  || current_binding_level->keep	  || current_binding_level->names != 0	  || (current_binding_level->tags != 0	      && !current_binding_level->tag_transparent));}/* Identify this binding level as a level of parameters.  */voiddeclare_parm_level (){  current_binding_level->parm_flag = 1;}/* Identify this binding level as a level of a default exception handler.  */voiddeclare_implicit_exception (){  current_binding_level->parm_flag = 3;}/* Nonzero if current binding contour contains expressions   that might raise exceptions.  */inthave_exceptions_p (){  return current_binding_level->have_exceptions;}voiddeclare_uninstantiated_type_level (){  current_binding_level->accept_any = 1;}intuninstantiated_type_level_p (){  return current_binding_level->accept_any;}voiddeclare_pseudo_global_level (){  current_binding_level->pseudo_global = 1;}intpseudo_global_level_p (){  return current_binding_level->pseudo_global;}/* Enter a new binding level.   If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,   not for that of tags.  */voidpushlevel (tag_transparent)     int tag_transparent;{  register struct binding_level *newlevel = NULL_BINDING_LEVEL;#ifdef DEBUG_CP_BINDING_LEVELS  indent_to (stderr, debug_bindings_indentation);  fprintf (stderr, "pushlevel");  debug_bindings_indentation += 4;#endif  /* If this is the top level of a function,     just make sure that NAMED_LABELS is 0.     They should have been set to 0 at the end of the previous function.  */  if (current_binding_level == global_binding_level)    my_friendly_assert (named_labels == NULL_TREE, 134);  /* Reuse or create a struct for this binding level.  */

⌨️ 快捷键说明

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