OSDN Git Service

Do no emit GNU metadata if there is nothing to put into it
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-act.h
index b7bb6f2..f45b4ea 100644 (file)
@@ -1,6 +1,6 @@
 /* Declarations for objc-act.c.
-   Copyright (C) 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
+   2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -28,8 +28,6 @@ bool objc_init (void);
 const char *objc_printable_name (tree, int);
 tree objc_fold_obj_type_ref (tree, tree);
 int objc_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
-tree objc_eh_runtime_type (tree);
-tree objc_eh_personality (void);
 
 /* NB: The remaining public functions are prototyped in c-common.h, for the
    benefit of stub-objc.c and objc-act.c.  */
@@ -54,17 +52,109 @@ tree objc_eh_personality (void);
 #define METHOD_TYPE_ATTRIBUTES(DECL) ((DECL)->decl_common.abstract_origin)
 #define METHOD_PROPERTY_CONTEXT(DECL) ((DECL)->decl_common.size_unit)
 
-#define PROPERTY_NAME(DECL) ((DECL)->decl_minimal.name)
+
+/* PROPERTY_DECL.  A PROPERTY_DECL repesents a @property declaration
+   (when attached to the list of properties of an interface) or a
+   @synthesize or @dynamic declaration (when attached to the list of
+   properties of an implementation).  */
+
+/* TREE_TYPE is the type (int, float, etc) of the property.  */
+
+/* DECL_ARTIFICIAL is set to 1 if the PROPERTY_DECL is an artificial
+   property declaration created when the dot-syntax object.component
+   is used with no actual @property matching the component, but a
+   valid getter/setter.  */
+
+/* PROPERTY_NAME is the name of the property.  */
+#define PROPERTY_NAME(DECL) DECL_NAME(DECL)
+
+/* PROPERTY_GETTER_NAME is the identifier of the getter method.  */
 #define PROPERTY_GETTER_NAME(DECL) ((DECL)->decl_non_common.arguments)
+
+/* PROPERTY_SETTER_NAME is the identifier of the setter method.  */
 #define PROPERTY_SETTER_NAME(DECL) ((DECL)->decl_non_common.result)
+
+/* PROPERTY_READONLY can be 0 or 1.  */
+#define PROPERTY_READONLY(DECL) DECL_LANG_FLAG_0 (DECL)
+
+/* PROPERTY_NONATOMIC can be 0 or 1.  */
+#define PROPERTY_NONATOMIC(DECL) DECL_LANG_FLAG_1 (DECL)
+
+typedef enum objc_property_assign_semantics {
+  OBJC_PROPERTY_ASSIGN = 1,
+  OBJC_PROPERTY_RETAIN = 2,
+  OBJC_PROPERTY_COPY = 3
+} objc_property_assign_semantics;
+
+/* PROPERTY_ASSIGN_SEMANTICS can be OBJC_PROPERTY_ASSIGN,
+   OBJC_PROPERTY_RETAIN or OBJC_PROPERTY_COPY.  We need an integer to
+   store it, so we hijack the alignment, that properties don't
+   have.  */
+#define PROPERTY_ASSIGN_SEMANTICS(DECL) ((DECL)->decl_common.align)
+
+/* PROPERTY_IVAR_NAME is the identifier of the instance variable.
+   This is set only if the PROPERTY_DECL represents a @synthesize;
+   otherwise, it is set to TREE_NULL.  */
 #define PROPERTY_IVAR_NAME(DECL) ((DECL)->decl_common.initial)
-#define PROPERTY_READONLY(DECL) ((DECL)->decl_minimal.context)
-#define PROPERTY_COPIES(DECL) ((DECL)->decl_common.size_unit)
+
+/* PROPERTY_DYNAMIC can be 0 or 1.  This is 1 if the PROPERTY_DECL
+   represents a @dynamic; otherwise, it is set to 0.  */
+#define PROPERTY_DYNAMIC(DECL) DECL_LANG_FLAG_2 (DECL)
+
+/* PROPERTY_HAS_NO_GETTER can be 0 or 1.  Normally it is 0, but if
+   this is an artificial PROPERTY_DECL that we generate even without a
+   getter, it is set to 1.  */
+#define PROPERTY_HAS_NO_GETTER(DECL) DECL_LANG_FLAG_3 (DECL)
+
+/* PROPERTY_HAS_NO_SETTER can be 0 or 1.  Normally it is 0, but if
+   this is an artificial PROPERTY_DECL that we generate even without a
+   setter, it is set to 1.  */
+#define PROPERTY_HAS_NO_SETTER(DECL) DECL_LANG_FLAG_4 (DECL)
+
+/* PROPERTY_OPTIONAL can be 0 or 1.  Normally it is 0, but if this is
+   a property declared as @optional in a @protocol, then it is set to
+   1.  */
+#define PROPERTY_OPTIONAL(DECL) DECL_LANG_FLAG_5 (DECL)
+
+/* PROPERTY_REF.  A PROPERTY_REF represents an 'object.property'
+   expression.  It is normally used for property access, but when
+   the Objective-C 2.0 "dot-syntax" (object.component) is used
+   with no matching property, a PROPERTY_REF is still created to
+   represent it, with an artificial PROPERTY_DECL.  */
+
+/* PROPERTY_REF_OBJECT is the object whose property we are
+   accessing.  */
+#define PROPERTY_REF_OBJECT(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 0)
+
+/* PROPERTY_REF_PROPERTY_DECL is the PROPERTY_DECL for the property
+   used in the expression.  From it, you can get the property type,
+   and the getter/setter names.  This PROPERTY_DECL could be artificial
+   if we are processing an 'object.component' syntax with no matching 
+   declared property.  */
+#define PROPERTY_REF_PROPERTY_DECL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 1)
+
+/* PROPERTY_REF_GETTER_CALL is the getter call expression, ready to
+   use at gimplify time if needed.  Generating the getter call
+   requires modifying the selector table, and, in the case of
+   self/super, requires the context to be generated correctly.  The
+   gimplify stage is too late to do these things, so we generate the
+   getter call earlier instead, and keep it here in case we need to
+   use it.  */
+#define PROPERTY_REF_GETTER_CALL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 2)
+
+/* PROPERTY_REF_DEPRECATED_GETTER is normally set to NULL_TREE.  If
+   the property getter is deprecated, it is set to the method
+   prototype for it, which is used to generate the deprecation warning
+   when the getter is used.  */
+#define PROPERTY_REF_DEPRECATED_GETTER(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 3)
 
 /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
    CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
    PROTOCOL_INTERFACE_TYPE */
+/* CLASS_NAME is the name of the class.  */
 #define CLASS_NAME(CLASS) ((CLASS)->type.name)
+/* CLASS_SUPER_NAME is the name of the superclass, or, in the case of
+   categories, it is the name of the category itself.  */
 #define CLASS_SUPER_NAME(CLASS) (TYPE_CHECK (CLASS)->type.context)
 #define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
 #define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 1)
@@ -75,6 +165,8 @@ tree objc_eh_personality (void);
 #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 4)
 #define TOTAL_CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 5)
 
+#define CLASS_HAS_EXCEPTION_ATTR(CLASS) ((CLASS)->type.lang_flag_0)
+
 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
 #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
 #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
@@ -89,6 +181,10 @@ tree objc_eh_personality (void);
 /* For CLASS_IMPLEMENTATION_TYPE or CATEGORY_IMPLEMENTATION_TYPE. */
 #define IMPL_PROPERTY_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 6)
 
+/* TREE_DEPRECATED is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE.  */
+
+/* TYPE_ATTRIBUTES is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE.  */
+
 /* ObjC-specific information pertaining to RECORD_TYPEs are stored in
    the LANG_SPECIFIC structures, which may itself need allocating first.  */
 
@@ -118,6 +214,7 @@ tree objc_eh_personality (void);
                = make_tree_vec (OBJC_INFO_SLOT_ELTS);          \
          }                                                     \
        while (0)
+
 #define DUP_TYPE_OBJC_INFO(DST, SRC)                           \
        do                                                      \
          {                                                     \
@@ -147,16 +244,24 @@ struct GTY(()) hashed_attribute {
   attr next;
   tree value;
 };
+
 struct GTY(()) hashed_entry {
   attr list;
   hash next;
   tree key;
 };
 
+#define SIZEHASHTABLE          257
+
 extern GTY ((length ("SIZEHASHTABLE"))) hash *nst_method_hash_list;
 extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_method_hash_list;
 
-#define SIZEHASHTABLE          257
+extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_name_hash_list;
+extern GTY ((length ("SIZEHASHTABLE"))) hash *als_name_hash_list;
+
+/* An array of all the local variables in the current function that
+   need to be marked as volatile.  */
+extern GTY(()) VEC(tree,gc) *local_variables_to_volatilize;
 
 /* Objective-C/Objective-C++ @implementation list.  */
 
@@ -164,8 +269,8 @@ struct GTY(()) imp_entry {
   struct imp_entry *next;
   tree imp_context;
   tree imp_template;
-  tree class_decl;             /* _OBJC_CLASS_<my_name>; */
-  tree meta_decl;              /* _OBJC_METACLASS_<my_name>; */
+  tree class_decl;             /* _OBJC[_v2]_CLASS/CATEGORY_<my_name>; */
+  tree meta_decl;              /* _OBJC[_v2]_METACLASS_<my_name>; */
   BOOL_BITFIELD has_cxx_cdtors : 1;
 };
 
@@ -173,7 +278,6 @@ extern GTY(()) struct imp_entry *imp_list;
 extern GTY(()) int imp_count;  /* `@implementation' */
 extern GTY(()) int cat_count;  /* `@category' */
 
-extern GTY(()) enum tree_code objc_inherit_code;
 extern GTY(()) objc_ivar_visibility_kind objc_ivar_visibility;
 
 /* Objective-C/Objective-C++ global tree enumeration.  */
@@ -200,8 +304,6 @@ enum objc_tree_index
     OCTI_NST_TYPE,
     OCTI_PROTO_TYPE,
 
-    OCTI_CLS_CHAIN,
-    OCTI_ALIAS_CHAIN,
     OCTI_INTF_CHAIN,
     OCTI_PROTO_CHAIN,
     OCTI_IMPL_CHAIN,
@@ -260,6 +362,7 @@ enum objc_tree_index
     OCTI_STRING_CLASS_DECL,
     OCTI_INTERNAL_CNST_STR_TYPE,
     OCTI_SUPER_DECL,
+    OCTI_SUPER_SUPERFIELD_ID,
     OCTI_UMSG_NONNIL_DECL,
     OCTI_UMSG_NONNIL_STRET_DECL,
     OCTI_STORAGE_CLS,
@@ -287,6 +390,16 @@ enum objc_tree_index
     OCTI_FAST_ENUM_STATE_TEMP,
     OCTI_ENUM_MUTATION_DECL,
 
+    OCTI_GET_PROPERTY_DECL,
+    OCTI_SET_PROPERTY_DECL,
+    OCTI_COPY_STRUCT_DECL,
+    OCTI_GET_PROPERTY_STRUCT_DECL,
+    OCTI_SET_PROPERTY_STRUCT_DECL,
+
+    /* "V1" stuff.  */
+    OCTI_V1_PROP_LIST_TEMPL,
+    OCTI_V1_PROP_NAME_ATTR_CHAIN,
+
     OCTI_MAX
 };
 
@@ -326,20 +439,21 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
        (TREE_CODE (TYPE) == POINTER_TYPE                               \
         && (TYPE_MAIN_VARIANT (TREE_TYPE (TYPE))                       \
             == TREE_TYPE (objc_object_type)))
+
 #define IS_CLASS(TYPE)                                                 \
        (TREE_CODE (TYPE) == POINTER_TYPE                               \
         && (TYPE_MAIN_VARIANT (TREE_TYPE (TYPE))                       \
             == TREE_TYPE (objc_class_type)))
+
 #define IS_PROTOCOL_QUALIFIED_UNTYPED(TYPE)                            \
        ((IS_ID (TYPE) || IS_CLASS (TYPE))                              \
         && TYPE_HAS_OBJC_INFO (TREE_TYPE (TYPE))                       \
         && TYPE_OBJC_PROTOCOL_LIST (TREE_TYPE (TYPE)))
+
 #define IS_SUPER(TYPE)                                                 \
        (TREE_CODE (TYPE) == POINTER_TYPE                               \
         && TREE_TYPE (TYPE) == objc_super_template)
 
-#define class_chain            objc_global_trees[OCTI_CLS_CHAIN]
-#define alias_chain            objc_global_trees[OCTI_ALIAS_CHAIN]
 #define interface_chain                objc_global_trees[OCTI_INTF_CHAIN]
 #define protocol_chain         objc_global_trees[OCTI_PROTO_CHAIN]
 #define implemented_classes    objc_global_trees[OCTI_IMPL_CHAIN]
@@ -444,16 +558,188 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
 #define objc_class_id          objc_global_trees[OCTI_CLS_ID]
 #define objc_object_name               objc_global_trees[OCTI_ID_NAME]
 #define objc_class_name                objc_global_trees[OCTI_CLASS_NAME]
+
+/* Constant string classes.  */
 #define constant_string_id     objc_global_trees[OCTI_CNST_STR_ID]
 #define constant_string_type   objc_global_trees[OCTI_CNST_STR_TYPE]
 #define constant_string_global_id              \
                                objc_global_trees[OCTI_CNST_STR_GLOB_ID]
 #define string_class_decl      objc_global_trees[OCTI_STRING_CLASS_DECL]
 #define internal_const_str_type        objc_global_trees[OCTI_INTERNAL_CNST_STR_TYPE]
+
 #define UOBJC_SUPER_decl       objc_global_trees[OCTI_SUPER_DECL]
+#define super_superclassfield_id \
+                               objc_global_trees[OCTI_SUPER_SUPERFIELD_ID]
+
 #define objc_fast_enumeration_state_template   \
                                 objc_global_trees[OCTI_FAST_ENUM_STATE_TEMP]
 #define objc_enumeration_mutation_decl         \
                                 objc_global_trees[OCTI_ENUM_MUTATION_DECL]
 
+/* Declarations of functions used when synthesizing property
+   accessors.  */
+#define objc_getProperty_decl  objc_global_trees[OCTI_GET_PROPERTY_DECL]
+#define objc_setProperty_decl  objc_global_trees[OCTI_SET_PROPERTY_DECL]
+#define objc_copyStruct_decl   objc_global_trees[OCTI_COPY_STRUCT_DECL]
+#define objc_getPropertyStruct_decl \
+                               objc_global_trees[OCTI_GET_PROPERTY_STRUCT_DECL]
+#define objc_setPropertyStruct_decl \
+                               objc_global_trees[OCTI_SET_PROPERTY_STRUCT_DECL]
+
+/* V1 stuff.  */
+#define objc_prop_list_ptr     objc_global_trees[OCTI_V1_PROP_LIST_TEMPL]
+#define prop_names_attr_chain  objc_global_trees[OCTI_V1_PROP_NAME_ATTR_CHAIN]
+
+/* Reserved tag definitions.  */
+
+#define OBJECT_TYPEDEF_NAME            "id"
+#define CLASS_TYPEDEF_NAME             "Class"
+
+#define TAG_OBJECT                     "objc_object"
+#define TAG_CLASS                      "objc_class"
+#define TAG_SUPER                      "objc_super"
+#define TAG_SELECTOR                   "objc_selector"
+
+#define UTAG_CLASS                     "_objc_class"
+#define UTAG_IVAR                      "_objc_ivar"
+#define UTAG_IVAR_LIST                 "_objc_ivar_list"
+#define UTAG_METHOD                    "_objc_method"
+#define UTAG_METHOD_LIST               "_objc_method_list"
+#define UTAG_CATEGORY                  "_objc_category"
+#define UTAG_MODULE                    "_objc_module"
+#define UTAG_SYMTAB                    "_objc_symtab"
+#define UTAG_SUPER                     "_objc_super"
+#define UTAG_SELECTOR                  "_objc_selector"
+
+#define UTAG_PROTOCOL                  "_objc_protocol"
+#define UTAG_METHOD_PROTOTYPE          "_objc_method_prototype"
+#define UTAG_METHOD_PROTOTYPE_LIST     "_objc__method_prototype_list"
+
+#define PROTOCOL_OBJECT_CLASS_NAME     "Protocol"
+
+#define TAG_EXCEPTIONTHROW             "objc_exception_throw"
+#define TAG_SYNCENTER                  "objc_sync_enter"
+#define TAG_SYNCEXIT                   "objc_sync_exit"
+
+/* Really should be NeXT private.  */
+#define UTAG_EXCDATA                   "_objc_exception_data"
+
+#define TAG_CXX_CONSTRUCT              ".cxx_construct"
+#define TAG_CXX_DESTRUCT               ".cxx_destruct"
+
+#define TAG_ENUMERATION_MUTATION        "objc_enumerationMutation"
+#define TAG_FAST_ENUMERATION_STATE      "__objcFastEnumerationState"
+
+typedef enum string_section
+{
+  class_names,         /* class, category, protocol, module names */
+  meth_var_names,      /* method and variable names */
+  meth_var_types,      /* method and variable type descriptors */
+  prop_names_attr      /* property names and their attributes. */
+} string_section;
+
+#define METHOD_DEF                     0
+#define METHOD_REF                     1
+
+/* (Decide if these can ever be validly changed.) */
+#define OBJC_ENCODE_INLINE_DEFS        0
+#define OBJC_ENCODE_DONT_INLINE_DEFS   1
+
+#define BUFSIZE                                1024
+
+#define CLS_FACTORY                    0x0001L
+#define CLS_META                       0x0002L
+
+/* Runtime metadata flags - ??? apparently unused.  */
+
+#define OBJC_MODIFIER_STATIC           0x00000001
+#define OBJC_MODIFIER_FINAL            0x00000002
+#define OBJC_MODIFIER_PUBLIC           0x00000004
+#define OBJC_MODIFIER_PRIVATE          0x00000008
+#define OBJC_MODIFIER_PROTECTED                0x00000010
+#define OBJC_MODIFIER_NATIVE           0x00000020
+#define OBJC_MODIFIER_SYNCHRONIZED     0x00000040
+#define OBJC_MODIFIER_ABSTRACT         0x00000080
+#define OBJC_MODIFIER_VOLATILE         0x00000100
+#define OBJC_MODIFIER_TRANSIENT                0x00000200
+#define OBJC_MODIFIER_NONE_SPECIFIED   0x80000000
+
+#define OBJC_VOID_AT_END               void_list_node
+
+/* Exception handling constructs.  We begin by having the parser do most
+   of the work and passing us blocks.  
+   This allows us to handle different exceptions implementations.  */
+
+/* Stack of open try blocks.  */
+
+struct objc_try_context
+{
+  struct objc_try_context *outer;
+
+  /* Statements (or statement lists) as processed by the parser.  */
+  tree try_body;
+  tree finally_body;
+
+  /* Some file position locations.  */
+  location_t try_locus;
+  location_t end_try_locus;
+  location_t end_catch_locus;
+  location_t finally_locus;
+  location_t end_finally_locus;
+
+  /* A STATEMENT_LIST of CATCH_EXPRs, appropriate for sticking into op1
+     of a TRY_CATCH_EXPR.  Even when doing Darwin setjmp.  */
+  tree catch_list;
+
+  /* The CATCH_EXPR of an open @catch clause.  */
+  tree current_catch;
+
+  /* The VAR_DECL holding  __builtin_eh_pointer (or equivalent).  */
+  tree caught_decl;
+  tree stack_decl;
+  tree rethrow_decl;
+};
+
+/*  A small number of routines used by the FE parser and the runtime code
+   generators.  Put here as inlines for efficiency in non-lto builds rather
+   than making them externs.  */
+
+extern tree objc_create_temporary_var (tree, const char *);
+  
+#define objc_is_object_id(TYPE) (OBJC_TYPE_NAME (TYPE) == objc_object_id)
+#define objc_is_class_id(TYPE) (OBJC_TYPE_NAME (TYPE) == objc_class_id)
+
+/* Retrieve category interface CAT_NAME (if any) associated with CLASS.  */
+static inline tree
+lookup_category (tree klass, tree cat_name)
+{
+  tree category = CLASS_CATEGORY_LIST (klass);
+
+  while (category && CLASS_SUPER_NAME (category) != cat_name)
+    category = CLASS_CATEGORY_LIST (category);
+  return category;
+}
+
+/* Count only the fields occurring in T.  */
+static inline int
+ivar_list_length (tree t)
+{
+  int count = 0;
+
+  for (; t; t = DECL_CHAIN (t))
+    if (TREE_CODE (t) == FIELD_DECL)
+      ++count;
+
+  return count;
+}
+
+static inline tree
+is_ivar (tree decl_chain, tree ident)
+{
+  for ( ; decl_chain; decl_chain = DECL_CHAIN (decl_chain))
+    if (DECL_NAME (decl_chain) == ident)
+      return decl_chain;
+  return NULL_TREE;
+}
+
 #endif /* GCC_OBJC_ACT_H */