MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / translateAssign

Method translateAssign

src/GLSLCompiler.cpp:602–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600 }
601
602 void GLSLCompiler::translateAssign(glsl::astAssignmentExpression *expression) {
603 m_exportLine(expression);
604
605 GLSLCompiler::ExpressionType lType = evaluateExpressionType(expression->operand1);
606 GLSLCompiler::ExpressionType rType = evaluateExpressionType(expression->operand2);
607
608 if (expression->assignment != glsl::kOperator_assign) {// push the lhs to the stack too if we are using some +=, -=, etc... operator
609 translateExpression(expression->operand1);
610 if (rType.Columns * rType.Rows > 1 && lType.Columns * lType.Rows == 1)
611 generateConvert(rType);
612 }
613
614 translateExpression(expression->operand2); // rhs
615 if (lType.Columns * lType.Rows > 1 && rType.Columns * rType.Rows == 1)
616 generateConvert(lType);
617
618 if (expression->assignment == glsl::kOperator_add_assign)
619 m_gen.Function.Add();
620 else if (expression->assignment == glsl::kOperator_sub_assign)
621 m_gen.Function.Subtract();
622 else if (expression->assignment == glsl::kOperator_multiply_assign)
623 m_gen.Function.Multiply();
624 else if (expression->assignment == glsl::kOperator_divide_assign)
625 m_gen.Function.Divide();
626 else if (expression->assignment == glsl::kOperator_modulus_assign)
627 m_gen.Function.Modulo();
628 else if (expression->assignment == glsl::kOperator_shift_left_assign)
629 m_gen.Function.BitLeftShift();
630 else if (expression->assignment == glsl::kOperator_shift_right_assign)
631 m_gen.Function.BitRightShift();
632 else if (expression->assignment == glsl::kOperator_bit_and_assign)
633 m_gen.Function.BitAnd();
634 else if (expression->assignment == glsl::kOperator_bit_xor_assign)
635 m_gen.Function.BitXor();
636 else if (expression->assignment == glsl::kOperator_bit_xor_assign)
637 m_gen.Function.BitOr();
638
639 GLSLCompiler::ExpressionType lhsType = evaluateExpressionType(expression->operand1);
640
641 if (lhsType != evaluateExpressionType(expression->operand2))
642 generateConvert(lhsType); // TODO: only cast when typeof(lhs) != typeof(rhs)
643
644 m_isSet = true;
645 translateExpression(expression->operand1); // lhs
646 m_isSet = false;
647 }
648
649 Function GLSLCompiler::matchFunction(const char* name, const std::vector<glsl::astConstantExpression*>& params)
650 {

Callers

nothing calls this directly

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected