From 2b02d443ab344bc02dfc2891fb1a57c6520c393f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 19 Aug 2010 17:05:24 +0200 Subject: Use type names as specified in the header that we compile --- odb/semantics/elements.cxx | 64 +++++++++++++++++++++++++++++++++++++++++-- odb/semantics/elements.hxx | 28 +++++++++++++++++++ odb/semantics/fundamental.cxx | 9 ++++++ odb/semantics/fundamental.hxx | 3 ++ 4 files changed, 102 insertions(+), 2 deletions(-) (limited to 'odb/semantics') diff --git a/odb/semantics/elements.cxx b/odb/semantics/elements.cxx index 29b1f8e..a25df86 100644 --- a/odb/semantics/elements.cxx +++ b/odb/semantics/elements.cxx @@ -21,13 +21,73 @@ namespace semantics // nameable // + bool nameable:: + fq_anonymous () const + { + // Nameable is fq-anonymous if all the paths to the global scope + // have at least one anonymous link. + // + if (anonymous ()) + return true; + + if (named ().global_scope ()) + return false; + + if (defined_ != 0 && !defined_->scope ().fq_anonymous ()) + return false; + + for (names_list::const_iterator i (named_.begin ()), e (named_.end ()); + i != e; ++i) + { + if (!(*i)->scope ().fq_anonymous ()) + return false; + } + + return true; + } + + bool nameable:: + fq_anonymous (names* hint) const + { + if (hint == 0 && defined_ == 0) + return true; + + names& n (hint ? *hint : *defined_); + + if (n.global_scope ()) + return false; + + return n.scope ().fq_anonymous (); + } + string nameable:: fq_name () const { if (named ().global_scope ()) return ""; - else - return scope ().fq_name () + "::" + name (); + + if (defined_ != 0 && !defined_->scope ().fq_anonymous ()) + return defined_->scope ().fq_name () + "::" + name (); + + for (names_list::const_iterator i (named_.begin ()), e (named_.end ()); + i != e; ++i) + { + if (!(*i)->scope ().fq_anonymous ()) + return (*i)->scope ().fq_name () + "::" + name (); + } + + return ""; + } + + string nameable:: + fq_name (names* hint) const + { + names& n (hint ? *hint : *defined_); + + if (n.global_scope ()) + return ""; + + return n.scope ().fq_name () + "::" + n.name (); } // scope diff --git a/odb/semantics/elements.hxx b/odb/semantics/elements.hxx index 8d9a379..03925f5 100644 --- a/odb/semantics/elements.hxx +++ b/odb/semantics/elements.hxx @@ -276,6 +276,14 @@ namespace semantics return defined_ == 0 && named_.empty (); } + bool + fq_anonymous () const; + + // If hint it 0, use the defines edge. + // + bool + fq_anonymous (names* hint) const; + string name () const { @@ -285,6 +293,11 @@ namespace semantics virtual string fq_name () const; + // If hint it 0, use the defines edge. + // + virtual string + fq_name (names* hint) const; + scope_type& scope () const { @@ -494,7 +507,21 @@ namespace semantics } public: + void + hint (names& hint) + { + hint_ = &hint; + } + + names* + hint () const + { + return hint_; + } + + public: belongs () + : hint_ (0) { } @@ -513,6 +540,7 @@ namespace semantics private: type_type* type_; instance_type* instance_; + names* hint_; }; // diff --git a/odb/semantics/fundamental.cxx b/odb/semantics/fundamental.cxx index 7da222d..76efbe4 100644 --- a/odb/semantics/fundamental.cxx +++ b/odb/semantics/fundamental.cxx @@ -14,6 +14,15 @@ namespace semantics return name (); } + string fund_type:: + fq_name (names* hint) const + { + if (hint == 0) + return name (); + + return type::fq_name (hint); + } + // type info // namespace diff --git a/odb/semantics/fundamental.hxx b/odb/semantics/fundamental.hxx index cd68688..991bc54 100644 --- a/odb/semantics/fundamental.hxx +++ b/odb/semantics/fundamental.hxx @@ -19,6 +19,9 @@ namespace semantics virtual string fq_name () const; + virtual string + fq_name (names*) const; + protected: fund_type (tree tn) : type (tn) {} -- cgit v1.1