* Makefile.in (osabi.o, i387-tdep.o, i386-linux-nat.o, lin-lwp.o,
[deliverable/binutils-gdb.git] / gdb / cp-abi.c
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 #include "gdb_string.h"
25
26 struct cp_abi_ops current_cp_abi;
27
28 struct cp_abi_ops *cp_abis;
29
30 int num_cp_abis = 0;
31
32 enum ctor_kinds
33 is_constructor_name (const char *name)
34 {
35 if ((current_cp_abi.is_constructor_name) == NULL)
36 error ("ABI doesn't define required function is_constructor_name");
37 return (*current_cp_abi.is_constructor_name) (name);
38 }
39
40 enum dtor_kinds
41 is_destructor_name (const char *name)
42 {
43 if ((current_cp_abi.is_destructor_name) == NULL)
44 error ("ABI doesn't define required function is_destructor_name");
45 return (*current_cp_abi.is_destructor_name) (name);
46 }
47
48 int
49 is_vtable_name (const char *name)
50 {
51 if ((current_cp_abi.is_vtable_name) == NULL)
52 error ("ABI doesn't define required function is_vtable_name");
53 return (*current_cp_abi.is_vtable_name) (name);
54 }
55
56 int
57 is_operator_name (const char *name)
58 {
59 if ((current_cp_abi.is_operator_name) == NULL)
60 error ("ABI doesn't define required function is_operator_name");
61 return (*current_cp_abi.is_operator_name) (name);
62 }
63
64 int
65 baseclass_offset (struct type *type, int index, char *valaddr,
66 CORE_ADDR address)
67 {
68 if (current_cp_abi.baseclass_offset == NULL)
69 error ("ABI doesn't define required function baseclass_offset");
70 return (*current_cp_abi.baseclass_offset) (type, index, valaddr, address);
71 }
72
73 struct value *
74 value_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
75 struct type * type, int offset)
76 {
77 if ((current_cp_abi.virtual_fn_field) == NULL)
78 return NULL;
79 return (*current_cp_abi.virtual_fn_field) (arg1p, f, j, type, offset);
80 }
81
82 struct type *
83 value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
84 {
85 if ((current_cp_abi.rtti_type) == NULL)
86 return NULL;
87 return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
88 }
89
90 int
91 register_cp_abi (struct cp_abi_ops abi)
92 {
93 cp_abis =
94 xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
95 cp_abis[num_cp_abis++] = abi;
96
97 return 1;
98
99 }
100
101 int
102 switch_to_cp_abi (const char *short_name)
103 {
104 int i;
105 for (i = 0; i < num_cp_abis; i++)
106 if (strcmp (cp_abis[i].shortname, short_name) == 0)
107 current_cp_abi = cp_abis[i];
108 return 1;
109 }
110
This page took 0.04886 seconds and 5 git commands to generate.