From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/type/method.cc | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tiger-compiler/src/type/method.cc (limited to 'tiger-compiler/src/type/method.cc') diff --git a/tiger-compiler/src/type/method.cc b/tiger-compiler/src/type/method.cc new file mode 100644 index 0000000..5726948 --- /dev/null +++ b/tiger-compiler/src/type/method.cc @@ -0,0 +1,48 @@ +/** + ** \file type/method.cc + ** \brief Implementation for type/method.hh. + */ + +#include + +#include +#include + +namespace type +{ + Method::Method(misc::symbol name, + const Class* owner, + const Record* formals, + const Type& result, + ast::MethodDec* def) + : Function(formals, result) + , name_(name) + , owner_(owner) + , def_(def) + {} + + Method::Method(misc::symbol name, + const Record* formals, + const Type& result, + ast::MethodDec* def) + : Function(formals, result) + , name_(name) + , owner_(nullptr) + , def_(def) + {} + + void Method::accept(ConstVisitor& v) const { v(*this); } + + void Method::accept(Visitor& v) { v(*this); } + + // FIXME DONE: Some code was deleted here. + bool Method::compatible_with(const Type& other) const + { + const auto other_method = dynamic_cast(&other); + + return other_method != nullptr \ + && other_method->formals_get().compatible_with(other) \ + && other_method->result_get().compatible_with(other); + } + +} // namespace type -- cgit v1.2.3