blob: ae5aa6c1fa5381d8939e10112ac9063dcf12ff90 [file] [log] [blame]
Václav Kubernát7edb5372019-12-13 12:40:49 +01001/*
2 * Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
5 *
6*/
7#include "ast_values.hpp"
8
9enum_::enum_() = default;
10
11enum_::enum_(const std::string& value)
12 : m_value(value)
13{
14}
15
16identityRef_::identityRef_() = default;
17
18identityRef_::identityRef_(const std::string& value)
19 : m_value(value)
20{
21}
22
23identityRef_::identityRef_(const std::string& module, const std::string& value)
24 : m_prefix(module_{module})
25 , m_value(value)
26{
27}
28
29binary_::binary_() = default;
30
31binary_::binary_(const std::string& value)
32 : m_value(value)
33{
34}
35
Václav Kubernátab612e92019-11-26 19:51:31 +010036bool module_::operator<(const module_& b) const
37{
38 return this->m_name < b.m_name;
39}
40
Václav Kubernát7edb5372019-12-13 12:40:49 +010041bool identityRef_::operator==(const identityRef_& b) const
42{
43 return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
44}
45
Václav Kubernátab612e92019-11-26 19:51:31 +010046bool identityRef_::operator<(const identityRef_& b) const
47{
48 return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
49}
50
Václav Kubernát7edb5372019-12-13 12:40:49 +010051bool binary_::operator==(const binary_& b) const
52{
53 return this->m_value == b.m_value;
54}
55
Václav Kubernátab612e92019-11-26 19:51:31 +010056bool binary_::operator<(const binary_& b) const
57{
58 return this->m_value < b.m_value;
59}
60
Václav Kubernát7edb5372019-12-13 12:40:49 +010061bool enum_::operator==(const enum_& b) const
62{
63 return this->m_value == b.m_value;
64}
65
Václav Kubernátab612e92019-11-26 19:51:31 +010066bool enum_::operator<(const enum_& b) const
67{
68 return this->m_value < b.m_value;
69}
70
Václav Kubernát144729d2020-01-08 15:20:35 +010071bool special_::operator==(const special_& b) const
72{
73 return this->m_value == b.m_value;
74}
75
Václav Kubernátab612e92019-11-26 19:51:31 +010076bool special_::operator<(const special_& b) const
77{
78 return this->m_value < b.m_value;
79}
80
Václav Kubernát144729d2020-01-08 15:20:35 +010081std::string specialValueToString(const special_& value)
82{
83 switch (value.m_value) {
84 case SpecialValue::Container:
85 return "(container)";
86 case SpecialValue::PresenceContainer:
87 return "(presence container)";
88 case SpecialValue::List:
89 return "(list)";
90 }
91
92 __builtin_unreachable();
93}