OSDN Git Service

[gcc/ChangeLog]
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-act.h
index c06c2b8..d5d6314 100644 (file)
@@ -1,5 +1,5 @@
 /* Declarations for objc-act.c.
-   Copyright (C) 1990, 2000, 2001, 2002, 2003
+   Copyright (C) 1990, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -22,59 +22,69 @@ Boston, MA 02111-1307, USA.  */
 #ifndef GCC_OBJC_ACT_H
 #define GCC_OBJC_ACT_H
 
-/*** Public Interface (procedures) ***/
+/*** Language hooks ***/
 
-bool objc_init                                 PARAMS ((void));
-const char *objc_printable_name                        PARAMS ((tree, int));
+bool objc_init (void);
+const char *objc_printable_name (tree, int);
+void objc_finish_file (void);
 
 /* used by yyparse */
 
-void finish_file                               PARAMS ((void));
-tree start_class                               PARAMS ((enum tree_code, tree, tree, tree));
-tree continue_class                            PARAMS ((tree));
-void finish_class                              PARAMS ((tree));
-void start_method_def                          PARAMS ((tree));
-void continue_method_def                       PARAMS ((void));
-void finish_method_def                         PARAMS ((void));
-tree start_protocol                            PARAMS ((enum tree_code, tree, tree));
-void finish_protocol                           PARAMS ((tree));
-void add_objc_decls                            PARAMS ((void));
-
-tree is_ivar                                   PARAMS ((tree, tree));
-int is_private                                 PARAMS ((tree));
-int is_public                                  PARAMS ((tree, tree));
-tree add_instance_variable                     PARAMS ((tree, int, tree, tree, tree));
-tree add_class_method                          PARAMS ((tree, tree));
-tree add_instance_method                       PARAMS ((tree, tree));
-tree get_super_receiver                                PARAMS ((void));
-tree get_class_ivars                           PARAMS ((tree));
-tree get_class_reference                       PARAMS ((tree));
-tree get_static_reference                      PARAMS ((tree, tree));
-tree get_object_reference                      PARAMS ((tree));
-tree build_message_expr                                PARAMS ((tree));
-tree finish_message_expr                       PARAMS ((tree, tree, tree));
-tree build_selector_expr                       PARAMS ((tree));
-tree build_ivar_reference                      PARAMS ((tree));
-tree build_keyword_decl                                PARAMS ((tree, tree, tree));
-tree build_method_decl                         PARAMS ((enum tree_code, tree, tree, tree));
-tree build_protocol_expr                       PARAMS ((tree));
-tree build_objc_string_object                  PARAMS ((tree));
-
-void objc_declare_alias                                PARAMS ((tree, tree));
-void objc_declare_class                                PARAMS ((tree));
-void objc_declare_protocols                    PARAMS ((tree));
+tree start_class (enum tree_code, tree, tree, tree);
+tree continue_class (tree);
+void finish_class (tree);
+void start_method_def (tree);
+void continue_method_def (void);
+void finish_method_def (void);
+tree start_protocol (enum tree_code, tree, tree);
+void finish_protocol (tree);
+
+tree objc_build_throw_stmt (tree);
+void objc_begin_try_stmt (location_t, tree);
+void objc_begin_catch_clause (tree);
+void objc_finish_catch_clause (void);
+void objc_build_finally_clause (location_t, tree);
+void objc_finish_try_stmt (void);
+void objc_build_synchronized (location_t, tree, tree);
+
+tree is_ivar (tree, tree);
+int is_private (tree);
+int objc_is_public (tree, tree);
+tree add_instance_variable (tree, int, tree, tree, tree);
+tree objc_add_method (tree, tree, int);
+tree get_super_receiver (void);
+void objc_clear_super_receiver (void);
+tree objc_get_class_ivars (tree);
+tree objc_get_class_reference (tree);
+tree get_static_reference (tree, tree);
+tree get_protocol_reference (tree);
+tree objc_build_message_expr (tree);
+tree finish_message_expr (tree, tree, tree);
+tree objc_build_selector_expr (tree);
+tree build_ivar_reference (tree);
+tree objc_build_keyword_decl (tree, tree, tree);
+tree build_method_decl (enum tree_code, tree, tree, tree);
+tree objc_build_protocol_expr (tree);
+tree objc_build_string_object (tree);
+
+void objc_declare_alias (tree, tree);
+void objc_declare_class (tree);
+void objc_declare_protocols (tree);
 
 /* the following routines are used to implement statically typed objects */
 
-int objc_comptypes                             PARAMS ((tree, tree, int));
-void objc_check_decl                           PARAMS ((tree));
+int objc_comptypes (tree, tree, int);
+void objc_check_decl (tree);
 
 /* NeXT extensions */
 
-tree build_encode_expr                         PARAMS ((tree));
+tree objc_build_encode_expr (tree);
 
 /* Objective-C structures */
 
+#define CLASS_LANG_SLOT_ELTS           6
+#define PROTOCOL_LANG_SLOT_ELTS                2
+
 /* KEYWORD_DECL */
 #define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name)
 #define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments)
@@ -90,37 +100,48 @@ tree build_encode_expr                             PARAMS ((tree));
    CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
    PROTOCOL_INTERFACE_TYPE */
 #define CLASS_NAME(CLASS) ((CLASS)->type.name)
-#define CLASS_SUPER_NAME(CLASS) ((CLASS)->type.context)
-#define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
-#define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
+#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)
 #define CLASS_NST_METHODS(CLASS) ((CLASS)->type.minval)
 #define CLASS_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
-#define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2)
-#define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3)
-#define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4)
-#define CLASS_OWN_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 5)
+#define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 2)
+#define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 3)
+#define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 4)
+#define CLASS_OWN_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 5)
 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
-#define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
+#define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
 #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
 #define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
-#define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
+#define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 1)
 #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS)
-#define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context)
+/* We need to distinguish TYPE_PROTOCOL_LISTs from TYPE_CONTEXTs, both of which
+   are stored in the same accessor slot.  */
+#define TYPE_PROTOCOL_LIST(TYPE)                               \
+       ((TYPE_CHECK (TYPE)->type.context                       \
+         && TREE_CODE ((TYPE)->type.context) == TREE_LIST)     \
+        ? (TYPE)->type.context : NULL_TREE)
+#define SET_TYPE_PROTOCOL_LIST(TYPE, P) (TYPE_CHECK (TYPE)->type.context = (P))
 
-/* Set by `continue_class' and checked by `is_public'.  */
+/* Set by `continue_class' and checked by `objc_is_public'.  */
 
-#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type))
+#define TREE_STATIC_TEMPLATE(record_type) (TREE_PRIVATE (record_type))
 #define TYPED_OBJECT(type) \
        (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type))
+#define OBJC_TYPE_NAME(type) TYPE_NAME(type)
 
 /* Define the Objective-C or Objective-C++ language-specific tree codes.  */
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
 enum objc_tree_code {
-#ifdef OBJCPLUS
+#if defined (GCC_CP_TREE_H)
   LAST_BASE_TREE_CODE = LAST_CPLUS_TREE_CODE,
-#else
+#else 
+#if defined (GCC_C_TREE_H)
   LAST_BASE_TREE_CODE = LAST_C_TREE_CODE,
+#else
+  #error You must include <c-tree.h> or <cp/cp-tree.h> before <objc/objc-act.h>
+#endif
 #endif
 #include "objc-tree.def"
   LAST_OBJC_TREE_CODE
@@ -147,7 +168,7 @@ struct hashed_entry GTY(())
 extern GTY ((length ("SIZEHASHTABLE"))) hash *nst_method_hash_list;
 extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_method_hash_list;
 
-#define SIZEHASHTABLE          257
+#define SIZEHASHTABLE          257
 
 /* Objective-C/Objective-C++ @implementation list.  */
 
@@ -178,6 +199,8 @@ enum objc_tree_index
     OCTI_SELF_DECL,
     OCTI_UMSG_DECL,
     OCTI_UMSG_SUPER_DECL,
+    OCTI_UMSG_STRET_DECL,
+    OCTI_UMSG_SUPER_STRET_DECL,
     OCTI_GET_CLASS_DECL,
     OCTI_GET_MCLASS_DECL,
     OCTI_SUPER_TYPE,
@@ -208,7 +231,6 @@ enum objc_tree_index
     OCTI_MCLS_DECL,
     OCTI_SEL_TABLE_DECL,
     OCTI_MODULES_DECL,
-    OCTI_STRG_DECL,
 
     OCTI_INTF_CTX,
     OCTI_IMPL_CTX,
@@ -241,7 +263,24 @@ enum objc_tree_index
     OCTI_CNST_STR_GLOB_ID,
     OCTI_STRING_CLASS_DECL,
     OCTI_SUPER_DECL,
-    
+    OCTI_UMSG_NONNIL_DECL,
+    OCTI_UMSG_NONNIL_STRET_DECL,
+    OCTI_STORAGE_CLS,
+    OCTI_EXCEPTION_EXTRACT_DECL,
+    OCTI_EXCEPTION_TRY_ENTER_DECL,
+    OCTI_EXCEPTION_TRY_EXIT_DECL,
+    OCTI_EXCEPTION_MATCH_DECL,
+    OCTI_EXCEPTION_THROW_DECL,
+    OCTI_SYNC_ENTER_DECL,
+    OCTI_SYNC_EXIT_DECL,
+    OCTI_SETJMP_DECL,
+    OCTI_EXCDATA_TEMPL,
+    OCTI_STACK_EXCEPTION_DATA_DECL,
+    OCTI_LOCAL_EXCEPTION_DECL,
+    OCTI_RETHROW_EXCEPTION_DECL,
+    OCTI_EVAL_ONCE_DECL,
+    OCTI_CATCH_TYPE,
+
     OCTI_MAX
 };
 
@@ -263,25 +302,27 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
 #define self_decl              objc_global_trees[OCTI_SELF_DECL]
 #define umsg_decl              objc_global_trees[OCTI_UMSG_DECL]
 #define umsg_super_decl                objc_global_trees[OCTI_UMSG_SUPER_DECL]
+#define umsg_stret_decl                objc_global_trees[OCTI_UMSG_STRET_DECL]
+#define umsg_super_stret_decl  objc_global_trees[OCTI_UMSG_SUPER_STRET_DECL]
 #define objc_get_class_decl    objc_global_trees[OCTI_GET_CLASS_DECL]
 #define objc_get_meta_class_decl                       \
                                objc_global_trees[OCTI_GET_MCLASS_DECL]
 
-#define super_type             objc_global_trees[OCTI_SUPER_TYPE]
-#define selector_type          objc_global_trees[OCTI_SEL_TYPE]
-#define id_type                        objc_global_trees[OCTI_ID_TYPE]
+#define objc_super_type                objc_global_trees[OCTI_SUPER_TYPE]
+#define objc_selector_type     objc_global_trees[OCTI_SEL_TYPE]
+#define objc_id_type           objc_global_trees[OCTI_ID_TYPE]
 #define objc_class_type                objc_global_trees[OCTI_CLS_TYPE]
-#define instance_type          objc_global_trees[OCTI_NST_TYPE]
-#define protocol_type          objc_global_trees[OCTI_PROTO_TYPE]
+#define objc_instance_type     objc_global_trees[OCTI_NST_TYPE]
+#define objc_protocol_type     objc_global_trees[OCTI_PROTO_TYPE]
 
 /* Type checking macros.  */
 
 #define IS_ID(TYPE) \
-  (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type))
+  (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (objc_id_type))
 #define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
   (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
 #define IS_SUPER(TYPE) \
-  (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (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]
@@ -314,7 +355,6 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
 #define UOBJC_METACLASS_decl           objc_global_trees[OCTI_MCLS_DECL]
 #define UOBJC_SELECTOR_TABLE_decl      objc_global_trees[OCTI_SEL_TABLE_DECL]
 #define UOBJC_MODULES_decl             objc_global_trees[OCTI_MODULES_DECL]
-#define UOBJC_STRINGS_decl             objc_global_trees[OCTI_STRG_DECL]
 
 /* The following are used when compiling a class implementation.
    implementation_template will normally be an interface, however if
@@ -335,6 +375,31 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
 #define ucls_super_ref         objc_global_trees[OCTI_UCLS_SUPER_REF]
 #define uucls_super_ref                objc_global_trees[OCTI_UUCLS_SUPER_REF]
 
+#define umsg_nonnil_decl       objc_global_trees[OCTI_UMSG_NONNIL_DECL]
+#define umsg_nonnil_stret_decl objc_global_trees[OCTI_UMSG_NONNIL_STRET_DECL]
+#define objc_storage_class     objc_global_trees[OCTI_STORAGE_CLS]
+#define objc_exception_extract_decl            \
+                               objc_global_trees[OCTI_EXCEPTION_EXTRACT_DECL]
+#define objc_exception_try_enter_decl          \
+                               objc_global_trees[OCTI_EXCEPTION_TRY_ENTER_DECL]
+#define objc_exception_try_exit_decl           \
+                               objc_global_trees[OCTI_EXCEPTION_TRY_EXIT_DECL]
+#define objc_exception_match_decl              \
+                               objc_global_trees[OCTI_EXCEPTION_MATCH_DECL]
+#define objc_exception_throw_decl              \
+                               objc_global_trees[OCTI_EXCEPTION_THROW_DECL]
+#define objc_sync_enter_decl   objc_global_trees[OCTI_SYNC_ENTER_DECL]
+#define objc_sync_exit_decl    objc_global_trees[OCTI_SYNC_EXIT_DECL]
+#define objc_exception_data_template           \
+                               objc_global_trees[OCTI_EXCDATA_TEMPL]
+#define objc_setjmp_decl       objc_global_trees[OCTI_SETJMP_DECL]
+#define objc_stack_exception_data              \
+                               objc_global_trees[OCTI_STACK_EXCEPTION_DATA_DECL]
+#define objc_caught_exception  objc_global_trees[OCTI_LOCAL_EXCEPTION_DECL]    
+#define objc_rethrow_exception objc_global_trees[OCTI_RETHROW_EXCEPTION_DECL]  
+#define objc_eval_once         objc_global_trees[OCTI_EVAL_ONCE_DECL]  
+#define objc_catch_type                objc_global_trees[OCTI_CATCH_TYPE]
+
 #define objc_method_template   objc_global_trees[OCTI_METH_TEMPL]
 #define objc_ivar_template     objc_global_trees[OCTI_IVAR_TEMPL]
 #define objc_symtab_template   objc_global_trees[OCTI_SYMTAB_TEMPL]
@@ -345,7 +410,7 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
                                objc_global_trees[OCTI_METH_PROTO_TEMPL]
 #define function1_template     objc_global_trees[OCTI_FUNCTION1_TEMPL]
 #define function2_template     objc_global_trees[OCTI_FUNCTION2_TEMPL]
-                               
+
 #define objc_object_id         objc_global_trees[OCTI_OBJ_ID]
 #define objc_class_id          objc_global_trees[OCTI_CLS_ID]
 #define objc_id_id             objc_global_trees[OCTI_ID_ID]