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)
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 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
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 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << ";\n";
}
if (mInsideFunction)
{
out << "}\n";
}
return false;
}
case EOpDeclaration:
......@@ -1201,12 +1212,13 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
sequence.erase(sequence.begin());
out << ")\n"
"{\n";
out << ")\n";
mInsideFunction = true;
}
else if (visit == PostVisit)
{
out << "}\n";
mInsideFunction = false;
}
}
break;
......
......@@ -51,6 +51,7 @@ class OutputHLSL : public TIntermTraverser
TParseContext &mContext;
UnfoldSelect *mUnfoldSelect;
bool mInsideFunction;
// Output streams
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