// t = b + c
        // a = t

        // a = b + c

        private void MergeBinary()
        {
            for (int index = 0; index < (m_middleCodeList.Count - 1); ++index)
            {
                MiddleCode thisCode = m_middleCodeList[index],
                           nextCode = m_middleCodeList[index + 1];

                if ((/*thisCode.IsUnary() ||*/ thisCode.IsBinary()) &&
                    (nextCode.Operator == MiddleOperator.Assign) &&
                    ((Symbol)thisCode[0]).IsTemporary() &&
                    (thisCode[0] == nextCode[1]))
                {
                    thisCode[0] = nextCode[0];
                    nextCode.Clear();
                    m_update = true;
                }
            }
        }
        private void SematicOptimization()
        {
            for (int index = 0; index < m_middleCodeList.Count; ++index)
            {
                MiddleCode thisCode = m_middleCodeList[index];

                if (thisCode.IsBinary())
                {
                    Symbol resultSymbol = (Symbol)thisCode[0],
                           leftSymbol   = (Symbol)thisCode[1],
                           rightSymbol  = (Symbol)thisCode[2],
                           newSymbol    = null;

                    if ((leftSymbol.Value is BigInteger) && // t0 = 2 * 3
                        (rightSymbol.Value is BigInteger))
                    {
                        newSymbol =
                            ConstantExpression.ArithmeticIntegral(thisCode.Operator,
                                                                  leftSymbol, rightSymbol);
                    }
                    // t0 = 0 + i
                    else if ((thisCode.Operator == MiddleOperator.Add) &&
                             (leftSymbol.Value is BigInteger) &&
                             (leftSymbol.Value.Equals(BigInteger.Zero)))
                    {
                        newSymbol = rightSymbol;
                    }
                    // t0 = 0 - i; t0 = -i
                    else if ((thisCode.Operator == MiddleOperator.Subtract) &&
                             (leftSymbol.Value is BigInteger) &&
                             (leftSymbol.Value.Equals(BigInteger.Zero)))
                    {
                        thisCode.Operator = MiddleOperator.Minus;
                        thisCode[0]       = thisCode[1];
                        thisCode[1]       = null;
                    }

                    // t0 = i + 0
                    // t0 = i - 0
                    else if (((thisCode.Operator == MiddleOperator.Add) ||
                              (thisCode.Operator == MiddleOperator.Subtract)) &&
                             (rightSymbol.Value is BigInteger) &&
                             (rightSymbol.Value.Equals(BigInteger.Zero)))
                    {
                        newSymbol = leftSymbol;
                    }
                    // t0 = 0 * i
                    else if ((thisCode.Operator == MiddleOperator.Multiply) &&
                             (leftSymbol.Value is BigInteger) &&
                             (leftSymbol.Value.Equals(BigInteger.Zero)))
                    {
                        newSymbol = new Symbol(resultSymbol.Type, BigInteger.Zero);
                    }
                    // t0 = 1 * i
                    else if ((thisCode.Operator == MiddleOperator.Multiply) &&
                             (leftSymbol.Value is BigInteger) &&
                             (leftSymbol.Value.Equals(BigInteger.One)))
                    {
                        newSymbol = rightSymbol;
                    }
                    // t0 = i * 0
                    else if ((thisCode.Operator == MiddleOperator.Multiply) &&
                             (rightSymbol.Value is BigInteger) &&
                             (rightSymbol.Value.Equals(BigInteger.Zero)))
                    {
                        newSymbol = new Symbol(resultSymbol.Type, BigInteger.Zero);
                    }

                    // t0 = -1 * i
                    else if ((thisCode.Operator == MiddleOperator.Multiply) &&
                             (leftSymbol.Value is BigInteger) &&
                             (leftSymbol.Value.Equals(BigInteger.MinusOne)))
                    {
                        thisCode.Operator = MiddleOperator.Minus;
                        thisCode[0]       = thisCode[1];
                        thisCode[1]       = null;
                    }
                    // t0 = i * -1
                    else if ((thisCode.Operator == MiddleOperator.Multiply) &&
                             (rightSymbol.Value is BigInteger) &&
                             (rightSymbol.Value.Equals(BigInteger.MinusOne)))
                    {
                        thisCode.Operator = MiddleOperator.Minus;
                        thisCode[1]       = null;
                    }

                    // t0 = i * 1
                    // t0 = i / 1
                    // t0 = i % 1
                    else if (((thisCode.Operator == MiddleOperator.Multiply) ||
                              (thisCode.Operator == MiddleOperator.Divide) ||
                              (thisCode.Operator == MiddleOperator.Modulo)) &&
                             (rightSymbol.Value is BigInteger) &&
                             (rightSymbol.Value.Equals(BigInteger.One)))
                    {
                        newSymbol = leftSymbol;
                    }

                    if (newSymbol != null)
                    {
                        if (resultSymbol.IsTemporary())
                        {
                            thisCode.Operator = MiddleOperator.Empty;

                            if (newSymbol.IsTemporary())
                            {
                                int index2;
                                for (index2 = (index - 1); index2 >= 0; --index2)
                                {
                                    MiddleCode previousCode = m_middleCodeList[index2];

                                    if (previousCode[0] == resultSymbol)
                                    {
                                        previousCode[0] = newSymbol;
                                        break;
                                    }
                                }
                            }

                            { int index2;
                              for (index2 = index + 1; index2 < m_middleCodeList.Count;
                                   ++index2)
                              {
                                  MiddleCode nextCode = m_middleCodeList[index2];

                                  if (nextCode[0] == resultSymbol)
                                  {
                                      nextCode[0] = newSymbol;
                                  }

                                  if (nextCode[1] == resultSymbol)
                                  {
                                      nextCode[1] = newSymbol;
                                  }

                                  if (nextCode[2] == resultSymbol)
                                  {
                                      nextCode[2] = newSymbol;
                                  }
                              }
                            }
                        }
                        else
                        {
                            thisCode.Operator = MiddleOperator.Assign; // i = 0 + j;
                            thisCode[1]       = newSymbol;             // i = j;
                            thisCode[2]       = null;
                        }

                        m_update = true;
                    }
                }
            }
        }