Refer to GLSL extensions through TExtension enum

Extensions are now referred to by enum values instead of strings most
of the time. This gets rid of unnecessary copying of strings. The code
is easier to work with than before as typoing the extension enum names
will be caught by the compiler.

BUG=angleproject:2147
TEST=angle_unittests

Change-Id: Ifa61b9f86ef03211188fc23bc23a5ce4e4d8c390
Reviewed-on: https://chromium-review.googlesource.com/571002
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index 58788a1..bcd51fd 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -35,6 +35,7 @@
 #include <set>
 
 #include "common/angleutils.h"
+#include "compiler/translator/ExtensionBehavior.h"
 #include "compiler/translator/InfoSink.h"
 #include "compiler/translator/IntermNode.h"
 
@@ -74,13 +75,13 @@
     virtual bool isFunction() const { return false; }
     virtual bool isVariable() const { return false; }
     int getUniqueId() const { return uniqueId; }
-    void relateToExtension(const TString &ext) { extension = ext; }
-    const TString &getExtension() const { return extension; }
+    void relateToExtension(TExtension ext) { extension = ext; }
+    TExtension getExtension() const { return extension; }
 
   private:
     const int uniqueId;
     const TString *name;
-    TString extension;
+    TExtension extension;
 };
 
 // Variable, meaning a symbol that's not a function.
@@ -165,8 +166,8 @@
     TFunction(TSymbolTable *symbolTable,
               const TString *name,
               const TType *retType,
-              TOperator tOp   = EOpNull,
-              const char *ext = "")
+              TOperator tOp  = EOpNull,
+              TExtension ext = TExtension::UNDEFINED)
         : TSymbol(symbolTable, name),
           returnType(retType),
           mangledName(nullptr),
@@ -343,12 +344,12 @@
     // declaration failed due to redefinition.
     TVariable *insertVariable(ESymbolLevel level, const char *name, const TType &type);
     TVariable *insertVariableExt(ESymbolLevel level,
-                                 const char *ext,
+                                 TExtension ext,
                                  const char *name,
                                  const TType &type);
     TVariable *insertStructType(ESymbolLevel level, TStructure *str);
     TInterfaceBlockName *insertInterfaceBlockNameExt(ESymbolLevel level,
-                                                     const char *ext,
+                                                     TExtension ext,
                                                      const TString *name);
 
     bool insertConstInt(ESymbolLevel level, const char *name, int value, TPrecision precision)
@@ -362,7 +363,7 @@
     }
 
     bool insertConstIntExt(ESymbolLevel level,
-                           const char *ext,
+                           TExtension ext,
                            const char *name,
                            int value,
                            TPrecision precision)
@@ -395,7 +396,7 @@
 
     void insertBuiltIn(ESymbolLevel level,
                        TOperator op,
-                       const char *ext,
+                       TExtension ext,
                        const TType *rvalue,
                        const char *name,
                        const TType *ptype1,
@@ -414,11 +415,12 @@
                        const TType *ptype5 = 0)
     {
         insertUnmangledBuiltInName(name, level);
-        insertBuiltIn(level, EOpNull, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, EOpNull, TExtension::UNDEFINED, rvalue, name, ptype1, ptype2, ptype3,
+                      ptype4, ptype5);
     }
 
     void insertBuiltIn(ESymbolLevel level,
-                       const char *ext,
+                       TExtension ext,
                        const TType *rvalue,
                        const char *name,
                        const TType *ptype1,
@@ -442,7 +444,7 @@
 
     void insertBuiltInOp(ESymbolLevel level,
                          TOperator op,
-                         const char *ext,
+                         TExtension ext,
                          const TType *rvalue,
                          const TType *ptype1,
                          const TType *ptype2 = 0,
@@ -456,7 +458,7 @@
                                            const char *name);
 
     void insertBuiltInFunctionNoParametersExt(ESymbolLevel level,
-                                              const char *ext,
+                                              TExtension ext,
                                               TOperator op,
                                               const TType *rvalue,
                                               const char *name);
@@ -524,7 +526,7 @@
 
     bool insert(ESymbolLevel level, TSymbol *symbol) { return table[level]->insert(symbol); }
 
-    bool insert(ESymbolLevel level, const char *ext, TSymbol *symbol)
+    bool insert(ESymbolLevel level, TExtension ext, TSymbol *symbol)
     {
         symbol->relateToExtension(ext);
         return table[level]->insert(symbol);