| 633 | } |
| 634 | } |
| 635 | void HLSLCompiler::translateAssignExpression(M4::HLSLBinaryExpression* expr) |
| 636 | { |
| 637 | HLSLCompiler::ExpressionType lType = m_convertType(expr->expression1->expressionType); |
| 638 | HLSLCompiler::ExpressionType rType = m_convertType(expr->expression2->expressionType); |
| 639 | |
| 640 | if (expr->binaryOp != M4::HLSLBinaryOp_Assign) { // push the lhs to the stack too if we are using some +=, -=, etc... operator |
| 641 | translateExpression(expr->expression1); |
| 642 | if (rType.Columns * rType.Rows > 1 && lType.Columns * lType.Rows == 1) |
| 643 | m_generateConvert(rType); |
| 644 | } |
| 645 | translateExpression(expr->expression2); // rhs |
| 646 | if (lType.Columns * lType.Rows > 1 && rType.Columns * rType.Rows == 1) |
| 647 | m_generateConvert(lType); |
| 648 | |
| 649 | if (expr->binaryOp == M4::HLSLBinaryOp_AddAssign) |
| 650 | m_gen.Function.Add(); |
| 651 | else if (expr->binaryOp == M4::HLSLBinaryOp_SubAssign) |
| 652 | m_gen.Function.Subtract(); |
| 653 | else if (expr->binaryOp == M4::HLSLBinaryOp_MulAssign) |
| 654 | m_gen.Function.Multiply(); |
| 655 | else if (expr->binaryOp == M4::HLSLBinaryOp_DivAssign) |
| 656 | m_gen.Function.Divide(); |
| 657 | |
| 658 | if (lType != rType) |
| 659 | m_generateConvert(lType); |
| 660 | |
| 661 | m_isSet = true; |
| 662 | translateExpression(expr->expression1); // lhs |
| 663 | m_isSet = false; |
| 664 | } |
| 665 | void HLSLCompiler::translateUnaryExpression(M4::HLSLUnaryExpression* expr) |
| 666 | { |
| 667 | // check if pre or post increment/decrement |