1 |
717 |
jeremybenn |
/* Hooks to abstract the runtime meta-data generation for Objective C.
|
2 |
|
|
Copyright (C) 2011 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Iain Sandoe
|
4 |
|
|
|
5 |
|
|
This file is part of GCC.
|
6 |
|
|
|
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)
|
10 |
|
|
any later version.
|
11 |
|
|
|
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.
|
16 |
|
|
|
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/>. */
|
20 |
|
|
|
21 |
|
|
#ifndef _OBJC_RUNTIME_HOOKS_H_
|
22 |
|
|
#define _OBJC_RUNTIME_HOOKS_H_
|
23 |
|
|
|
24 |
|
|
/* A set of hooks for the front end to obtain runtime-specific actions. */
|
25 |
|
|
|
26 |
|
|
/* Objective-C supports several runtime library variants:
|
27 |
|
|
|
28 |
|
|
"GNU" runtime selected by -fgnu-runtime (currently at ABI version 8).
|
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).
|
31 |
|
|
|
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. */
|
35 |
|
|
|
36 |
|
|
/* TODO: Do we want the initial underscore ? */
|
37 |
|
|
typedef struct _objc_runtime_hooks_r
|
38 |
|
|
{
|
39 |
|
|
/* TODO: Expand comments in this file. */
|
40 |
|
|
|
41 |
|
|
/* Initialize for this runtime. */
|
42 |
|
|
void (*initialize) (void);
|
43 |
|
|
const char *default_constant_string_class_name;
|
44 |
|
|
|
45 |
|
|
/* FIXME: Having to check this name should not be necessary. */
|
46 |
|
|
const char *tag_getclass;
|
47 |
|
|
/* id for superclass class field - named differently in the existing
|
48 |
|
|
runtimes. */
|
49 |
|
|
tree (*super_superclassfield_ident) (void);
|
50 |
|
|
|
51 |
|
|
/* Obtain a class decl for the identifier. */
|
52 |
|
|
tree (*class_decl) (tree);
|
53 |
|
|
/* Obtain a metaclass decl for the identifier. */
|
54 |
|
|
tree (*metaclass_decl) (tree);
|
55 |
|
|
/* Obtain a category decl for the identifier. */
|
56 |
|
|
tree (*category_decl) (tree);
|
57 |
|
|
/* Obtain a protocol decl for the identifier. */
|
58 |
|
|
tree (*protocol_decl) (tree);
|
59 |
|
|
/* Obtain a string decl, to be placed in the nominated string-section. */
|
60 |
|
|
tree (*string_decl) (tree, const char *, string_section);
|
61 |
|
|
|
62 |
|
|
/* Obtain a class reference, generating the fwd def. if necessary. */
|
63 |
|
|
tree (*get_class_reference) (tree);
|
64 |
|
|
/* build/get selector reference. */
|
65 |
|
|
tree (*build_selector_reference) (location_t, tree, tree);
|
66 |
|
|
/* Get a protocol reference, generating the forward def. if necessary. */
|
67 |
|
|
tree (*get_protocol_reference) (location_t, tree);
|
68 |
|
|
/* Get an ivar ref. re the base. */
|
69 |
|
|
tree (*build_ivar_reference) (location_t, tree, tree);
|
70 |
|
|
/* Get a reference to {meta}class' super. */
|
71 |
|
|
tree (*get_class_super_ref) (location_t, struct imp_entry *, bool);
|
72 |
|
|
/* Get a reference to Category {meta}class' super. */
|
73 |
|
|
tree (*get_category_super_ref) (location_t, struct imp_entry *, bool);
|
74 |
|
|
|
75 |
|
|
/* Receiver is class Object, check runtime-specific. */
|
76 |
|
|
tree (*receiver_is_class_object) (tree);
|
77 |
|
|
/* Get the start of a method argument type list (receiver, _cmd). */
|
78 |
|
|
void (*get_arg_type_list_base) (VEC(tree,gc) **, tree, int, int);
|
79 |
|
|
/* Build method call. */
|
80 |
|
|
tree (*build_objc_method_call) (location_t, tree, tree, tree, tree, tree, int);
|
81 |
|
|
|
82 |
|
|
/* Check for or otherwise handle a request to check that the constant
|
83 |
|
|
string class reference is set-up & OK. */
|
84 |
|
|
bool (*setup_const_string_class_decl) (void);
|
85 |
|
|
/* Return the tree reprenting a const string constructor for the arg.
|
86 |
|
|
Most of the data are in global trees. */
|
87 |
|
|
tree (*build_const_string_constructor) (location_t, tree, int);
|
88 |
|
|
|
89 |
|
|
/* Exceptions. */
|
90 |
|
|
tree (*build_throw_stmt) (location_t, tree, bool);
|
91 |
|
|
tree (*build_exc_ptr) (struct objc_try_context **);
|
92 |
|
|
tree (*begin_catch) (struct objc_try_context **, tree, tree, tree, bool);
|
93 |
|
|
void (*finish_catch) (struct objc_try_context **, tree);
|
94 |
|
|
tree (*finish_try_stmt) (struct objc_try_context **);
|
95 |
|
|
|
96 |
|
|
/* Emit all the metadata required by the runtime - based on the tables built
|
97 |
|
|
during parsing. */
|
98 |
|
|
void (*generate_metadata) (void);
|
99 |
|
|
|
100 |
|
|
} objc_runtime_hooks;
|
101 |
|
|
|
102 |
|
|
/* For shared support that needs to access these. */
|
103 |
|
|
extern objc_runtime_hooks runtime;
|
104 |
|
|
|
105 |
|
|
/* One per runtime at present.
|
106 |
|
|
TODO: Make into some kind of configury-generated table. */
|
107 |
|
|
extern bool objc_gnu_runtime_abi_01_init (objc_runtime_hooks *);
|
108 |
|
|
extern bool objc_next_runtime_abi_01_init (objc_runtime_hooks *);
|
109 |
|
|
extern bool objc_next_runtime_abi_02_init (objc_runtime_hooks *);
|
110 |
|
|
|
111 |
|
|
#endif /* _OBJC_RUNTIME_HOOKS_H_ */
|