summaryrefslogtreecommitdiff
path: root/cli/semantics
diff options
context:
space:
mode:
Diffstat (limited to 'cli/semantics')
-rw-r--r--cli/semantics/class.cxx18
-rw-r--r--cli/semantics/class.hxx86
-rw-r--r--cli/semantics/elements.cxx13
-rw-r--r--cli/semantics/elements.hxx9
4 files changed, 122 insertions, 4 deletions
diff --git a/cli/semantics/class.cxx b/cli/semantics/class.cxx
index 1af31dc..9a6fc85 100644
--- a/cli/semantics/class.cxx
+++ b/cli/semantics/class.cxx
@@ -19,9 +19,21 @@ namespace semantics
{
using compiler::type_info;
- type_info ti (typeid (class_));
- ti.add_base (typeid (scope));
- insert (ti);
+ // inherits
+ //
+ {
+ type_info ti (typeid (inherits));
+ ti.add_base (typeid (edge));
+ insert (ti);
+ }
+
+ // class_
+ //
+ {
+ type_info ti (typeid (class_));
+ ti.add_base (typeid (scope));
+ insert (ti);
+ }
}
} init_;
}
diff --git a/cli/semantics/class.hxx b/cli/semantics/class.hxx
index be0b9f9..f5f12c8 100644
--- a/cli/semantics/class.hxx
+++ b/cli/semantics/class.hxx
@@ -6,17 +6,101 @@
#ifndef CLI_SEMANTICS_CLASS_HXX
#define CLI_SEMANTICS_CLASS_HXX
+#include <vector>
+
#include <semantics/elements.hxx>
namespace semantics
{
+ class class_;
+
+ class inherits: public edge
+ {
+ public:
+ class_&
+ base () const
+ {
+ return *base_;
+ }
+
+ class_&
+ derived () const
+ {
+ return *derived_;
+ }
+
+ public:
+ void
+ set_left_node (class_& n)
+ {
+ derived_ = &n;
+ }
+
+ void
+ set_right_node (class_& n)
+ {
+ base_ = &n;
+ }
+
+ protected:
+ class_* base_;
+ class_* derived_;
+ };
+
class class_: public scope
{
+ private:
+ typedef std::vector<inherits*> inherits_list;
+
+ public:
+ bool
+ abstract () const
+ {
+ return abstract_;
+ }
+
+ void
+ abstract (bool a)
+ {
+ abstract_ = a;
+ }
+
+ public:
+ typedef pointer_iterator<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)
+ : node (file, line, column), abstract_ (false)
+ {
+ }
+
+ 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;
+
+ private:
+ bool abstract_;
+ inherits_list inherits_;
};
}
diff --git a/cli/semantics/elements.cxx b/cli/semantics/elements.cxx
index 04d6e03..3e87248 100644
--- a/cli/semantics/elements.cxx
+++ b/cli/semantics/elements.cxx
@@ -9,6 +9,19 @@
namespace semantics
{
+ // nameable
+ //
+ string nameable::
+ fq_name () const
+ {
+ string const& n (name ());
+
+ if (n.empty ())
+ return n;
+ else
+ return scope ().fq_name () + "::" + n;
+ }
+
// scope
//
diff --git a/cli/semantics/elements.hxx b/cli/semantics/elements.hxx
index 6dd6f78..e650f37 100644
--- a/cli/semantics/elements.hxx
+++ b/cli/semantics/elements.hxx
@@ -254,12 +254,21 @@ namespace semantics
return named_->name ();
}
+ string
+ fq_name () const;
+
scope_type&
scope ()
{
return named_->scope ();
}
+ scope_type const&
+ scope () const
+ {
+ return named_->scope ();
+ }
+
names&
named ()
{