diff options
| author | John Hodge <tpg@mutabah.net> | 2016-11-02 14:51:21 +0800 |
|---|---|---|
| committer | John Hodge <tpg@mutabah.net> | 2016-11-02 14:51:21 +0800 |
| commit | 52c363340a4f2ee589d2e6753f1c685ef7b907f5 (patch) | |
| tree | 758c04ec4aada28255cb5cd7865ad27025f29e7f /src/include | |
| parent | 563520207ad1a6c0deff41b881ac5d0168d3439e (diff) | |
| download | mrust-52c363340a4f2ee589d2e6753f1c685ef7b907f5.tar.gz | |
All - Hack in start of macro hygine - requires rework so is disabled
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ident.hpp | 78 | ||||
| -rw-r--r-- | src/include/rc_string.hpp | 1 |
2 files changed, 79 insertions, 0 deletions
diff --git a/src/include/ident.hpp b/src/include/ident.hpp new file mode 100644 index 00000000..d5ce2e77 --- /dev/null +++ b/src/include/ident.hpp @@ -0,0 +1,78 @@ +/* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * include/ident.hpp + * - Identifiers with hygine + */ +#pragma once +#include <vector> +#include <string> + +struct Ident +{ + struct Hygine + { + unsigned int file_num; + ::std::vector<unsigned int> indexes; + + Hygine(unsigned int file, ::std::vector<unsigned int> indexes): + file_num(file), + indexes(::std::move(indexes)) + {} + + Hygine(Hygine&& x) = default; + Hygine(const Hygine& x) = default; + Hygine& operator=(Hygine&& x) = default; + Hygine& operator=(const Hygine& x) = default; + + // Returns true if an ident with hygine `souce` can see an ident with this hygine + bool is_visible(const Hygine& source) const; + bool operator==(const Hygine& x) const { return file_num == x.file_num && indexes == x.indexes; } + bool operator!=(const Hygine& x) const { return file_num != x.file_num || indexes != x.indexes; } + + friend ::std::ostream& operator<<(::std::ostream& os, const Hygine& v); + }; + + Hygine hygine; + ::std::string name; + + Ident(const char* name): + hygine(~0u, {}), + name(name) + { } + Ident(::std::string name): + hygine(~0u, {}), + name(::std::move(name)) + { } + Ident(Hygine hygine, ::std::string name): + hygine(::std::move(hygine)), name(::std::move(name)) + { } + + Ident(Ident&& x) = default; + Ident(const Ident& x) = default; + Ident& operator=(Ident&& x) = default; + Ident& operator=(const Ident& x) = default; + + ::std::string into_string() { + return ::std::move(name); + } + + bool operator==(const char* s) const { + return this->name == s; + } + + bool operator==(const Ident& x) const { + if( this->name != x.name ) + return false; + //if( this->hygine.indexes != x.hygine.indexes ) + // return false; + return true; + } + bool operator!=(const Ident& x) const { + return !(*this == x); + } + bool operator<(const Ident& x) const; + + friend ::std::ostream& operator<<(::std::ostream& os, const Ident& x); +}; diff --git a/src/include/rc_string.hpp b/src/include/rc_string.hpp index 4649b36e..630f8e89 100644 --- a/src/include/rc_string.hpp +++ b/src/include/rc_string.hpp @@ -75,6 +75,7 @@ public: return ""; } } + bool operator==(const RcString& s) const { return *this == s.c_str(); } bool operator==(const char* s) const; friend ::std::ostream& operator<<(::std::ostream& os, const RcString& x) { return os << x.c_str(); |
