summaryrefslogtreecommitdiff
path: root/odb/semantics/class.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-23 12:34:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-23 12:34:58 +0200
commit64ff415ed33a733f9a297b1526403bfb8f391c63 (patch)
treed0f02c10e2bc9c068538719186f0683e7743e314 /odb/semantics/class.hxx
parent4867605e59aa35e588f6f812c42ea95dffc0bbb3 (diff)
Semantic graph and parsing code
Currently covers/handles namespace, class definitions (including bases and data members), and typedefs in namespace-scopes.
Diffstat (limited to 'odb/semantics/class.hxx')
-rw-r--r--odb/semantics/class.hxx135
1 files changed, 135 insertions, 0 deletions
diff --git a/odb/semantics/class.hxx b/odb/semantics/class.hxx
new file mode 100644
index 0000000..d4a0900
--- /dev/null
+++ b/odb/semantics/class.hxx
@@ -0,0 +1,135 @@
+// file : odb/semantics/class.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_SEMANTICS_CLASS_HXX
+#define ODB_SEMANTICS_CLASS_HXX
+
+#include <vector>
+#include <semantics/elements.hxx>
+
+namespace semantics
+{
+ class class_;
+
+ //
+ //
+ class data_member: public nameable, public instance
+ {
+ public:
+ data_member (path const& file, size_t line, size_t column)
+ : node (file, line, column)
+ {
+ }
+ };
+
+ //
+ //
+ class inherits: public edge
+ {
+ public:
+ typedef semantics::access access_type;
+
+ class_&
+ base () const
+ {
+ return *base_;
+ }
+
+ class_&
+ derived () const
+ {
+ return *derived_;
+ }
+
+ bool
+ virtual_ () const
+ {
+ return virt_;
+ }
+
+ access_type
+ access () const
+ {
+ return access_;
+ }
+
+ public:
+ inherits (access_type access, bool virt)
+ : virt_ (virt), access_ (access)
+ {
+ }
+
+ void
+ set_left_node (class_& n)
+ {
+ derived_ = &n;
+ }
+
+ void
+ set_right_node (class_& n)
+ {
+ base_ = &n;
+ }
+
+ protected:
+ bool virt_;
+ access_type access_;
+
+ class_* base_;
+ class_* derived_;
+ };
+
+ //
+ //
+ class class_: public type, public scope
+ {
+ private:
+ typedef std::vector<inherits*> inherits_list;
+
+ public:
+ typedef inherits_list::const_iterator inherits_iterator;
+
+ inherits_iterator
+ inherits_begin () const
+ {
+ return inherits_.begin ();
+ }
+
+ inherits_iterator
+ inherits_end () const
+ {
+ return inherits_.end ();
+ }
+
+ public:
+ class_ (path const& file, size_t line, size_t column)
+ : node (file, line, column)
+ {
+ }
+
+ void
+ add_edge_left (inherits& e)
+ {
+ inherits_.push_back (&e);
+ }
+
+ void
+ add_edge_right (inherits&)
+ {
+ }
+
+ using scope::add_edge_left;
+ using scope::add_edge_right;
+
+ // Resolve conflict between scope::scope and nameable::scope.
+ //
+ using nameable::scope;
+
+ private:
+ inherits_list inherits_;
+ };
+}
+
+#endif // ODB_SEMANTICS_CLASS_HXX