| 1180 | } |
| 1181 | |
| 1182 | void MSLGenerator::OutputExpression(HLSLExpression* expression, HLSLExpression* parentExpression) |
| 1183 | { |
| 1184 | if (expression->nodeType == HLSLNodeType_IdentifierExpression) { |
| 1185 | HLSLIdentifierExpression* identifierExpression = static_cast<HLSLIdentifierExpression*>(expression); |
| 1186 | const char* name = identifierExpression->name; |
| 1187 | |
| 1188 | { |
| 1189 | if (identifierExpression->global) { |
| 1190 | // prepend cbuffer name |
| 1191 | HLSLBuffer* buffer; |
| 1192 | HLSLDeclaration* declaration = m_tree->FindGlobalDeclaration(identifierExpression->name, &buffer); |
| 1193 | |
| 1194 | if (declaration && declaration->buffer) { |
| 1195 | ASSERT(buffer == declaration->buffer); |
| 1196 | m_writer.Write("%s.", declaration->buffer->name); |
| 1197 | } |
| 1198 | } |
| 1199 | m_writer.Write("%s", name); |
| 1200 | |
| 1201 | // IC: Add swizzle if this is a member access of a field that has the swizzle flag. |
| 1202 | /*if (parentExpression->nodeType == HLSLNodeType_MemberAccess) |
| 1203 | { |
| 1204 | HLSLMemberAccess* memberAccess = (HLSLMemberAccess*)parentExpression; |
| 1205 | const HLSLType & objectType = memberAccess->object->expressionType; |
| 1206 | const HLSLStruct* structure = m_tree->FindGlobalStruct(objectType.typeName); |
| 1207 | if (structure != NULL) |
| 1208 | { |
| 1209 | const HLSLStructField* field = structure->field; |
| 1210 | while (field != NULL) |
| 1211 | { |
| 1212 | if (field->name == name) |
| 1213 | { |
| 1214 | if (field->type.flags & HLSLTypeFlag_Swizzle_BGRA) |
| 1215 | { |
| 1216 | m_writer.Write(".bgra", name); |
| 1217 | } |
| 1218 | } |
| 1219 | } |
| 1220 | } |
| 1221 | }*/ |
| 1222 | } |
| 1223 | } |
| 1224 | else if (expression->nodeType == HLSLNodeType_CastingExpression) { |
| 1225 | HLSLCastingExpression* castingExpression = static_cast<HLSLCastingExpression*>(expression); |
| 1226 | OutputCast(castingExpression->type); |
| 1227 | m_writer.Write("("); |
| 1228 | OutputExpression(castingExpression->expression, castingExpression); |
| 1229 | m_writer.Write(")"); |
| 1230 | } |
| 1231 | else if (expression->nodeType == HLSLNodeType_ConstructorExpression) { |
| 1232 | HLSLConstructorExpression* constructorExpression = static_cast<HLSLConstructorExpression*>(expression); |
| 1233 | |
| 1234 | m_writer.Write("%s(", GetTypeName(constructorExpression->type, /*exactType=*/false)); |
| 1235 | //OutputExpressionList(constructorExpression->type, constructorExpression->argument); // @@ Get element type. |
| 1236 | OutputExpressionList(constructorExpression->argument); |
| 1237 | m_writer.Write(")"); |
| 1238 | } |
| 1239 | else if (expression->nodeType == HLSLNodeType_LiteralExpression) { |
nothing calls this directly
no test coverage detected