Compiler - access struct fields

TRAC #11379 Signed-off-by: Daniel Koch Author: Nicolas Capens <nicolas@transgaming.com> git-svn-id: https://angleproject.googlecode.com/svn/trunk@14 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent fbb6dfa3
......@@ -405,7 +405,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpRightShiftAssign: UNIMPLEMENTED(); /* FIXME */ out << "right shift second child into first child"; break;
case EOpIndexDirect: outputTriplet(visit, NULL, "[", "]"); break;
case EOpIndexIndirect: outputTriplet(visit, NULL, "[", "]"); break;
case EOpIndexDirectStruct: UNIMPLEMENTED(); /* FIXME */ out << "direct index for structure"; break;
case EOpIndexDirectStruct: outputTriplet(visit, NULL, ".", NULL); break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
......@@ -919,11 +919,19 @@ void OutputHLSL::visitConstantUnion(TIntermConstantUnion *node)
{
TInfoSinkBase &out = context.infoSink.obj;
int size = node->getType().getObjectSize();
bool matrix = node->getType().isMatrix();
TBasicType type = node->getUnionArrayPointer()[0].getType();
TType &type = node->getType();
switch (type)
if(type.isField())
{
out << type.getFieldName();
}
else
{
int size = type.getObjectSize();
bool matrix = type.isMatrix();
TBasicType basicType = node->getUnionArrayPointer()[0].getType();
switch (basicType)
{
case EbtBool:
if (!matrix)
......@@ -988,7 +996,7 @@ void OutputHLSL::visitConstantUnion(TIntermConstantUnion *node)
for (int i = 0; i < size; i++)
{
switch (type)
switch (basicType)
{
case EbtBool:
if (node->getUnionArrayPointer()[i].getBConst())
......@@ -1015,6 +1023,7 @@ void OutputHLSL::visitConstantUnion(TIntermConstantUnion *node)
out << ", ";
}
}
}
out << ")";
}
......
......@@ -205,6 +205,7 @@ public:
virtual bool isMatrix() const { return matrix ? true : false; }
virtual bool isArray() const { return array ? true : false; }
bool isField() const { return fieldName != 0; }
int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; }
void setMaxArraySize (int s) { maxArraySize = s; }
......
......@@ -422,7 +422,7 @@ postfix_expression
} else {
constUnion *unionArray = new constUnion[1];
unionArray->setIConst(i);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
$$ = parseContext.intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
$$->setType(*(*fields)[i].type);
}
......
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