Implemented short-circuiting behavior for the ternary operator
TRAC #11444
This is achieved by turning the ternary operator into conditional code.
The UnfoldSelect intermediate code traverser places this conditional
code before the statement containing the ternary operator (aka. select).
The computed value is assigned to a temporary variable.
On outputting the actual statement the ternary operator is
replaced by the temporary variable.
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/trunk@148 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h
index 43ee78c..aa65611 100644
--- a/src/compiler/OutputHLSL.h
+++ b/src/compiler/OutputHLSL.h
@@ -12,13 +12,25 @@
namespace sh
{
+class UnfoldSelect;
+
class OutputHLSL : public TIntermTraverser
{
public:
- OutputHLSL(TParseContext &context);
+ explicit OutputHLSL(TParseContext &context);
+ ~OutputHLSL();
void output();
+ TInfoSinkBase &getBodyStream();
+
+ static TString argumentString(const TIntermSymbol *symbol);
+ static TString qualifierString(TQualifier qualifier);
+ static TString typeString(const TType &type);
+ static TString arrayString(const TType &type);
+ static TString initializer(const TType &type);
+ static TString decorate(const TString &string); // Prepend an underscore to avoid naming clashes
+
protected:
void header();
void footer();
@@ -33,17 +45,12 @@
bool visitLoop(Visit visit, TIntermLoop*);
bool visitBranch(Visit visit, TIntermBranch*);
+ bool isSingleStatement(TIntermNode *node);
bool handleExcessiveLoop(TIntermLoop *node);
void outputTriplet(Visit visit, const char *preString, const char *inString, const char *postString);
- static TString argumentString(const TIntermSymbol *symbol);
- static TString qualifierString(TQualifier qualifier);
- static TString typeString(const TType &type);
- static TString arrayString(const TType &type);
- static TString initializer(const TType &type);
- static TString decorate(const TString &string); // Prepend an underscore to avoid naming clashes
-
TParseContext &mContext;
+ UnfoldSelect *mUnfoldSelect;
// Output streams
TInfoSinkBase mHeader;