summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/type/function.cc
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/type/function.cc
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/type/function.cc')
-rw-r--r--tiger-compiler/src/type/function.cc38
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