Implement scoping
TRAC #11975
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch
Author: Nicolas Capens
git-svn-id: http://angleproject.googlecode.com/svn/trunk@176 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 7ba66e2..109b356 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -24,6 +24,7 @@
OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, true), mContext(context)
{
mUnfoldSelect = new UnfoldSelect(context, this);
+ mInsideFunction = false;
mUsesTexture2D = false;
mUsesTexture2D_bias = false;
@@ -1046,6 +1047,11 @@
{
case EOpSequence:
{
+ if (mInsideFunction)
+ {
+ out << "{\n";
+ }
+
for (TIntermSequence::iterator sit = node->getSequence().begin(); sit != node->getSequence().end(); sit++)
{
if (isSingleStatement(*sit))
@@ -1058,6 +1064,11 @@
out << ";\n";
}
+ if (mInsideFunction)
+ {
+ out << "}\n";
+ }
+
return false;
}
case EOpDeclaration:
@@ -1201,12 +1212,13 @@
sequence.erase(sequence.begin());
- out << ")\n"
- "{\n";
+ out << ")\n";
+
+ mInsideFunction = true;
}
else if (visit == PostVisit)
{
- out << "}\n";
+ mInsideFunction = false;
}
}
break;
diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h
index 7fbdeb5..886c12f 100644
--- a/src/compiler/OutputHLSL.h
+++ b/src/compiler/OutputHLSL.h
@@ -51,6 +51,7 @@
TParseContext &mContext;
UnfoldSelect *mUnfoldSelect;
+ bool mInsideFunction;
// Output streams
TInfoSinkBase mHeader;