From 4fd6bca4e75870958ea61b94e0a1e60e78cd91bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 8 Jan 2012 17:27:40 +0200 Subject: Add support for defining composite value type as class template instantiations --- odb/common.cxx | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'odb/common.cxx') diff --git a/odb/common.cxx b/odb/common.cxx index 322a915..379c769 100644 --- a/odb/common.cxx +++ b/odb/common.cxx @@ -442,3 +442,58 @@ traverse (semantics::data_member& m) oc_.member_path_.pop_back (); } + +// +// typedefs +// + +void typedefs:: +traverse (semantics::typedefs& t) +{ + if (check (t)) + traversal::typedefs::traverse (t); +} + +bool typedefs:: +check (semantics::typedefs& t) +{ + // This typedef must be for a class template instantiation. + // + using semantics::class_instantiation; + class_instantiation* ci (dynamic_cast (&t.type ())); + + if (ci == 0) + return false; + + // It must be a composite value. + // + if (!composite (*ci)) + return false; + + // This typedef name should be the one that was used in the pragma. + // + using semantics::names; + tree type (ci->get ("tree-node")); + + names* hint; + if (ci->count ("tree-hint")) + hint = ci->get ("tree-hint"); + else + { + hint = unit.find_hint (type); + ci->set ("tree-hint", hint); // Cache it. + } + + if (hint != &t) + return false; + + // And the pragma may have to be in the file we are compiling. + // + if (!included_) + { + if (class_file (*ci) != unit.file ()) + return false; + } + + return true; +} -- cgit v1.1