Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 9 | enum_::enum_() = default; |
| 10 | |
| 11 | enum_::enum_(const std::string& value) |
| 12 | : m_value(value) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | identityRef_::identityRef_() = default; |
| 17 | |
| 18 | identityRef_::identityRef_(const std::string& value) |
| 19 | : m_value(value) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | identityRef_::identityRef_(const std::string& module, const std::string& value) |
| 24 | : m_prefix(module_{module}) |
| 25 | , m_value(value) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | binary_::binary_() = default; |
| 30 | |
| 31 | binary_::binary_(const std::string& value) |
| 32 | : m_value(value) |
| 33 | { |
| 34 | } |
| 35 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 36 | bool module_::operator<(const module_& b) const |
| 37 | { |
| 38 | return this->m_name < b.m_name; |
| 39 | } |
| 40 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 41 | bool 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át | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 46 | bool 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át | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 51 | bool binary_::operator==(const binary_& b) const |
| 52 | { |
| 53 | return this->m_value == b.m_value; |
| 54 | } |
| 55 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 56 | bool binary_::operator<(const binary_& b) const |
| 57 | { |
| 58 | return this->m_value < b.m_value; |
| 59 | } |
| 60 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 61 | bool enum_::operator==(const enum_& b) const |
| 62 | { |
| 63 | return this->m_value == b.m_value; |
| 64 | } |
| 65 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 66 | bool enum_::operator<(const enum_& b) const |
| 67 | { |
| 68 | return this->m_value < b.m_value; |
| 69 | } |
| 70 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 71 | bool special_::operator==(const special_& b) const |
| 72 | { |
| 73 | return this->m_value == b.m_value; |
| 74 | } |
| 75 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 76 | bool special_::operator<(const special_& b) const |
| 77 | { |
| 78 | return this->m_value < b.m_value; |
| 79 | } |
| 80 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 81 | std::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 | } |