summaryrefslogtreecommitdiff
path: root/odb/common.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-01-08 17:27:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-01-08 17:27:40 +0200
commit4fd6bca4e75870958ea61b94e0a1e60e78cd91bc (patch)
tree2119cae72f45e1ceff1982d8364b4b678ac4ee69 /odb/common.cxx
parent7cd11b5f604c7d786261568aa31cd2ae3638f61e (diff)
Add support for defining composite value type as class template instantiations
Diffstat (limited to 'odb/common.cxx')
-rw-r--r--odb/common.cxx55
1 files changed, 55 insertions, 0 deletions
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<class_instantiation*> (&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> ("tree-node"));
+
+ names* hint;
+ if (ci->count ("tree-hint"))
+ hint = ci->get<names*> ("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;
+}