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