summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/typable.hh
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/src/ast/typable.hh')
-rw-r--r--tiger-compiler/src/ast/typable.hh50
1 files changed, 50 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/typable.hh b/tiger-compiler/src/ast/typable.hh
new file mode 100644
index 0000000..50c004e
--- /dev/null
+++ b/tiger-compiler/src/ast/typable.hh
@@ -0,0 +1,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>