LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
class.hh
Go to the documentation of this file.
1 
5 #ifndef TYPE_CLASS_HH
6 # define TYPE_CLASS_HH
7 
8 # include <list>
9 
10 # include <misc/symbol.hh>
11 # include <type/attribute.hh>
12 # include <type/method.hh>
13 # include <type/type.hh>
14 
15 namespace type
16 {
20  class Class : public Type
21  {
24  public:
28  Class(const Class* super = nullptr);
33  public:
35  const Type* attr_type(const misc::symbol& key) const;
37  const Method* meth_type(const misc::symbol& key) const;
42  public:
44  typedef std::list<Attribute> attrs_type;
46  typedef std::list<const Method*> meths_type;
47 
49  const attrs_type& attrs_get() const;
51  const meths_type& meths_get() const;
52 
57  const Attribute* attr_find(const misc::symbol& key) const;
62  const Attribute* owned_attr_find(const misc::symbol& key) const;
63 
68  const Method* owned_meth_find(const misc::symbol& key) const;
69 
71  void attr_add(const Attribute& attr);
73  void attr_add(const ast::VarDec* def);
74 
76  void meth_add(const Method* method);
79 
80  bool has_data() const;
81 
84  public:
86  unsigned id_get() const;
87 
89  const Class* super_get() const;
91  void super_set(const Class* type);
92 
94  const std::list<const Class*>& subclasses_get() const;
95 
100  void subclass_add(const Class* subclass) const;
101 
106  void subclasses_clear() const;
111  public:
114  bool sound() const;
117  // FIXME: Some code was deleted here (Inherited virtual methods).
118 
119  public:
121  static const Class& object_instance();
122 
123  private:
125  static unsigned fresh_id();
126 
128  unsigned id_;
130  const Class* super_;
132  mutable std::list<const Class*> subclasses_;
137  };
138 
139 
140 } // namespace type
141 
142 # include <type/class.hxx>
143 
144 #endif // !TYPE_CLASS_HH