Use a stack for OutputHLSL info log output.
Previously we would always reference mBody in several intermediate
output methods. This made using these traversals from within the
header, or for utility methods, very difficult. Instead, use a stack
where we write to the top InfoLog, and can push/pop from the stack.
This gives us more flexibility.
BUG=angle:878
Change-Id: I8a6c0382bad18b44d75158274c701db13d4d4e65
Reviewed-on: https://chromium-review.googlesource.com/243580
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.h b/src/compiler/translator/OutputHLSL.h
index b2b3b80..0f9b6d6 100644
--- a/src/compiler/translator/OutputHLSL.h
+++ b/src/compiler/translator/OutputHLSL.h
@@ -10,6 +10,7 @@
#include <list>
#include <set>
#include <map>
+#include <stack>
#include "angle_gl.h"
#include "compiler/translator/IntermNode.h"
@@ -33,13 +34,13 @@
void output();
- TInfoSinkBase &getBodyStream();
-
const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const;
const std::map<std::string, unsigned int> &getUniformRegisterMap() const;
static TString initializer(const TType &type);
+ TInfoSinkBase &getInfoSink() { ASSERT(!mInfoSinkStack.empty()); return *mInfoSinkStack.top(); }
+
protected:
void header(const BuiltInFunctionEmulatorHLSL *builtInFunctionEmulator);
@@ -77,6 +78,10 @@
TInfoSinkBase mBody;
TInfoSinkBase mFooter;
+ // A stack is useful when we want to traverse in the header, or in helper functions, but not always
+ // write to the body. Instead use an InfoSink stack to keep our current state intact.
+ std::stack<TInfoSinkBase *> mInfoSinkStack;
+
ReferencedSymbols mReferencedUniforms;
ReferencedSymbols mReferencedInterfaceBlocks;
ReferencedSymbols mReferencedAttributes;