Add translations for various sub-directories
[binutils-gdb.git] / gdb / namespace.h
blobca949aa614f4416f67d374662f6265d951bdbc21
1 /* Code dealing with "using" directives for GDB.
2 Copyright (C) 2003-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
19 #ifndef GDB_NAMESPACE_H
20 #define GDB_NAMESPACE_H
22 #include "gdbsupport/gdb_obstack.h"
24 /* This struct is designed to store data from using directives. It
25 says that names from namespace IMPORT_SRC should be visible within
26 namespace IMPORT_DEST. These form a linked list; NEXT is the next
27 element of the list. If the imported namespace or declaration has
28 been aliased within the IMPORT_DEST namespace, ALIAS is set to a
29 string representing the alias. Otherwise, ALIAS is NULL.
30 DECLARATION is the name of the imported declaration, if this import
31 statement represents one. Otherwise DECLARATION is NULL and this
32 import statement represents a namespace. DECL_LINE is the line
33 where the using directive is written in the source code.
35 C++: using namespace A;
36 Fortran: use A
37 import_src = "A"
38 import_dest = local scope of the import statement even such as ""
39 alias = NULL
40 declaration = NULL
41 excludes = NULL
43 C++: using A::x;
44 Fortran: use A, only: x
45 import_src = "A"
46 import_dest = local scope of the import statement even such as ""
47 alias = NULL
48 declaration = "x"
49 excludes = NULL
50 The declaration will get imported as import_dest::x.
52 C++ has no way to import all names except those listed ones.
53 Fortran: use A, localname => x
54 import_src = "A"
55 import_dest = local scope of the import statement even such as ""
56 alias = "localname"
57 declaration = "x"
58 excludes = NULL
60 import_src = "A"
61 import_dest = local scope of the import statement even such as ""
62 alias = NULL
63 declaration = NULL
64 excludes = ["x"]
65 All the entries of A get imported except of "x". "x" gets imported as
66 "localname". "x" is not defined as a local name by this statement.
68 C++: namespace LOCALNS = A;
69 Fortran has no way to address non-local namespace/module.
70 import_src = "A"
71 import_dest = local scope of the import statement even such as ""
72 alias = "LOCALNS"
73 declaration = NULL
74 excludes = NULL
75 The namespace will get imported as the import_dest::LOCALNS
76 namespace.
78 C++ cannot express it, it would be something like: using localname
79 = A::x;
80 Fortran: use A, only localname => x
81 import_src = "A"
82 import_dest = local scope of the import statement even such as ""
83 alias = "localname"
84 declaration = "x"
85 excludes = NULL
86 The declaration will get imported as localname or
87 `import_dest`localname. */
89 struct using_direct
91 const char *import_src;
92 const char *import_dest;
94 const char *alias;
95 const char *declaration;
97 struct using_direct *next;
99 /* The line where the using directive was declared on the source file.
100 This is used to check if the using directive is already active at the
101 point where the inferior is stopped. */
102 unsigned int decl_line;
104 /* Used during import search to temporarily mark this node as
105 searched. */
106 int searched;
108 /* USING_DIRECT has variable allocation size according to the number of
109 EXCLUDES entries, the last entry is NULL. */
110 const char *excludes[1];
112 /* Returns true if the using_directive USING_DIR is valid in CURR_LINE.
113 Because current GCC (at least version 12.2) sets the decl_line as
114 the last line in the current block, we need to take this into
115 consideration when checking the validity, by comparing it to
116 BOUNDARY, the last line of the current block. */
117 bool valid_line (unsigned int boundary) const;
120 extern void add_using_directive (struct using_direct **using_directives,
121 const char *dest,
122 const char *src,
123 const char *alias,
124 const char *declaration,
125 const std::vector<const char *> &excludes,
126 const unsigned int decl_line,
127 struct obstack *obstack);
129 #endif /* GDB_NAMESPACE_H */