summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/typable.hh
blob: 50c004e13fc961565574fa66d9a2c0c88058022d (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
/**
 ** \file ast/typable.hh
 ** \brief Declaration of ast::Typable.
 */

#pragma once

#include <ast/fwd.hh>
#include <type/fwd.hh>

namespace ast
{
  /** \class ast::Typable
   ** \brief Hold a type information.
   **
   ** A Typable node holds a type information (type::Type) about
   ** this node.  This can be:
   ** \li the type of the node itself, if it is a Exp or a Ty, or
   ** \li the type of of the declared object, in case of a Dec.
   */

  class Typable
  {
    // FIXME DONE: Some code was deleted here.

  public:
      // Only need for basic constructor and destructor here
      Typable();
      virtual ~Typable() = default;

      /* We prohibit copy and assignment as to avoid having
      ** multiple Typable referencing the same Type which could
      ** potentially mess up the TypeConstructor
      */
      Typable(const Typable&) = delete;
      Typable& operator=(const Typable&) = delete;

      // Basic getters/setters
      void type_set(const type::Type*);
      const type::Type* type_get() const;

      // Making sure we can visit thoses "nodes"
      virtual void accept(ConstVisitor& v) const = 0;
      virtual void accept(Visitor& v) = 0;
  
  private:
      const type::Type* type_;
  };
} // namespace ast
#include <ast/typable.hxx>