diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-31 10:03:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-31 10:03:45 +0200 |
commit | c0957cfe1c73ecb6c96314e45e7d29b4199b20d6 (patch) | |
tree | 96a747f7196baa335cf83ff160527bb8333ca9e3 /odb/semantics/namespace.cxx | |
parent | ed52acc5e65dd9ea2fb2d9c851c2faa61d5cb2d9 (diff) |
Add support for virtual data members
New test: common/virtual.
Diffstat (limited to 'odb/semantics/namespace.cxx')
-rw-r--r-- | odb/semantics/namespace.cxx | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/odb/semantics/namespace.cxx b/odb/semantics/namespace.cxx index 9906219..257385e 100644 --- a/odb/semantics/namespace.cxx +++ b/odb/semantics/namespace.cxx @@ -19,6 +19,76 @@ namespace semantics { } + 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 |