Eliminate TShHandleBase.
Bug 19331817
Change-Id: I3dc11a3e4eaea734ae86e2722d2565ce136fe335
Reviewed-on: https://swiftshader-review.googlesource.com/2151
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/Compiler.cpp b/src/OpenGL/compiler/Compiler.cpp
index ba5d2ae..e34bee9 100644
--- a/src/OpenGL/compiler/Compiler.cpp
+++ b/src/OpenGL/compiler/Compiler.cpp
@@ -31,25 +31,19 @@
};
} // namespace
-TShHandleBase::TShHandleBase() {
- allocator.push();
- SetGlobalPoolAllocator(&allocator);
-}
-
-TShHandleBase::~TShHandleBase() {
- SetGlobalPoolAllocator(NULL);
- allocator.popAll();
-}
-
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
: shaderType(type),
shaderSpec(spec),
maxCallStackDepth(UINT_MAX)
{
+ allocator.push();
+ SetGlobalPoolAllocator(&allocator);
}
TCompiler::~TCompiler()
{
+ SetGlobalPoolAllocator(NULL);
+ allocator.popAll();
}
bool TCompiler::Init(const ShBuiltInResources& resources)
diff --git a/src/OpenGL/compiler/Compiler.h b/src/OpenGL/compiler/Compiler.h
index d37a2e9..8457cc6 100644
--- a/src/OpenGL/compiler/Compiler.h
+++ b/src/OpenGL/compiler/Compiler.h
@@ -20,28 +20,12 @@
#include "InfoSink.h"
#include "SymbolTable.h"
-class TCompiler;
-
-//
-// The base class used to back handles returned to the driver.
-//
-class TShHandleBase {
-public:
- TShHandleBase();
- virtual ~TShHandleBase();
- virtual TCompiler* getAsCompiler() { return 0; }
-
-protected:
- // Memory allocator. Allocates and tracks memory required by the compiler.
- // Deallocates all memory when compiler is destructed.
- TPoolAllocator allocator;
-};
-
//
// The base class for the machine dependent compiler to derive from
// for managing object code from the compile.
//
-class TCompiler : public TShHandleBase {
+class TCompiler
+{
public:
TCompiler(ShShaderType type, ShShaderSpec spec);
virtual ~TCompiler();
@@ -86,6 +70,10 @@
// Results of compilation.
TInfoSink infoSink; // Output sink.
+
+ // Memory allocator. Allocates and tracks memory required by the compiler.
+ // Deallocates all memory when compiler is destructed.
+ TPoolAllocator allocator;
};
//
diff --git a/src/OpenGL/compiler/ShaderLang.cpp b/src/OpenGL/compiler/ShaderLang.cpp
index 39596e5..8589575 100644
--- a/src/OpenGL/compiler/ShaderLang.cpp
+++ b/src/OpenGL/compiler/ShaderLang.cpp
@@ -64,7 +64,7 @@
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
const ShBuiltInResources* resources)
{
- TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec));
+ TCompiler* base = ConstructCompiler(type, spec);
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
return 0;
@@ -83,7 +83,7 @@
if (handle == 0)
return;
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+ TCompiler* base = static_cast<TCompiler*>(handle);
if (base->getAsCompiler())
DeleteCompiler(base->getAsCompiler());
@@ -105,7 +105,7 @@
if (handle == 0)
return 0;
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TCompiler* base = reinterpret_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
return 0;
@@ -119,7 +119,7 @@
if (!handle || !params)
return;
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+ TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;
@@ -149,7 +149,7 @@
if (!handle || !infoLog)
return;
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+ TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;
@@ -165,7 +165,7 @@
if (!handle || !objCode)
return;
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+ TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;