diff options
author | Ziemowit Laski <zlaski@apple.com> | 2004-12-16 01:10:38 +0000 |
---|---|---|
committer | Ziemowit Laski <zlaski@gcc.gnu.org> | 2004-12-16 01:10:38 +0000 |
commit | 035e8f01490bdd11ac29dfc07e79e7975d2c53cc (patch) | |
tree | a3a7db25ede93c8e5aeb13d64bd697265fcaeed9 /gcc/objc/objc-act.h | |
parent | 6591c4a79d52bd310cd425b558be4326c321b5f4 (diff) | |
download | gcc-035e8f01490bdd11ac29dfc07e79e7975d2c53cc.zip gcc-035e8f01490bdd11ac29dfc07e79e7975d2c53cc.tar.gz gcc-035e8f01490bdd11ac29dfc07e79e7975d2c53cc.tar.bz2 |
objc-act.c (build_private_template): Change to return 'void'...
[gcc/objc/ChangeLog]
2004-12-15 Ziemowit Laski <zlaski@apple.com>
* objc-act.c (build_private_template): Change to return 'void'; do
not set ivar_context, uprivate_record or objc_instance_type.
(objc_comptypes, gen_type_name_0): For types 'id' and 'Class',
retrieve protocol list from the pointee rather than the pointer itself;
check TYPE_HAS_OBJC_INFO(...) precondition before accessing
TYPE_OBJC_PROTOCOL_LIST.
(objc_get_protocol_qualified_type): For types 'id' and 'Class',
construct a variant of the pointee as well as the pointer, and
store protocol information in the former. When creating variants
of RECORD_TYPEs, clone their TYPE_LANG_SPECIFIC fields and propagate
TYPE_OBJC_INTERFACE information.
(objc_declare_class): If a TYPE_DECL is looked up, retrieve the
underlying RECORD_TYPE to check for presence of TYPE_OBJC_INTERFACE;
for newly-created RECORD_TYPEs, create a tentative TYPE_OBJC_INTERFACE
holding an IDENTIFIER_NODE.
(objc_finish_message_expr): Check TYPE_HAS_OBJC_INFO(...) before
accessing TYPE_OBJC_PROTOCOL_LIST; Use TYPE_OBJC_INTERFACE instead
of calling lookup_interface(); allow for TYPE_OBJC_INTERFACE holding
an IDENTIFIER_NODE (meaning a @class forward-declaration only).
(objc_is_public): Check TYPE_OBJC_INTERFACE instead of calling
lookup_interface().
(continue_class): For @implementations, set ivar_context,
uprivate_record and objc_instance_type, for @interfaces, call
build_private_template().
(encode_pointer): Check TYPE_HAS_OBJC_INFO(...) before accessing
TYPE_OBJC_INTERFACE.
(objc_types_are_equivalent): Check TYPE_HAS_OBJC_INFO(...) before
accessing TYPE_OBJC_PROTOCOL_LIST.
* objc-act.h (OBJC_INFO_SLOT_ELTS, TYPE_OBJC_INFO, INIT_TYPE_OBJC_INFO,
DUP_TYPE_OBJC_INFO, ALLOC_OBJC_TYPE_LANG_SPECIFIC,
SIZEOF_OBJC_TYPE_LANG_SPECIFIC): New macros.
(TYPE_OBJC_INTERFACE): Replaces TREE_STATIC_INSTANCE and now points
to an actual @interface; stored in TYPE_LANG_SPECIFIC(...).
(TYPE_OBJC_PROTOCOL_LIST): Replaces TYPE_PROTOCOL_LIST; stored in
TYPE_LANG_SPECIFIC(...).
(TREE_STATIC_INSTANCE, TYPE_PROTOCOL_LIST): Delete.
(IS_ID, IS_CLASS, IS_PROTOCOL_QUALIFIED_UNTYPED, IS_SUPER,
TYPED_OBJECT): Check for POINTER_TYPE rather than POINTER_TYPE_P;
adjust for use of TYPE_OBJC_INTERFACE and TYPE_OBJC_PROTOCOL_LIST
instead of TREE_STATIC_INSTANCE and TYPE_PROTOCOL_LIST.
From-SVN: r92239
Diffstat (limited to 'gcc/objc/objc-act.h')
-rw-r--r-- | gcc/objc/objc-act.h | 82 |
1 files changed, 61 insertions, 21 deletions
diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index d13e374..e52e0f0 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -36,6 +36,7 @@ tree objc_fold_obj_type_ref (tree, tree); #define CLASS_LANG_SLOT_ELTS 5 #define PROTOCOL_LANG_SLOT_ELTS 2 +#define OBJC_INFO_SLOT_ELTS 2 /* KEYWORD_DECL */ #define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name) @@ -67,19 +68,51 @@ tree objc_fold_obj_type_ref (tree, tree); #define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 1) #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS) -/* 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)) - -#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type)) -#define TYPED_OBJECT(type) \ - (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type)) -#define OBJC_TYPE_NAME(type) TYPE_NAME(type) -#define OBJC_SET_TYPE_NAME(type, name) (TYPE_NAME (type) = name) +/* ObjC-specific information pertaining to RECORD_TYPEs are stored in + the LANG_SPECIFIC structures, which may itself need allocating first. */ +#define TYPE_OBJC_INFO(TYPE) TYPE_LANG_SPECIFIC (TYPE)->objc_info +#define TYPE_HAS_OBJC_INFO(TYPE) \ + (TYPE_LANG_SPECIFIC (TYPE) \ + && TYPE_LANG_SPECIFIC (TYPE)->objc_info) +#define TYPE_OBJC_INTERFACE(TYPE) TREE_VEC_ELT (TYPE_OBJC_INFO (TYPE), 0) +#define TYPE_OBJC_PROTOCOL_LIST(TYPE) TREE_VEC_ELT (TYPE_OBJC_INFO (TYPE), 1) + +#define INIT_TYPE_OBJC_INFO(TYPE) \ + do \ + { \ + if (!TYPE_LANG_SPECIFIC (TYPE)) \ + TYPE_LANG_SPECIFIC (TYPE) \ + = ALLOC_OBJC_TYPE_LANG_SPECIFIC; \ + if (!TYPE_LANG_SPECIFIC (TYPE)->objc_info) \ + TYPE_LANG_SPECIFIC (TYPE)->objc_info \ + = make_tree_vec (OBJC_INFO_SLOT_ELTS); \ + } \ + while (0) +#define DUP_TYPE_OBJC_INFO(DST, SRC) \ + do \ + { \ + TYPE_LANG_SPECIFIC (DST) \ + = ALLOC_OBJC_TYPE_LANG_SPECIFIC; \ + if (TYPE_LANG_SPECIFIC (SRC)) \ + memcpy (TYPE_LANG_SPECIFIC (DST), \ + TYPE_LANG_SPECIFIC (SRC), \ + SIZEOF_OBJC_TYPE_LANG_SPECIFIC); \ + TYPE_LANG_SPECIFIC (DST)->objc_info \ + = make_tree_vec (OBJC_INFO_SLOT_ELTS); \ + } \ + while (0) + +/* The following two macros must be overridden (in objcp/objcp-decl.h) + for Objective-C++. */ +#define ALLOC_OBJC_TYPE_LANG_SPECIFIC GGC_CNEW (struct lang_type) +#define SIZEOF_OBJC_TYPE_LANG_SPECIFIC sizeof (struct lang_type) + +#define TYPED_OBJECT(TYPE) \ + (TREE_CODE (TYPE) == RECORD_TYPE \ + && TYPE_HAS_OBJC_INFO (TYPE) \ + && TYPE_OBJC_INTERFACE (TYPE)) +#define OBJC_TYPE_NAME(TYPE) TYPE_NAME(TYPE) +#define OBJC_SET_TYPE_NAME(TYPE, NAME) (TYPE_NAME (TYPE) = NAME) /* Define the Objective-C or Objective-C++ language-specific tree codes. */ @@ -273,14 +306,21 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; /* Type checking macros. */ -#define IS_ID(TYPE) \ - (POINTER_TYPE_P (TYPE) && TREE_TYPE (TYPE) == TREE_TYPE (objc_object_type)) -#define IS_CLASS(TYPE) \ - (POINTER_TYPE_P (TYPE) && TREE_TYPE (TYPE) == TREE_TYPE (objc_class_type)) -#define IS_PROTOCOL_QUALIFIED_UNTYPED(TYPE) \ - ((IS_ID (TYPE) || IS_CLASS (TYPE)) && TYPE_PROTOCOL_LIST (TYPE)) -#define IS_SUPER(TYPE) \ - (POINTER_TYPE_P (TYPE) && TREE_TYPE (TYPE) == objc_super_template) +#define IS_ID(TYPE) \ + (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] |