1 /* Hooks to abstract the runtime meta-data generation for Objective C.
2 Copyright (C) 2011 Free Software Foundation, Inc.
3 Contributed by Iain Sandoe
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _OBJC_RUNTIME_HOOKS_H_
22 #define _OBJC_RUNTIME_HOOKS_H_
24 /* A set of hooks for the front end to obtain runtime-specific actions. */
26 /* Objective-C supports several runtime library variants:
28 "GNU" runtime selected by -fgnu-runtime (currently at API version 1).
29 "NeXT" runtime (selected by -fnext-runtime) and installed on OSX/Darwin
30 systems at API version 1 (for m32 code) and version 2 (for m64 code).
32 The runtimes require different data types/layouts, method call mechanisms
33 and so on, and the purpose of this interface is to abstract such
34 differences from the parser's perspective. */
36 typedef struct _objc_runtime_hooks_r
38 /* Initialize for this runtime. */
39 void (*initialize
) (void);
40 const char *default_constant_string_class_name
;
42 /* FIXME: Having to check this name should not be necessary. */
43 const char *tag_getclass
;
44 /* id for superclass class field - named differently in the existing
46 tree (*super_superclassfield_ident
) (void);
48 /* Obtain a class decl for the identifier. */
49 tree (*class_decl
) (tree
);
50 /* Obtain a metaclass decl for the identifier. */
51 tree (*metaclass_decl
) (tree
);
52 /* Obtain a category decl for the identifier. */
53 tree (*category_decl
) (tree
);
54 /* Obtain a protocol decl for the identifier. */
55 tree (*protocol_decl
) (tree
);
56 /* Obtain a string decl, to be placed in the nominated string-section. */
57 tree (*string_decl
) (tree
, const char *, string_section
);
59 /* Obtain a class reference, generating the fwd def. if necessary. */
60 tree (*get_class_reference
) (tree
);
61 /* build/get selector reference. */
62 tree (*build_selector_reference
) (location_t
, tree
, tree
);
63 /* Get a protocol reference, generating the forward def. if necessary. */
64 tree (*get_protocol_reference
) (location_t
, tree
);
65 /* Get an ivar ref. re the base. */
66 tree (*build_ivar_reference
) (location_t
, tree
, tree
);
67 /* Get a reference to {meta}class' super. */
68 tree (*get_class_super_ref
) (location_t
, struct imp_entry
*, bool);
69 /* Get a reference to Category {meta}class' super. */
70 tree (*get_category_super_ref
) (location_t
, struct imp_entry
*, bool);
72 /* Receiver is class Object, check runtime-specific. */
73 tree (*receiver_is_class_object
) (tree
);
74 /* Get the start of a method argument type list (receiver, _cmd). */
75 tree (*get_arg_type_list_base
) (tree
, int, int);
76 /* Build method call. */
77 tree (*build_objc_method_call
) (location_t
, tree
, tree
, tree
, tree
, tree
, int);
79 /* Check for or otherwise handle a request to check that the constant
80 string class reference is set-up & OK. */
81 bool (*setup_const_string_class_decl
) (void);
82 /* Return the tree reprenting a const string constructor for the arg.
83 Most of the data are in global trees. */
84 tree (*build_const_string_constructor
) (location_t
, tree
, int);
87 tree (*build_throw_stmt
) (location_t
, tree
, bool);
88 tree (*build_exc_ptr
) (struct objc_try_context
**);
89 tree (*begin_catch
) (struct objc_try_context
**, tree
, tree
, tree
, bool);
90 void (*finish_catch
) (struct objc_try_context
**, tree
);
91 tree (*finish_try_stmt
) (struct objc_try_context
**);
93 /* Emit all the metadata required by the runtime - based on the tables built
95 void (*generate_metadata
) (void);
99 /* For shared support that needs to access these. */
100 extern objc_runtime_hooks runtime
;
102 /* One per runtime at present.
103 TODO: Make into some kind of configury-generated table. */
104 extern bool objc_gnu_runtime_abi_01_init (objc_runtime_hooks
*);
105 extern bool objc_next_runtime_abi_01_init (objc_runtime_hooks
*);
106 extern bool objc_next_runtime_abi_02_init (objc_runtime_hooks
*);
108 #endif /* _OBJC_RUNTIME_HOOKS_H_ */