summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/function-dec.hh
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/src/ast/function-dec.hh')
-rw-r--r--tiger-compiler/src/ast/function-dec.hh72
1 files changed, 72 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/function-dec.hh b/tiger-compiler/src/ast/function-dec.hh
new file mode 100644
index 0000000..0a94e95
--- /dev/null
+++ b/tiger-compiler/src/ast/function-dec.hh
@@ -0,0 +1,72 @@
+/**
+ ** \file ast/function-dec.hh
+ ** \brief Declaration of ast::FunctionDec.
+ */
+
+#pragma once
+
+#include <ast/chunk.hh>
+#include <ast/dec.hh>
+#include <ast/exp.hh>
+#include <ast/name-ty.hh>
+#include <ast/type-constructor.hh>
+#include <ast/var-dec.hh>
+
+namespace ast
+{
+ /// FunctionDec.
+ class FunctionDec
+ : public Dec
+ , public TypeConstructor
+ {
+ public:
+ /** \name Ctor & dtor.
+ ** \{ */
+ /// Construct a FunctionDec node.
+ FunctionDec(const Location& location,
+ misc::symbol name,
+ VarChunk* formals,
+ NameTy* result,
+ Exp* body);
+ FunctionDec(const FunctionDec&) = delete;
+ FunctionDec& operator=(const FunctionDec&) = delete;
+ /// Destroy a FunctionDec node.
+ ~FunctionDec() override;
+ /** \} */
+
+ /// \name Visitors entry point.
+ /// \{ */
+ /// Accept a const visitor \a v.
+ void accept(ConstVisitor& v) const override;
+ /// Accept a non-const visitor \a v.
+ void accept(Visitor& v) override;
+ /// \}
+
+ /** \name Accessors.
+ ** \{ */
+ /// Return formal arguments.
+ const VarChunk& formals_get() const;
+ /// Return formal arguments.
+ VarChunk& formals_get();
+ /// Return result type.
+ const NameTy* result_get() const;
+ /// Return result type.
+ NameTy* result_get();
+ /// Return instructions.
+ const Exp* body_get() const;
+ /// Return instructions.
+ Exp* body_get();
+ /// Set instructions.
+ void body_set(Exp*);
+ /** \} */
+
+ protected:
+ /// Formal arguments.
+ VarChunk* formals_;
+ /// Result type.
+ NameTy* result_;
+ /// Instructions.
+ Exp* body_;
+ };
+} // namespace ast
+#include <ast/function-dec.hxx>