Move symbol table initialization to SymbolTable.cpp
This is needed in order to make symbol table symbols statically
allocated.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: Ia2d44fb30d49dc5d5c67643fe01280c89127a3c3
Reviewed-on: https://chromium-review.googlesource.com/889299
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index a53e875..dc09f54 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -708,56 +708,11 @@
compileResources = resources;
setResourceString();
- ASSERT(symbolTable.isEmpty());
- symbolTable.push(); // COMMON_BUILTINS
- symbolTable.push(); // ESSL1_BUILTINS
- symbolTable.push(); // ESSL3_BUILTINS
- symbolTable.push(); // ESSL3_1_BUILTINS
- symbolTable.push(); // GLSL_BUILTINS
-
- switch (shaderType)
- {
- case GL_FRAGMENT_SHADER:
- symbolTable.setDefaultPrecision(EbtInt, EbpMedium);
- break;
- case GL_VERTEX_SHADER:
- case GL_COMPUTE_SHADER:
- case GL_GEOMETRY_SHADER_EXT:
- symbolTable.setDefaultPrecision(EbtInt, EbpHigh);
- symbolTable.setDefaultPrecision(EbtFloat, EbpHigh);
- break;
- default:
- UNREACHABLE();
- }
- // Set defaults for sampler types that have default precision, even those that are
- // only available if an extension exists.
- // New sampler types in ESSL3 don't have default precision. ESSL1 types do.
- initSamplerDefaultPrecision(EbtSampler2D);
- initSamplerDefaultPrecision(EbtSamplerCube);
- // SamplerExternalOES is specified in the extension to have default precision.
- initSamplerDefaultPrecision(EbtSamplerExternalOES);
- // SamplerExternal2DY2YEXT is specified in the extension to have default precision.
- initSamplerDefaultPrecision(EbtSamplerExternal2DY2YEXT);
- // It isn't specified whether Sampler2DRect has default precision.
- initSamplerDefaultPrecision(EbtSampler2DRect);
-
- symbolTable.setDefaultPrecision(EbtAtomicCounter, EbpHigh);
-
- InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);
-
- IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable);
-
- symbolTable.markBuiltInInitializationFinished();
+ symbolTable.initializeBuiltIns(shaderType, shaderSpec, resources);
return true;
}
-void TCompiler::initSamplerDefaultPrecision(TBasicType samplerType)
-{
- ASSERT(samplerType > EbtGuardSamplerBegin && samplerType < EbtGuardSamplerEnd);
- symbolTable.setDefaultPrecision(samplerType, EbpLow);
-}
-
void TCompiler::setResourceString()
{
std::ostringstream strstream;