summaryrefslogtreecommitdiff
path: root/src/ident.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-11-02 14:51:21 +0800
committerJohn Hodge <tpg@mutabah.net>2016-11-02 14:51:21 +0800
commit52c363340a4f2ee589d2e6753f1c685ef7b907f5 (patch)
tree758c04ec4aada28255cb5cd7865ad27025f29e7f /src/ident.cpp
parent563520207ad1a6c0deff41b881ac5d0168d3439e (diff)
downloadmrust-52c363340a4f2ee589d2e6753f1c685ef7b907f5.tar.gz
All - Hack in start of macro hygine - requires rework so is disabled
Diffstat (limited to 'src/ident.cpp')
-rw-r--r--src/ident.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/ident.cpp b/src/ident.cpp
new file mode 100644
index 00000000..5d0fe00c
--- /dev/null
+++ b/src/ident.cpp
@@ -0,0 +1,60 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * include/ident.cpp
+ * - Identifiers with hygine
+ */
+#include <iostream>
+#include <ident.hpp>
+#include <debug.hpp>
+#include <common.hpp> // vector print
+
+bool Ident::Hygine::is_visible(const Hygine& src) const
+{
+ // HACK: Disable hygine for now
+ return true;
+
+ DEBUG("*this = " << *this << ", src=" << src);
+ if( this->file_num != src.file_num ) {
+ DEBUG("- Different file");
+ return false;
+ }
+
+ // `this` is the item, `src` is the ident used to access it
+
+ // If this is from a deeper point than the source, it won't work.
+ if( this->indexes.size() > src.indexes.size() ) {
+ DEBUG("- Not subset: len");
+ return false;
+ }
+
+ // If this hygine list (barring the last) is a subset of the source
+ for(unsigned int i = 0; i < this->indexes.size()-1 - 1; i ++)
+ {
+ if( this->indexes[i] != src.indexes[i] ) {
+ DEBUG("- Not subset: " << i);
+ return false;
+ }
+ }
+
+ unsigned int end = this->indexes.size()-1-1;
+ // Allow match if this ident is from before the addressing ident
+ if( this->indexes[end] < src.indexes[end] ) {
+ return true;
+ }
+
+ DEBUG("- Not before");
+ return false;
+}
+
+::std::ostream& operator<<(::std::ostream& os, const Ident& x) {
+ os << x.name;
+ return os;
+}
+
+::std::ostream& operator<<(::std::ostream& os, const Ident::Hygine& x) {
+ os << "{" << x.file_num << ": [" << x.indexes << "]}";
+ return os;
+}
+