diff options
Diffstat (limited to 'tiger-compiler/src/type/function.cc')
| -rw-r--r-- | tiger-compiler/src/type/function.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tiger-compiler/src/type/function.cc b/tiger-compiler/src/type/function.cc new file mode 100644 index 0000000..91cef2c --- /dev/null +++ b/tiger-compiler/src/type/function.cc @@ -0,0 +1,38 @@ +/** + ** \file type/function.cc + ** \brief Implementation for type/function.hh. + */ + +#include <ostream> +#include <ranges> + +#include <type/function.hh> +#include <type/visitor.hh> + +namespace type +{ + Function::Function(const Record* formals, const Type& result) + : result_(result) + { + precondition(formals); + + formals_ = formals; + } + + Function::~Function() { delete formals_; } + + void Function::accept(ConstVisitor& v) const { v(*this); } + + void Function::accept(Visitor& v) { v(*this); } + + // FIXME DONE: Some code was deleted here. + bool Function::compatible_with(const Type& other) const + { + const auto other_function = dynamic_cast<const Function*>(&other); + + return other_function != nullptr \ + && other_function->formals_get().compatible_with(this->formals_get()) \ + && other_function->result_get().compatible_with(this->result_get()); + } + +} // namespace type |
