summaryrefslogtreecommitdiff
path: root/cli/semantics/class.hxx
blob: ca7de8c18c9ee81ba48c436ca29dbbcb71223471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// file      : cli/semantics/class.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// license   : MIT; see accompanying LICENSE file

#ifndef CLI_SEMANTICS_CLASS_HXX
#define CLI_SEMANTICS_CLASS_HXX

#include <vector>

#include <cli/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), 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_;
  };
}

#endif // CLI_SEMANTICS_CLASS_HXX