2002-01-04 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / gdb / cp-abi.c
CommitLineData
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
25struct cp_abi_ops current_cp_abi;
26
27struct cp_abi_ops *cp_abis;
28
29int num_cp_abis = 0;
30
31enum ctor_kinds
32is_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
39enum dtor_kinds
40is_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
47int
48is_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
55int
56is_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
1514d34e
DJ
63int
64baseclass_offset (struct type *type, int index, char *valaddr,
65 CORE_ADDR address)
66{
67 if (current_cp_abi.baseclass_offset == NULL)
68 error ("ABI doesn't define required function baseclass_offset");
69 return (*current_cp_abi.baseclass_offset) (type, index, valaddr, address);
70}
71
e933e538
AC
72struct value *
73value_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
015a42b4
JB
74 struct type * type, int offset)
75{
76 if ((current_cp_abi.virtual_fn_field) == NULL)
77 return NULL;
78 return (*current_cp_abi.virtual_fn_field) (arg1p, f, j, type, offset);
79}
1514d34e 80
015a42b4 81struct type *
e933e538 82value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
015a42b4
JB
83{
84 if ((current_cp_abi.rtti_type) == NULL)
85 return NULL;
86 return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
87}
88
89int
90register_cp_abi (struct cp_abi_ops abi)
91{
92 cp_abis =
93 xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
94 cp_abis[num_cp_abis++] = abi;
95
96 return 1;
97
98}
99
100int
101switch_to_cp_abi (const char *short_name)
102{
103 int i;
104 for (i = 0; i < num_cp_abis; i++)
105 if (strcmp (cp_abis[i].shortname, short_name) == 0)
106 current_cp_abi = cp_abis[i];
107 return 1;
108}
109
This page took 0.070264 seconds and 4 git commands to generate.