Implement user-defined name hashing.

ANGLEBUG=315
Review URL: https://codereview.appspot.com/6818109

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1469 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/VariableInfo.cpp b/src/compiler/VariableInfo.cpp
index 3ff2836..eb6bea9 100644
--- a/src/compiler/VariableInfo.cpp
+++ b/src/compiler/VariableInfo.cpp
@@ -77,23 +77,25 @@
 static void getUserDefinedVariableInfo(const TType& type,
                                        const TString& name,
                                        const TString& mappedName,
-                                       TVariableInfoList& infoList);
+                                       TVariableInfoList& infoList,
+                                       ShHashFunction64 hashFunction);
 
 // Returns info for an attribute or uniform.
 static void getVariableInfo(const TType& type,
                             const TString& name,
                             const TString& mappedName,
-                            TVariableInfoList& infoList)
+                            TVariableInfoList& infoList,
+                            ShHashFunction64 hashFunction)
 {
     if (type.getBasicType() == EbtStruct) {
         if (type.isArray()) {
             for (int i = 0; i < type.getArraySize(); ++i) {
                 TString lname = name + arrayBrackets(i);
                 TString lmappedName = mappedName + arrayBrackets(i);
-                getUserDefinedVariableInfo(type, lname, lmappedName, infoList);
+                getUserDefinedVariableInfo(type, lname, lmappedName, infoList, hashFunction);
             }
         } else {
-            getUserDefinedVariableInfo(type, name, mappedName, infoList);
+            getUserDefinedVariableInfo(type, name, mappedName, infoList, hashFunction);
         }
     } else {
         getBuiltInVariableInfo(type, name, mappedName, infoList);
@@ -124,7 +126,8 @@
 void getUserDefinedVariableInfo(const TType& type,
                                 const TString& name,
                                 const TString& mappedName,
-                                TVariableInfoList& infoList)
+                                TVariableInfoList& infoList,
+                                ShHashFunction64 hashFunction)
 {
     ASSERT(type.getBasicType() == EbtStruct);
 
@@ -133,8 +136,9 @@
         const TType* fieldType = (*structure)[i].type;
         getVariableInfo(*fieldType,
                         name + "." + fieldType->getFieldName(),
-                        mappedName + "." + fieldType->getFieldName(),
-                        infoList);
+                        mappedName + "." + TIntermTraverser::hash(fieldType->getFieldName(), hashFunction),
+                        infoList,
+                        hashFunction);
     }
 }
 
@@ -149,9 +153,11 @@
 }
 
 CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs,
-                                               TVariableInfoList& uniforms)
+                                               TVariableInfoList& uniforms,
+                                               ShHashFunction64 hashFunction)
     : mAttribs(attribs),
-      mUniforms(uniforms)
+      mUniforms(uniforms),
+      mHashFunction(hashFunction)
 {
 }
 
@@ -206,10 +212,16 @@
                 // cannot be initialized in a shader, we must have only
                 // TIntermSymbol nodes in the sequence.
                 ASSERT(variable != NULL);
+                TString processedSymbol;
+                if (mHashFunction == NULL)
+                    processedSymbol = variable->getSymbol();
+                else
+                    processedSymbol = TIntermTraverser::hash(variable->getOriginalSymbol(), mHashFunction);
                 getVariableInfo(variable->getType(),
                                 variable->getOriginalSymbol(),
-                                variable->getSymbol(),
-                                infoList);
+                                processedSymbol,
+                                infoList,
+                                mHashFunction);
             }
         }
         break;