1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// file : odb/semantics/namespace.cxx
// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
// license : GNU GPL v3; see accompanying LICENSE file
#include <cutl/compiler/type-info.hxx>
#include <odb/semantics/namespace.hxx>
namespace semantics
{
namespace_::
namespace_ (path const& file, size_t line, size_t column, tree tn)
: node (file, line, column, tn), original_ (0)
{
}
namespace_::
namespace_ ()
: original_ (0)
{
}
names* namespace_::
lookup (string const& name,
type_id const& ti,
unsigned int flags,
bool* hidden) const
{
if (original_ != 0)
return original_->lookup (name, ti, flags, hidden);
// Being hidden in one namespace doesn't mean it is also hidden in
// the other. Normally that would be an ambiguous lookup, but we use
// relaxed rules.
//
bool h (false); // Indicates whether this namespace hides the name.
bool any_h (false); // Indicates whether any namespace hides the name.
names* r (scope::lookup (name, ti, flags | exclude_outer, &h));
any_h = any_h || h;
if (r != 0 && h && hidden != 0)
*hidden = true;
for (extensions_iterator i (extensions_begin ());
i != extensions_end ();
++i)
{
h = false;
names* er ((*i)->scope::lookup (name, ti, flags | exclude_outer, &h));
any_h = any_h || h;
if (er != 0)
{
if (r != 0)
{
// If both are namespaces, then the one is just an extension
// of the other.
//
if (!(r->named ().is_a<namespace_> () &&
er->named ().is_a<namespace_> ()))
throw ambiguous (*r, *er);
}
else
r = er;
if (h && hidden != 0)
*hidden = true;
}
}
if (r != 0)
return r;
if (any_h)
{
if (hidden != 0)
*hidden = true;
if ((flags & include_hidden) == 0)
return 0;
}
// Look in the outer scope unless requested not to or if this is
// the global scope.
//
if ((flags & exclude_outer) == 0 && !global_scope ())
return scope ().lookup (name, ti, flags, hidden);
return 0;
}
// type info
//
namespace
{
struct init
{
init ()
{
using compiler::type_info;
type_info ti (typeid (namespace_));
ti.add_base (typeid (scope));
insert (ti);
}
} init_;
}
}
|