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

📄 symbian.c

📁 linux下编程用 编译软件
💻 C
📖 第 1 页 / 共 2 页
字号:
     the user declared constructor itself.  */  if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE      && (DECL_CONSTRUCTOR_P (node) || DECL_DESTRUCTOR_P (node)))    {      tree overload;      for (overload = OVL_CHAIN (node); overload; overload = OVL_CHAIN (overload))	{	  tree node_args;	  tree func_args;	  tree function = OVL_CURRENT (overload);	  if (! function	      || ! DECL_P (function)	      || (DECL_CONSTRUCTOR_P (node) && ! DECL_CONSTRUCTOR_P (function))	      || (DECL_DESTRUCTOR_P (node)  && ! DECL_DESTRUCTOR_P (function)))	    continue;	  /* The arguments must match as well.  */	  for (node_args = DECL_ARGUMENTS (node), func_args = DECL_ARGUMENTS (function);	       node_args && func_args;	       node_args = TREE_CHAIN (node_args), func_args = TREE_CHAIN (func_args))	    if (TREE_TYPE (node_args) != TREE_TYPE (func_args))	      break;	  if (node_args || func_args)	    {	      /* We can ignore an extraneous __in_chrg arguments in the node.		 GCC generated destructors, for example, will have this.  */	      if ((node_args == NULL_TREE		   || func_args != NULL_TREE)		  && strcmp (IDENTIFIER_POINTER (DECL_NAME (node)), "__in_chrg") != 0)		continue;	    }	  symbian_add_attribute (function, attr);	  /* Propagate the attribute to any function thunks as well.  */	  for (thunk = DECL_THUNKS (function); thunk; thunk = TREE_CHAIN (thunk))	    if (TREE_CODE (thunk) == FUNCTION_DECL)	      symbian_add_attribute (thunk, attr);	}    }  if (TREE_CODE (node) == FUNCTION_DECL && DECL_VIRTUAL_P (node))    {      /* Propagate the attribute to any thunks of this function.  */      for (thunk = DECL_THUNKS (node); thunk; thunk = TREE_CHAIN (thunk))	if (TREE_CODE (thunk) == FUNCTION_DECL)	  symbian_add_attribute (thunk, attr);    }  /*  Report error if symbol is not accessible at global scope.  */  if (!TREE_PUBLIC (node)      && (   TREE_CODE (node) == VAR_DECL	  || TREE_CODE (node) == FUNCTION_DECL))    {      error ("external linkage required for symbol %q+D because of %qs attribute",	     node, IDENTIFIER_POINTER (name));      *no_add_attrs = true;    }#if SYMBIAN_DEBUG  print_node_brief (stderr, "mark node", node, 0);  fprintf (stderr, " as %s\n", attr);#endif  return NULL_TREE;}/* This code implements a specification for exporting the vtable and rtti of   classes that have members with the dllexport or dllexport attributes.   This specification is defined here:     http://www.armdevzone.com/EABI/exported_class.txt   Basically it says that a class's vtable and rtti should be exported if   the following rules apply:   - If it has any non-inline non-pure virtual functions,     at least one of these need to be declared dllimport     OR any of the constructors is declared dllimport.   AND   - The class has an inline constructor/destructor and     a key-function (placement of vtable uniquely defined) that     is defined in this translation unit.   The specification also says that for classes which will have their   vtables and rtti exported that their base class(es) might also need a   similar exporting if:   - Every base class needs to have its vtable & rtti exported     as well, if the following the conditions hold true:     + The base class has a non-inline declared non-pure virtual function     + The base class is polymorphic (has or inherits any virtual functions)       or the base class has any virtual base classes.  *//* Decide if a base class of a class should   also have its vtable and rtti exported.  */static voidsymbian_possibly_export_base_class (tree base_class){  VEC(tree,gc) *method_vec;  int len;  if (! (TYPE_CONTAINS_VPTR_P (base_class)))    return;  method_vec = CLASSTYPE_METHOD_VEC (base_class);  len = method_vec ? VEC_length (tree, method_vec) : 0;  for (;len --;)    {      tree member = VEC_index (tree, method_vec, len);      if (! member)	continue;      for (member = OVL_CURRENT (member); member; member = OVL_NEXT (member))	{	  if (TREE_CODE (member) != FUNCTION_DECL)	    continue;	  if (DECL_CONSTRUCTOR_P (member) || DECL_DESTRUCTOR_P (member))	    continue;	  if (! DECL_VIRTUAL_P (member))	    continue;	  if (DECL_PURE_VIRTUAL_P (member))	    continue;	  if (DECL_INLINE (member))	    continue;	  break;	}      if (member)	break;    }  if (len < 0)    return;  /* FIXME: According to the spec this base class should be exported, but     a) how do we do this ? and     b) it does not appear to be necessary for compliance with the Symbian        OS which so far is the only consumer of this code.  */#if SYMBIAN_DEBUG  print_node_brief (stderr, "", base_class, 0);  fprintf (stderr, " EXPORTed [base class of exported class]\n");#endif}/* Decide if a class needs its vtable and rtti exporting.  */static boolsymbian_export_vtable_and_rtti_p (tree ctype){  bool inline_ctor_dtor;  bool dllimport_ctor_dtor;  bool dllimport_member;  tree binfo, base_binfo;  VEC(tree,gc) *method_vec;  tree key;  int i;  int len;  /* Make sure that we are examining a class...  */  if (TREE_CODE (ctype) != RECORD_TYPE)    {#if SYMBIAN_DEBUG      print_node_brief (stderr, "", ctype, 0);      fprintf (stderr, " does NOT need to be EXPORTed [not a class]\n");#endif      return false;    }  /* If the class does not have a key function it     does not need to have its vtable exported.  */  if ((key = CLASSTYPE_KEY_METHOD (ctype)) == NULL_TREE)    {#if SYMBIAN_DEBUG      print_node_brief (stderr, "", ctype, 0);      fprintf (stderr, " does NOT need to be EXPORTed [no key function]\n");#endif      return false;    }  /* If the key fn has not been defined     then the class should not be exported.  */  if (! TREE_ASM_WRITTEN (key))    {#if SYMBIAN_DEBUG      print_node_brief (stderr, "", ctype, 0);      fprintf (stderr, " does NOT need to be EXPORTed [key function not defined]\n");#endif      return false;    }  /* Check the class's member functions.  */  inline_ctor_dtor = false;  dllimport_ctor_dtor = false;  dllimport_member = false;  method_vec = CLASSTYPE_METHOD_VEC (ctype);  len = method_vec ? VEC_length (tree, method_vec) : 0;  for (;len --;)    {      tree member = VEC_index (tree, method_vec, len);      if (! member)	continue;      for (member = OVL_CURRENT (member); member; member = OVL_NEXT (member))	{	  if (TREE_CODE (member) != FUNCTION_DECL)	    continue;	  if (DECL_CONSTRUCTOR_P (member) || DECL_DESTRUCTOR_P (member))	    {	      if (DECL_INLINE (member)		  /* Ignore C++ backend created inline ctors/dtors.  */		  && (   DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (member)		      || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (member)))		inline_ctor_dtor = true;	      if (lookup_attribute ("dllimport", DECL_ATTRIBUTES (member)))		dllimport_ctor_dtor = true;	    }	  else	    {	      if (DECL_PURE_VIRTUAL_P (member))		continue;	      if (! DECL_VIRTUAL_P (member))		continue;	      if (DECL_INLINE (member))		continue;	      if (lookup_attribute ("dllimport", DECL_ATTRIBUTES (member)))		dllimport_member = true;	    }	}    }  if (! dllimport_member && ! dllimport_ctor_dtor)    {#if SYMBIAN_DEBUG      print_node_brief (stderr, "", ctype, 0);      fprintf (stderr,	       " does NOT need to be EXPORTed [no non-pure virtuals or ctors/dtors with dllimport]\n");#endif      return false;    }  if (! inline_ctor_dtor)    {#if SYMBIAN_DEBUG      print_node_brief (stderr, "", ctype, 0);      fprintf (stderr,	       " does NOT need to be EXPORTed [no inline ctor/dtor]\n");#endif      return false;    }#if SYMBIAN_DEBUG  print_node_brief (stderr, "", ctype, 0);  fprintf (stderr, " DOES need to be EXPORTed\n");#endif  /* Now we must check and possibly export the base classes.  */  for (i = 0, binfo = TYPE_BINFO (ctype);       BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)    symbian_possibly_export_base_class (BINFO_TYPE (base_binfo));  return true;}/* Add the named attribute to a class and its vtable and rtti.  */static voidsymbian_add_attribute_to_class_vtable_and_rtti (tree ctype, const char *attr_name){  symbian_add_attribute (ctype, attr_name);  /* If the vtable exists then they need annotating as well.  */  if (CLASSTYPE_VTABLES (ctype))    /* XXX - Do we need to annotate any vtables other than the primary ?  */    symbian_add_attribute (CLASSTYPE_VTABLES (ctype), attr_name);  /* If the rtti exists then it needs annotating as well.  */  if (TYPE_MAIN_VARIANT (ctype)      && CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (ctype)))    symbian_add_attribute (CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (ctype)),			   attr_name);}/* Decide if a class needs to have an attribute because   one of its member functions has the attribute.  */static boolsymbian_class_needs_attribute_p (tree ctype, const char *attribute_name){  VEC(tree,gc) *method_vec;  method_vec = CLASSTYPE_METHOD_VEC (ctype);  /* If the key function has the attribute then the class needs it too.  */  if (TYPE_POLYMORPHIC_P (ctype)      && method_vec      && lookup_attribute (attribute_name,			   DECL_ATTRIBUTES (VEC_index (tree, method_vec, 0))))    return true;  /* Check the class's member functions.  */  if (TREE_CODE (ctype) == RECORD_TYPE)    {      unsigned int len;      len = method_vec ? VEC_length (tree, method_vec) : 0;      for (;len --;)	{	  tree member = VEC_index (tree, method_vec, len);	  if (! member)	    continue;	  for (member = OVL_CURRENT (member);	       member;	       member = OVL_NEXT (member))	    {	      if (TREE_CODE (member) != FUNCTION_DECL)		continue;	      if (DECL_PURE_VIRTUAL_P (member))		continue;	      if (! DECL_VIRTUAL_P (member))		continue;	      if (lookup_attribute (attribute_name, DECL_ATTRIBUTES (member)))		{#if SYMBIAN_DEBUG		  print_node_brief (stderr, "", ctype, 0);		  fprintf (stderr, " inherits %s because", attribute_name);		  print_node_brief (stderr, "", member, 0);		  fprintf (stderr, " has it.\n");#endif		  return true;		}	    }	}    }#if SYMBIAN_DEBUG  print_node_brief (stderr, "", ctype, 0);  fprintf (stderr, " does not inherit %s\n", attribute_name);#endif  return false;}intsymbian_import_export_class (tree ctype, int import_export){  const char *attr_name = NULL;  /* If we are exporting the class but it does not have the dllexport     attribute then we may need to add it.  Similarly imported classes     may need the dllimport attribute.  */  switch (import_export)    {    case  1: attr_name = "dllexport"; break;    case -1: attr_name = "dllimport"; break;    default: break;    }  if (attr_name      && ! lookup_attribute (attr_name, TYPE_ATTRIBUTES (ctype)))    {      if (symbian_class_needs_attribute_p (ctype, attr_name))	symbian_add_attribute_to_class_vtable_and_rtti (ctype, attr_name);      /* Classes can be forced to export their	 vtable and rtti under certain conditions.  */      if (symbian_export_vtable_and_rtti_p (ctype))	{	  symbian_add_attribute_to_class_vtable_and_rtti (ctype, "dllexport");	  /* Make sure that the class and its vtable are exported.  */	  import_export = 1;	  if (CLASSTYPE_VTABLES (ctype))	    DECL_EXTERNAL (CLASSTYPE_VTABLES (ctype)) = 1;	  /* Check to make sure that if the class has a key method that	     it is now on the list of keyed classes.  That way its vtable	     will be emitted.  */	  if (CLASSTYPE_KEY_METHOD (ctype))	    {	      tree class;	      for (class = keyed_classes; class; class = TREE_CHAIN (class))		if (class == ctype)		  break;	      if (class == NULL_TREE)		{#if SYMBIAN_DEBUG		  print_node_brief (stderr, "Add node", ctype, 0);		  fprintf (stderr, " to the keyed classes list\n");#endif		  keyed_classes = tree_cons (NULL_TREE, ctype, keyed_classes);		}	    }	  /* Make sure that the typeinfo will be emitted as well.  */	  if (CLASS_TYPE_P (ctype))	    TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (ctype)))) = 1;	}    }  return import_export;}/* Dummy definition of this array for cc1 building purposes.  */tree cp_global_trees[CPTI_MAX] __attribute__((weak));#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)/* Dummy version of this G++ function for building cc1.  */void lang_check_failed (const char *, int, const char *) __attribute__((weak));voidlang_check_failed (const char *file, int line, const char *function){  internal_error ("lang_* check: failed in %s, at %s:%d",		  function, trim_filename (file), line);}#endif /* ENABLE_TREE_CHECKING */

⌨️ 快捷键说明

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