diff options
Diffstat (limited to 'tiger-compiler/src/type/function.hh')
| -rw-r--r-- | tiger-compiler/src/type/function.hh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tiger-compiler/src/type/function.hh b/tiger-compiler/src/type/function.hh new file mode 100644 index 0000000..2accb82 --- /dev/null +++ b/tiger-compiler/src/type/function.hh @@ -0,0 +1,59 @@ +/** + ** \file type/function.hh + ** \brief The class Function. + */ +#pragma once + +#include <type/fwd.hh> +#include <type/record.hh> +#include <type/type.hh> + +namespace type +{ + /** \brief Function types. + ** + ** Encapsulate the signature of a function, i.e. the type structures + ** of both function's arguments and its result. */ + class Function : public Type + { + public: + /** \brief Construct a Function. + ** + ** \param formals type structures of formal arguments. + ** \param result type structure of what function returns. */ + Function(const Record* formals, const Type& result); + + /** \brief Destructor. + **/ + ~Function() 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 the type structures of the function's arguments. + const Record& formals_get() const; + /// Return the type structure of the function's result. + const Type& result_get() const; + /** \} */ + + // FIXME DONE: Some code was deleted here (Special implementation of "compatible_with" for Function). + bool compatible_with(const Type& other) const override; + + protected: + /// Formals' types. + const Record* formals_; + + /// Result's type. + const Type& result_; + }; + +} // namespace type + +#include <type/function.hxx> |
