blob: ff092f6835380c578e4f7bca257b3ff866347aa4 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/**
** \file type/named.cc
** \brief Implementation for type/named.hh.
*/
#include <type/named.hh>
#include <type/visitor.hh>
#include <vector>
namespace type
{
Named::Named(misc::symbol name)
: name_(name)
, type_(nullptr)
{}
Named::Named(misc::symbol name, const Type* type)
: name_(name)
, type_(type)
{}
// Inherited functions
void Named::accept(ConstVisitor& v) const
{
// FIXME DONE: Some code was deleted here.
v(*this);
}
void Named::accept(Visitor& v)
{
// FIXME DONE: Some code was deleted here.
v(*this);
}
bool Named::sound() const
{
// FIXME DONE: Some code was deleted here (Sound).
auto reference = dynamic_cast<const Named*>(type_);
std::vector<const Named*> previous;
while (reference != nullptr)
{
if (std::ranges::find(previous, reference) != previous.end())
{
return false;
}
previous.push_back(reference);
reference = dynamic_cast<const Named*>(reference->type_get());
}
return true;
}
bool Named::compatible_with(const Type& other) const
{
// FIXME DONE: Some code was deleted here (Special implementation of "compatible_with" for Named).
return type_->compatible_with(other);
}
} // namespace type
|