Add all structure definitions to constructor map and simplify initialization

TRAC #11809 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@204 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 7a7003c3
......@@ -1153,6 +1153,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
if (variable && (variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal))
{
if (variable->getType().getStruct())
{
addConstructor(variable->getType(), variable->getType().getTypeName(), NULL);
}
if (!variable->getAsSymbolNode() || variable->getAsSymbolNode()->getSymbol() != "") // Variable declaration
{
if (!mInsideFunction)
......@@ -1193,7 +1198,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
}
else if (variable->getAsSymbolNode() && variable->getAsSymbolNode()->getSymbol() == "") // Type (struct) declaration
{
addConstructor(variable->getType(), variable->getType().getTypeName(), NULL);
// Already added to constructor map
}
else UNREACHABLE();
}
......@@ -2065,41 +2070,17 @@ TString OutputHLSL::initializer(const TType &type)
{
TString string;
int arraySize = type.isArray() ? type.getArraySize() : 1;
if (type.isArray())
{
string += "{";
}
for (int element = 0; element < arraySize; element++)
for (int component = 0; component < type.getObjectSize(); component++)
{
string += typeString(type) + "(";
string += "0";
for (int component = 0; component < type.getInstanceSize(); component++)
{
string += "0";
if (component < type.getInstanceSize() - 1)
{
string += ", ";
}
}
string += ")";
if (element < arraySize - 1)
if (component < type.getObjectSize() - 1)
{
string += ", ";
}
}
if (type.isArray())
{
string += "}";
}
return string;
return "{" + string + "}";
}
bool OutputHLSL::CompareConstructor::operator()(const Constructor &x, const Constructor &y) const
......
......@@ -1355,7 +1355,7 @@ init_declarator_list
single_declaration
: fully_specified_type {
$$.type = $1;
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line);;
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line);
}
| fully_specified_type IDENTIFIER {
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
......
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