diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/type/method.cc | |
Diffstat (limited to 'tiger-compiler/src/type/method.cc')
| -rw-r--r-- | tiger-compiler/src/type/method.cc | 48 |
1 files changed, 48 insertions, 0 deletions
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 <iostream> + +#include <type/method.hh> +#include <type/visitor.hh> + +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<const Method*>(&other); + + return other_method != nullptr \ + && other_method->formals_get().compatible_with(other) \ + && other_method->result_get().compatible_with(other); + } + +} // namespace type |
