namespace.h revision 1.1 1 1.1 christos /* Code dealing with "using" directives for GDB.
2 1.1 christos Copyright (C) 2003-2016 Free Software Foundation, Inc.
3 1.1 christos
4 1.1 christos This file is part of GDB.
5 1.1 christos
6 1.1 christos This program is free software; you can redistribute it and/or modify
7 1.1 christos it under the terms of the GNU General Public License as published by
8 1.1 christos the Free Software Foundation; either version 3 of the License, or
9 1.1 christos (at your option) any later version.
10 1.1 christos
11 1.1 christos This program is distributed in the hope that it will be useful,
12 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 1.1 christos GNU General Public License for more details.
15 1.1 christos
16 1.1 christos You should have received a copy of the GNU General Public License
17 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 1.1 christos
19 1.1 christos #ifndef NAMESPACE_H
20 1.1 christos #define NAMESPACE_H
21 1.1 christos
22 1.1 christos #include "vec.h"
23 1.1 christos #include "gdb_vecs.h"
24 1.1 christos #include "gdb_obstack.h"
25 1.1 christos
26 1.1 christos /* This struct is designed to store data from using directives. It
27 1.1 christos says that names from namespace IMPORT_SRC should be visible within
28 1.1 christos namespace IMPORT_DEST. These form a linked list; NEXT is the next
29 1.1 christos element of the list. If the imported namespace or declaration has
30 1.1 christos been aliased within the IMPORT_DEST namespace, ALIAS is set to a
31 1.1 christos string representing the alias. Otherwise, ALIAS is NULL.
32 1.1 christos DECLARATION is the name of the imported declaration, if this import
33 1.1 christos statement represents one. Otherwise DECLARATION is NULL and this
34 1.1 christos import statement represents a namespace.
35 1.1 christos
36 1.1 christos C++: using namespace A;
37 1.1 christos Fortran: use A
38 1.1 christos import_src = "A"
39 1.1 christos import_dest = local scope of the import statement even such as ""
40 1.1 christos alias = NULL
41 1.1 christos declaration = NULL
42 1.1 christos excludes = NULL
43 1.1 christos
44 1.1 christos C++: using A::x;
45 1.1 christos Fortran: use A, only: x
46 1.1 christos import_src = "A"
47 1.1 christos import_dest = local scope of the import statement even such as ""
48 1.1 christos alias = NULL
49 1.1 christos declaration = "x"
50 1.1 christos excludes = NULL
51 1.1 christos The declaration will get imported as import_dest::x.
52 1.1 christos
53 1.1 christos C++ has no way to import all names except those listed ones.
54 1.1 christos Fortran: use A, localname => x
55 1.1 christos import_src = "A"
56 1.1 christos import_dest = local scope of the import statement even such as ""
57 1.1 christos alias = "localname"
58 1.1 christos declaration = "x"
59 1.1 christos excludes = NULL
60 1.1 christos +
61 1.1 christos import_src = "A"
62 1.1 christos import_dest = local scope of the import statement even such as ""
63 1.1 christos alias = NULL
64 1.1 christos declaration = NULL
65 1.1 christos excludes = ["x"]
66 1.1 christos All the entries of A get imported except of "x". "x" gets imported as
67 1.1 christos "localname". "x" is not defined as a local name by this statement.
68 1.1 christos
69 1.1 christos C++: namespace LOCALNS = A;
70 1.1 christos Fortran has no way to address non-local namespace/module.
71 1.1 christos import_src = "A"
72 1.1 christos import_dest = local scope of the import statement even such as ""
73 1.1 christos alias = "LOCALNS"
74 1.1 christos declaration = NULL
75 1.1 christos excludes = NULL
76 1.1 christos The namespace will get imported as the import_dest::LOCALNS
77 1.1 christos namespace.
78 1.1 christos
79 1.1 christos C++ cannot express it, it would be something like: using localname
80 1.1 christos = A::x;
81 1.1 christos Fortran: use A, only localname => x
82 1.1 christos import_src = "A"
83 1.1 christos import_dest = local scope of the import statement even such as ""
84 1.1 christos alias = "localname"
85 1.1 christos declaration = "x"
86 1.1 christos excludes = NULL
87 1.1 christos The declaration will get imported as localname or
88 1.1 christos `import_dest`localname. */
89 1.1 christos
90 1.1 christos struct using_direct
91 1.1 christos {
92 1.1 christos const char *import_src;
93 1.1 christos const char *import_dest;
94 1.1 christos
95 1.1 christos const char *alias;
96 1.1 christos const char *declaration;
97 1.1 christos
98 1.1 christos struct using_direct *next;
99 1.1 christos
100 1.1 christos /* Used during import search to temporarily mark this node as
101 1.1 christos searched. */
102 1.1 christos int searched;
103 1.1 christos
104 1.1 christos /* USING_DIRECT has variable allocation size according to the number of
105 1.1 christos EXCLUDES entries, the last entry is NULL. */
106 1.1 christos const char *excludes[1];
107 1.1 christos };
108 1.1 christos
109 1.1 christos extern void add_using_directive (struct using_direct **using_directives,
110 1.1 christos const char *dest,
111 1.1 christos const char *src,
112 1.1 christos const char *alias,
113 1.1 christos const char *declaration,
114 1.1 christos VEC (const_char_ptr) *excludes,
115 1.1 christos int copy_names,
116 1.1 christos struct obstack *obstack);
117 1.1 christos
118 1.1 christos #endif /* NAMESPACE_H */
119