LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
class.hxx
Go to the documentation of this file.
1 
5 #ifndef TYPE_CLASS_HXX
6 # define TYPE_CLASS_HXX
7 
8 # include <iostream>
9 # include <misc/algorithm.hh>
10 # include <type/class.hh>
11 
12 namespace type
13 {
14  inline const Class::attrs_type&
16  {
17  return attrs_;
18  }
19 
20  inline const Attribute*
21  Class::attr_find(const misc::symbol& key) const
22  {
23  for (const Class* cur = this; cur; cur = cur->super_get())
24  {
25  const Attribute* attr = cur->owned_attr_find(key);
26  if (attr)
27  return attr;
28  }
29  return nullptr;
30  }
31 
32  inline const Attribute*
34  {
35  for (const Attribute& at : attrs_get())
36  if (at.name_get() == key)
37  return &at;
38  return nullptr;
39  }
40 
41  inline const Method*
43  {
44  for (const Method* m : meths_get())
45  if (m->name_get() == key)
46  return m;
47  return nullptr;
48  }
49 
50  inline void
52  {
53  attrs_.push_back(attr);
54  }
55 
56  inline void
58  {
59  attrs_.emplace_back(def);
60  }
61 
62  inline const Class::meths_type&
64  {
65  return meths_;
66  }
67 
68  inline void
69  Class::meth_add(const Method* meth)
70  {
71  meths_.push_back(meth);
72  }
73 
74  inline bool
76  {
77  return !attrs_.empty();
78  }
79 
80  inline unsigned
81  Class::id_get() const
82  {
83  return id_;
84  }
85 
86  inline const Class*
88  {
89  return super_;
90  }
91 
92  inline void
93  Class::super_set(const Class* super)
94  {
95  super_ = super;
96 
97  }
98 
99  inline
100  const std::list<const Class*>&
102  {
103  return subclasses_;
104  }
105 
106  inline void
107  Class::subclass_add(const Class* subclass) const
108  {
109  subclasses_.push_back(subclass);
110  }
111 
112  inline void
114  {
115  subclasses_.clear();
116  }
117 
118 } // namespace type
119 
120 #endif // !TYPE_CLASS_HXX