Commit | Line | Data |
---|---|---|
22cee43f | 1 | /* Code dealing with "using" directives for GDB. |
42a4f53d | 2 | Copyright (C) 2003-2019 Free Software Foundation, Inc. |
22cee43f PMR |
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 3 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, see <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #ifndef NAMESPACE_H | |
20 | #define NAMESPACE_H | |
21 | ||
0747795c TT |
22 | #include "common/vec.h" |
23 | #include "common/gdb_vecs.h" | |
22cee43f PMR |
24 | #include "gdb_obstack.h" |
25 | ||
26 | /* This struct is designed to store data from using directives. It | |
27 | says that names from namespace IMPORT_SRC should be visible within | |
28 | namespace IMPORT_DEST. These form a linked list; NEXT is the next | |
29 | element of the list. If the imported namespace or declaration has | |
30 | been aliased within the IMPORT_DEST namespace, ALIAS is set to a | |
31 | string representing the alias. Otherwise, ALIAS is NULL. | |
32 | DECLARATION is the name of the imported declaration, if this import | |
33 | statement represents one. Otherwise DECLARATION is NULL and this | |
34 | import statement represents a namespace. | |
35 | ||
36 | C++: using namespace A; | |
37 | Fortran: use A | |
38 | import_src = "A" | |
39 | import_dest = local scope of the import statement even such as "" | |
40 | alias = NULL | |
41 | declaration = NULL | |
42 | excludes = NULL | |
43 | ||
44 | C++: using A::x; | |
45 | Fortran: use A, only: x | |
46 | import_src = "A" | |
47 | import_dest = local scope of the import statement even such as "" | |
48 | alias = NULL | |
49 | declaration = "x" | |
50 | excludes = NULL | |
51 | The declaration will get imported as import_dest::x. | |
52 | ||
53 | C++ has no way to import all names except those listed ones. | |
54 | Fortran: use A, localname => x | |
55 | import_src = "A" | |
56 | import_dest = local scope of the import statement even such as "" | |
57 | alias = "localname" | |
58 | declaration = "x" | |
59 | excludes = NULL | |
60 | + | |
61 | import_src = "A" | |
62 | import_dest = local scope of the import statement even such as "" | |
63 | alias = NULL | |
64 | declaration = NULL | |
65 | excludes = ["x"] | |
66 | All the entries of A get imported except of "x". "x" gets imported as | |
67 | "localname". "x" is not defined as a local name by this statement. | |
68 | ||
69 | C++: namespace LOCALNS = A; | |
70 | Fortran has no way to address non-local namespace/module. | |
71 | import_src = "A" | |
72 | import_dest = local scope of the import statement even such as "" | |
73 | alias = "LOCALNS" | |
74 | declaration = NULL | |
75 | excludes = NULL | |
76 | The namespace will get imported as the import_dest::LOCALNS | |
77 | namespace. | |
78 | ||
79 | C++ cannot express it, it would be something like: using localname | |
80 | = A::x; | |
81 | Fortran: use A, only localname => x | |
82 | import_src = "A" | |
83 | import_dest = local scope of the import statement even such as "" | |
84 | alias = "localname" | |
85 | declaration = "x" | |
86 | excludes = NULL | |
87 | The declaration will get imported as localname or | |
88 | `import_dest`localname. */ | |
89 | ||
90 | struct using_direct | |
91 | { | |
92 | const char *import_src; | |
93 | const char *import_dest; | |
94 | ||
95 | const char *alias; | |
96 | const char *declaration; | |
97 | ||
98 | struct using_direct *next; | |
99 | ||
100 | /* Used during import search to temporarily mark this node as | |
101 | searched. */ | |
102 | int searched; | |
103 | ||
104 | /* USING_DIRECT has variable allocation size according to the number of | |
105 | EXCLUDES entries, the last entry is NULL. */ | |
106 | const char *excludes[1]; | |
107 | }; | |
108 | ||
109 | extern void add_using_directive (struct using_direct **using_directives, | |
110 | const char *dest, | |
111 | const char *src, | |
112 | const char *alias, | |
113 | const char *declaration, | |
eb1e02fd | 114 | const std::vector<const char *> &excludes, |
22cee43f PMR |
115 | int copy_names, |
116 | struct obstack *obstack); | |
117 | ||
118 | #endif /* NAMESPACE_H */ |