コード例 #1
0
        /// <summary>
        /// Gets the source code corresponding to the expression.
        /// </summary>
        /// <param name="writer">The stream on which to write.</param>
        /// <param name="expressionContext">The context.</param>
        /// <param name="skippedIndex">Index of a destination to skip.</param>
        public override void WriteCSharp(ICSharpWriter writer, ICSharpExpressionContext expressionContext, int skippedIndex)
        {
            Debug.Assert(WriteDown);

            string LeftText;

            ICSharpExpressionContext LeftSourceExpressionContext = new CSharpExpressionContext();

            LeftExpression.WriteCSharp(writer, LeftSourceExpressionContext, -1);

            if (LeftSourceExpressionContext.ReturnValue != null)
            {
                string Result = LeftSourceExpressionContext.ReturnValue;

                if (LeftExpression.IsComplex)
                {
                    Result = $"({Result})";
                }

                LeftText = Result;
            }
            else
            {
                //TODO
                LeftText = "TODO";
            }

            string RightText;

            ICSharpExpressionContext RightSourceExpressionContext = new CSharpExpressionContext();

            RightExpression.WriteCSharp(writer, RightSourceExpressionContext, -1);

            if (RightSourceExpressionContext.ReturnValue != null)
            {
                string Result = RightSourceExpressionContext.ReturnValue;

                if (RightExpression.IsComplex)
                {
                    Result = $"({Result})";
                }

                RightText = Result;
            }
            else
            {
                //TODO
                RightText = "TODO";
            }

            string EqualitySign = null;

            switch (Source.Comparison)
            {
            case BaseNode.ComparisonType.Equal:
                EqualitySign = "==";
                break;

            case BaseNode.ComparisonType.Different:
                EqualitySign = "!=";
                break;
            }

            Debug.Assert(EqualitySign != null);

            expressionContext.SetSingleReturnValue($"{LeftText} {EqualitySign} {RightText}");
        }