Add special type for representing special values
Before this, pseudo-values like lists and containers were represented by
a string leaf value. Now, I can tell these values apart. This can be
helpful for filtering (for example, when printing the values). It will
also be used for implementing key value completion.
Change-Id: I48f6fa2facaf3e8e52aa3b3b4d92130e63acdb6f
diff --git a/src/ast_values.cpp b/src/ast_values.cpp
index b8ca68d..8d9c40c 100644
--- a/src/ast_values.cpp
+++ b/src/ast_values.cpp
@@ -48,3 +48,21 @@
return this->m_value == b.m_value;
}
+bool special_::operator==(const special_& b) const
+{
+ return this->m_value == b.m_value;
+}
+
+std::string specialValueToString(const special_& value)
+{
+ switch (value.m_value) {
+ case SpecialValue::Container:
+ return "(container)";
+ case SpecialValue::PresenceContainer:
+ return "(presence container)";
+ case SpecialValue::List:
+ return "(list)";
+ }
+
+ __builtin_unreachable();
+}