blob: 91cef2caff6185c3a6cb47eb4509fde96e701076 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|