Clean up TCompiler members and style

Some dead code and duplicate data are cleaned up from the compiler.
Several parameters can be accessed directly from ShBuiltInResources
instead of creating a copy in TCompiler.

This also encapsulates some TCompiler member functions as private and
changes the remaining unprefixed TCompiler member variable names to
start with the m prefix.

BUG=angleproject:2068
TEST=angle_unittests

Change-Id: I6690aaf538b17e0f45460660272a21f82f1808a0
Reviewed-on: https://chromium-review.googlesource.com/c/1267503
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Compiler.h b/src/compiler/translator/Compiler.h
index 2dc0fe6..2eef387 100644
--- a/src/compiler/translator/Compiler.h
+++ b/src/compiler/translator/Compiler.h
@@ -94,8 +94,8 @@
                  ShCompileOptions compileOptions);
 
     // Get results of the last compilation.
-    int getShaderVersion() const { return shaderVersion; }
-    TInfoSink &getInfoSink() { return infoSink; }
+    int getShaderVersion() const { return mShaderVersion; }
+    TInfoSink &getInfoSink() { return mInfoSink; }
 
     bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; }
     const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; }
@@ -104,25 +104,25 @@
     // Clears the results from the previous compilation.
     void clearResults();
 
-    const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
-    const std::vector<sh::OutputVariable> &getOutputVariables() const { return outputVariables; }
-    const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
-    const std::vector<sh::Varying> &getInputVaryings() const { return inputVaryings; }
-    const std::vector<sh::Varying> &getOutputVaryings() const { return outputVaryings; }
-    const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
-    const std::vector<sh::InterfaceBlock> &getUniformBlocks() const { return uniformBlocks; }
+    const std::vector<sh::Attribute> &getAttributes() const { return mAttributes; }
+    const std::vector<sh::OutputVariable> &getOutputVariables() const { return mOutputVariables; }
+    const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; }
+    const std::vector<sh::Varying> &getInputVaryings() const { return mInputVaryings; }
+    const std::vector<sh::Varying> &getOutputVaryings() const { return mOutputVaryings; }
+    const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; }
+    const std::vector<sh::InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; }
     const std::vector<sh::InterfaceBlock> &getShaderStorageBlocks() const
     {
-        return shaderStorageBlocks;
+        return mShaderStorageBlocks;
     }
-    const std::vector<sh::InterfaceBlock> &getInBlocks() const { return inBlocks; }
+    const std::vector<sh::InterfaceBlock> &getInBlocks() const { return mInBlocks; }
 
-    ShHashFunction64 getHashFunction() const { return hashFunction; }
-    NameMap &getNameMap() { return nameMap; }
-    TSymbolTable &getSymbolTable() { return symbolTable; }
-    ShShaderSpec getShaderSpec() const { return shaderSpec; }
-    ShShaderOutput getOutputType() const { return outputType; }
-    const std::string &getBuiltInResourcesString() const { return builtInResourcesString; }
+    ShHashFunction64 getHashFunction() const { return mResources.HashFunction; }
+    NameMap &getNameMap() { return mNameMap; }
+    TSymbolTable &getSymbolTable() { return mSymbolTable; }
+    ShShaderSpec getShaderSpec() const { return mShaderSpec; }
+    ShShaderOutput getOutputType() const { return mOutputType; }
+    const std::string &getBuiltInResourcesString() const { return mBuiltInResourcesString; }
 
     bool shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const;
 
@@ -140,15 +140,9 @@
         return mGeometryShaderOutputPrimitiveType;
     }
 
-    sh::GLenum getShaderType() const { return shaderType; }
+    sh::GLenum getShaderType() const { return mShaderType; }
 
   protected:
-    // Initialize symbol-table with built-in symbols.
-    bool InitBuiltInSymbolTable(const ShBuiltInResources &resources);
-    // Compute the string representation of the built-in resources
-    void setResourceString();
-    // Return false if the call depth is exceeded.
-    bool checkCallDepth();
     // Add emulated functions to the built-in function emulator.
     virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
                                              ShCompileOptions compileOptions){};
@@ -156,20 +150,6 @@
     virtual void translate(TIntermBlock *root,
                            ShCompileOptions compileOptions,
                            PerformanceDiagnostics *perfDiagnostics) = 0;
-    // Insert statements to reference all members in unused uniform blocks with standard and shared
-    // layout. This is to work around a Mac driver that treats unused standard/shared
-    // uniform blocks as inactive.
-    void useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root);
-    // Insert statements to initialize output variables in the beginning of main().
-    // This is to avoid undefined behaviors.
-    void initializeOutputVariables(TIntermBlock *root);
-    // Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
-    // It is to work around a Linux driver bug where missing this causes compile failure
-    // while spec says it is allowed.
-    // This function should only be applied to vertex shaders.
-    void initializeGLPosition(TIntermBlock *root);
-    // Return true if the maximum expression complexity is below the limit.
-    bool limitExpressionComplexity(TIntermBlock *root);
     // Get built-in extensions with default behavior.
     const TExtensionBehavior &getExtensionBehavior() const;
     const char *getSourcePath() const;
@@ -186,28 +166,46 @@
     virtual bool shouldCollectVariables(ShCompileOptions compileOptions);
 
     bool wereVariablesCollected() const;
-    std::vector<sh::Attribute> attributes;
-    std::vector<sh::OutputVariable> outputVariables;
-    std::vector<sh::Uniform> uniforms;
-    std::vector<sh::Varying> inputVaryings;
-    std::vector<sh::Varying> outputVaryings;
-    std::vector<sh::InterfaceBlock> interfaceBlocks;
-    std::vector<sh::InterfaceBlock> uniformBlocks;
-    std::vector<sh::InterfaceBlock> shaderStorageBlocks;
-    std::vector<sh::InterfaceBlock> inBlocks;
+    std::vector<sh::Attribute> mAttributes;
+    std::vector<sh::OutputVariable> mOutputVariables;
+    std::vector<sh::Uniform> mUniforms;
+    std::vector<sh::Varying> mInputVaryings;
+    std::vector<sh::Varying> mOutputVaryings;
+    std::vector<sh::InterfaceBlock> mInterfaceBlocks;
+    std::vector<sh::InterfaceBlock> mUniformBlocks;
+    std::vector<sh::InterfaceBlock> mShaderStorageBlocks;
+    std::vector<sh::InterfaceBlock> mInBlocks;
 
   private:
+    // Initialize symbol-table with built-in symbols.
+    bool initBuiltInSymbolTable(const ShBuiltInResources &resources);
+    // Compute the string representation of the built-in resources
+    void setResourceString();
+    // Return false if the call depth is exceeded.
+    bool checkCallDepth();
+    // Insert statements to reference all members in unused uniform blocks with standard and shared
+    // layout. This is to work around a Mac driver that treats unused standard/shared
+    // uniform blocks as inactive.
+    void useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root);
+    // Insert statements to initialize output variables in the beginning of main().
+    // This is to avoid undefined behaviors.
+    void initializeOutputVariables(TIntermBlock *root);
+    // Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
+    // It is to work around a Linux driver bug where missing this causes compile failure
+    // while spec says it is allowed.
+    // This function should only be applied to vertex shaders.
+    void initializeGLPosition(TIntermBlock *root);
+    // Return true if the maximum expression complexity is below the limit.
+    bool limitExpressionComplexity(TIntermBlock *root);
     // Creates the function call DAG for further analysis, returning false if there is a recursion
     bool initCallDag(TIntermNode *root);
     // Return false if "main" doesn't exist
     bool tagUsedFunctions();
     void internalTagUsedFunction(size_t index);
 
-    void initSamplerDefaultPrecision(TBasicType samplerType);
-
     void collectInterfaceBlocks();
 
-    bool variablesCollected;
+    bool mVariablesCollected;
 
     bool mGLPositionInitialized;
 
@@ -231,9 +229,9 @@
                              const TParseContext &parseContext,
                              ShCompileOptions compileOptions);
 
-    sh::GLenum shaderType;
-    ShShaderSpec shaderSpec;
-    ShShaderOutput outputType;
+    sh::GLenum mShaderType;
+    ShShaderSpec mShaderSpec;
+    ShShaderOutput mOutputType;
 
     struct FunctionMetadata
     {
@@ -242,30 +240,23 @@
     };
 
     CallDAG mCallDag;
-    std::vector<FunctionMetadata> functionMetadata;
+    std::vector<FunctionMetadata> mFunctionMetadata;
 
-    int maxUniformVectors;
-    int maxExpressionComplexity;
-    int maxCallStackDepth;
-    int maxFunctionParameters;
-
-    ShBuiltInResources compileResources;
-    std::string builtInResourcesString;
+    ShBuiltInResources mResources;
+    std::string mBuiltInResourcesString;
 
     // Built-in symbol table for the given language, spec, and resources.
     // It is preserved from compile-to-compile.
-    TSymbolTable symbolTable;
+    TSymbolTable mSymbolTable;
     // Built-in extensions with default behavior.
-    TExtensionBehavior extensionBehavior;
-    bool fragmentPrecisionHigh;
+    TExtensionBehavior mExtensionBehavior;
 
-    ArrayBoundsClamper arrayBoundsClamper;
-    ShArrayIndexClampingStrategy clampingStrategy;
-    BuiltInFunctionEmulator builtInFunctionEmulator;
+    ArrayBoundsClamper mArrayBoundsClamper;
+    BuiltInFunctionEmulator mBuiltInFunctionEmulator;
 
     // Results of compilation.
-    int shaderVersion;
-    TInfoSink infoSink;       // Output sink.
+    int mShaderVersion;
+    TInfoSink mInfoSink;  // Output sink.
     TDiagnostics mDiagnostics;
     const char *mSourcePath;  // Path of source file or NULL
 
@@ -283,8 +274,7 @@
     TLayoutPrimitiveType mGeometryShaderOutputPrimitiveType;
 
     // name hashing.
-    ShHashFunction64 hashFunction;
-    NameMap nameMap;
+    NameMap mNameMap;
 
     TPragma mPragma;
 };