diff options
| Commit | 72d9bbcc3154142af79fb686d9dc7e4d1fa1badb (patch) | |
|---|---|---|
| Author | 2018-11-29 09:13:12 +0200 | |
| Committer | 2018-11-29 09:13:12 +0200 | |
| Files | 3cea4377cba9370f3f2248557f82831d617d89d1 /spasm/src/string.hpp | |
| IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.tar IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.tar.gz IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.zip | ||
| Parent | cdfd42d72030a031e5c5d810fcd53441902b5cff (diff) | |
Feature/strings (#75)
* The assembler supports string opcode
* disabled the string test until implmented
* strings can be printed
1 files changed, 43 insertions, 0 deletions
| -rw-r--r-- | spasm/src/string.hpp | 43 |
diff --git a/spasm/src/string.hpp b/spasm/src/string.hpp new file mode 100644 index 0000000..8ffb214 --- /dev/null +++ b/spasm/src/string.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include <string> + +namespace SpasmImpl +{ +typedef std::string SPString; + +class SPStringValue +{ + public: + explicit SPStringValue(SPString s) : m_Value(std::move(s)) {} + + SPStringValue(const SPStringValue&) = delete; + SPStringValue(SPStringValue&&) = default; + SPStringValue& operator=(const SPStringValue&) = delete; + SPStringValue& operator=(SPStringValue&&) = default; + + const SPString& GetValue() const { return m_Value; } + + bool operator==(const SPStringValue& rhs) const + { + return m_Value == rhs.m_Value; + } + + bool operator==(const SPString& rhs) const { return m_Value == rhs; } + + private: + SPString m_Value; +}; +} // namespace SpasmImpl + +namespace std +{ +template <> +struct hash<SpasmImpl::SPStringValue> +{ + size_t operator()(const SpasmImpl::SPStringValue& v) const + { + return std::hash<SpasmImpl::SPString>{}(v.GetValue()); + } +}; +} // namespace std
\ No newline at end of file |
