Commit | Line | Data |
---|---|---|
015a42b4 JB |
1 | /* Generic code for supporting multiple C++ ABI's |
2 | Copyright 2001 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "defs.h" | |
22 | #include "value.h" | |
23 | #include "cp-abi.h" | |
24 | ||
25 | struct cp_abi_ops current_cp_abi; | |
26 | ||
27 | struct cp_abi_ops *cp_abis; | |
28 | ||
29 | int num_cp_abis = 0; | |
30 | ||
31 | enum ctor_kinds | |
32 | is_constructor_name (const char *name) | |
33 | { | |
34 | if ((current_cp_abi.is_constructor_name) == NULL) | |
35 | error ("ABI doesn't define required function is_constructor_name"); | |
36 | return (*current_cp_abi.is_constructor_name) (name); | |
37 | } | |
38 | ||
39 | enum dtor_kinds | |
40 | is_destructor_name (const char *name) | |
41 | { | |
42 | if ((current_cp_abi.is_destructor_name) == NULL) | |
43 | error ("ABI doesn't define required function is_destructor_name"); | |
44 | return (*current_cp_abi.is_destructor_name) (name); | |
45 | } | |
46 | ||
47 | int | |
48 | is_vtable_name (const char *name) | |
49 | { | |
50 | if ((current_cp_abi.is_vtable_name) == NULL) | |
51 | error ("ABI doesn't define required function is_vtable_name"); | |
52 | return (*current_cp_abi.is_vtable_name) (name); | |
53 | } | |
54 | ||
55 | int | |
56 | is_operator_name (const char *name) | |
57 | { | |
58 | if ((current_cp_abi.is_operator_name) == NULL) | |
59 | error ("ABI doesn't define required function is_operator_name"); | |
60 | return (*current_cp_abi.is_operator_name) (name); | |
61 | } | |
62 | ||
63 | value_ptr | |
64 | value_virtual_fn_field (value_ptr * arg1p, struct fn_field * f, int j, | |
65 | struct type * type, int offset) | |
66 | { | |
67 | if ((current_cp_abi.virtual_fn_field) == NULL) | |
68 | return NULL; | |
69 | return (*current_cp_abi.virtual_fn_field) (arg1p, f, j, type, offset); | |
70 | } | |
71 | struct type * | |
72 | value_rtti_type (value_ptr v, int *full, int *top, int *using_enc) | |
73 | { | |
74 | if ((current_cp_abi.rtti_type) == NULL) | |
75 | return NULL; | |
76 | return (*current_cp_abi.rtti_type) (v, full, top, using_enc); | |
77 | } | |
78 | ||
79 | int | |
80 | register_cp_abi (struct cp_abi_ops abi) | |
81 | { | |
82 | cp_abis = | |
83 | xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops)); | |
84 | cp_abis[num_cp_abis++] = abi; | |
85 | ||
86 | return 1; | |
87 | ||
88 | } | |
89 | ||
90 | int | |
91 | switch_to_cp_abi (const char *short_name) | |
92 | { | |
93 | int i; | |
94 | for (i = 0; i < num_cp_abis; i++) | |
95 | if (strcmp (cp_abis[i].shortname, short_name) == 0) | |
96 | current_cp_abi = cp_abis[i]; | |
97 | return 1; | |
98 | } | |
99 |