Redesign HLSL scoped structures to a unique ID.
A unique ID gives a more flexible renaming scheme than our
current method of using nested scope identifiers. The reduced
complexity allows for fewer points of breakage and fixes an
outstanding bug with scoped structures (with added test).
BUG=angle:618
Change-Id: I6551248bb9fa2d185ab67248721f898dd50151f0
Reviewed-on: https://chromium-review.googlesource.com/202183
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index 5eb0434..aa5933d 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <algorithm>
-int TSymbolTableLevel::uniqueId = 0;
+int TSymbolTable::uniqueIdCounter = 0;
//
// Functions have buried pointers to delete.
@@ -38,6 +38,30 @@
delete (*it).second;
}
+bool TSymbolTableLevel::insert(const TString &name, TSymbol &symbol)
+{
+ symbol.setUniqueId(TSymbolTable::nextUniqueId());
+
+ // returning true means symbol was added to the table
+ tInsertResult result = level.insert(tLevelPair(name, &symbol));
+
+ return result.second;
+}
+
+bool TSymbolTableLevel::insert(TSymbol &symbol)
+{
+ return insert(symbol.getMangledName(), symbol);
+}
+
+TSymbol *TSymbolTableLevel::find(const TString &name) const
+{
+ tLevel::const_iterator it = level.find(name);
+ if (it == level.end())
+ return 0;
+ else
+ return (*it).second;
+}
+
//
// Change all function entries in the table with the non-mangled name
// to be related to the provided built-in operation. This is a low