Implement scoping

TRAC #11975 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@176 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6e49740d
...@@ -24,6 +24,7 @@ TString str(int i) ...@@ -24,6 +24,7 @@ TString str(int i)
OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, true), mContext(context) OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, true), mContext(context)
{ {
mUnfoldSelect = new UnfoldSelect(context, this); mUnfoldSelect = new UnfoldSelect(context, this);
mInsideFunction = false;
mUsesTexture2D = false; mUsesTexture2D = false;
mUsesTexture2D_bias = false; mUsesTexture2D_bias = false;
...@@ -1046,6 +1047,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1046,6 +1047,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
case EOpSequence: case EOpSequence:
{ {
if (mInsideFunction)
{
out << "{\n";
}
for (TIntermSequence::iterator sit = node->getSequence().begin(); sit != node->getSequence().end(); sit++) for (TIntermSequence::iterator sit = node->getSequence().begin(); sit != node->getSequence().end(); sit++)
{ {
if (isSingleStatement(*sit)) if (isSingleStatement(*sit))
...@@ -1058,6 +1064,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1058,6 +1064,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << ";\n"; out << ";\n";
} }
if (mInsideFunction)
{
out << "}\n";
}
return false; return false;
} }
case EOpDeclaration: case EOpDeclaration:
...@@ -1201,12 +1212,13 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1201,12 +1212,13 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
sequence.erase(sequence.begin()); sequence.erase(sequence.begin());
out << ")\n" out << ")\n";
"{\n";
mInsideFunction = true;
} }
else if (visit == PostVisit) else if (visit == PostVisit)
{ {
out << "}\n"; mInsideFunction = false;
} }
} }
break; break;
......
...@@ -51,6 +51,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -51,6 +51,7 @@ class OutputHLSL : public TIntermTraverser
TParseContext &mContext; TParseContext &mContext;
UnfoldSelect *mUnfoldSelect; UnfoldSelect *mUnfoldSelect;
bool mInsideFunction;
// Output streams // Output streams
TInfoSinkBase mHeader; TInfoSinkBase mHeader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment