internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeObjectCreateExpression childExpr = (CodeObjectCreateExpression)expression;
            bool flag = RuleDecompiler.MustParenthesize(childExpr, parentExpression);

            if (flag)
            {
                stringBuilder.Append("(");
            }
            stringBuilder.Append("new ");
            RuleDecompiler.DecompileType(stringBuilder, childExpr.CreateType);
            stringBuilder.Append('(');
            for (int i = 0; i < childExpr.Parameters.Count; i++)
            {
                CodeExpression expression3 = childExpr.Parameters[i];
                if (expression3 == null)
                {
                    RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullConstructorTypeParameter, new object[] { i.ToString(CultureInfo.CurrentCulture), childExpr.CreateType }));
                    exception.Data["ErrorObject"] = childExpr;
                    throw exception;
                }
                if (i > 0)
                {
                    stringBuilder.Append(", ");
                }
                RuleExpressionWalker.Decompile(stringBuilder, expression3, null);
            }
            stringBuilder.Append(')');
            if (flag)
            {
                stringBuilder.Append(")");
            }
        }
Exemple #2
0
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeCastExpression childExpr   = (CodeCastExpression)expression;
            CodeExpression     expression3 = childExpr.Expression;

            if (expression3 == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullCastExpr);
                exception.Data["ErrorObject"] = childExpr;
                throw exception;
            }
            if (childExpr.TargetType == null)
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(Messages.NullCastType);
                exception2.Data["ErrorObject"] = childExpr;
                throw exception2;
            }
            bool flag = RuleDecompiler.MustParenthesize(childExpr, parentExpression);

            if (flag)
            {
                stringBuilder.Append("(");
            }
            stringBuilder.Append("(");
            RuleDecompiler.DecompileType(stringBuilder, childExpr.TargetType);
            stringBuilder.Append(")");
            RuleExpressionWalker.Decompile(stringBuilder, expression3, childExpr);
            if (flag)
            {
                stringBuilder.Append(")");
            }
        }
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeArrayIndexerExpression expression2  = (CodeArrayIndexerExpression)expression;
            CodeExpression             targetObject = expression2.TargetObject;

            if (targetObject == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullIndexerTarget, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            if ((expression2.Indices == null) || (expression2.Indices.Count == 0))
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.MissingIndexExpressions, new object[0]));
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            RuleExpressionWalker.Decompile(stringBuilder, targetObject, expression2);
            stringBuilder.Append('[');
            RuleExpressionWalker.Decompile(stringBuilder, expression2.Indices[0], null);
            for (int i = 1; i < expression2.Indices.Count; i++)
            {
                stringBuilder.Append(", ");
                RuleExpressionWalker.Decompile(stringBuilder, expression2.Indices[i], null);
            }
            stringBuilder.Append(']');
        }
 public override string ToString()
 {
     if (this._expression != null)
     {
         StringBuilder stringBuilder = new StringBuilder();
         RuleExpressionWalker.Decompile(stringBuilder, this._expression, null);
         return(stringBuilder.ToString());
     }
     return("");
 }
 internal override void Decompile(StringBuilder decompilation)
 {
     if (this.exprStatement.Expression == null)
     {
         RuleEvaluationException exception = new RuleEvaluationException(Messages.InvokeStatementNull);
         exception.Data["ErrorObject"] = this.exprStatement;
         throw exception;
     }
     RuleExpressionWalker.Decompile(decompilation, this.exprStatement.Expression, null);
 }
Exemple #6
0
 public override string ToString()
 {
     if (_expression != null)
     {
         StringBuilder decompilation = new StringBuilder();
         RuleExpressionWalker.Decompile(decompilation, _expression, null);
         return(decompilation.ToString());
     }
     else
     {
         return("");
     }
 }
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeFieldReferenceExpression expression2 = (CodeFieldReferenceExpression)expression;
            CodeExpression targetObject = expression2.TargetObject;

            if (targetObject == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullFieldTarget, new object[] { expression2.FieldName }));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            RuleExpressionWalker.Decompile(stringBuilder, targetObject, expression2);
            stringBuilder.Append('.');
            stringBuilder.Append(expression2.FieldName);
        }
Exemple #8
0
 internal override void Decompile(StringBuilder decompilation)
 {
     if (this.assignStatement.Right == null)
     {
         RuleEvaluationException exception = new RuleEvaluationException(Messages.AssignRightNull);
         exception.Data["ErrorObject"] = this.assignStatement;
         throw exception;
     }
     if (this.assignStatement.Left == null)
     {
         RuleEvaluationException exception2 = new RuleEvaluationException(Messages.AssignLeftNull);
         exception2.Data["ErrorObject"] = this.assignStatement;
         throw exception2;
     }
     RuleExpressionWalker.Decompile(decompilation, this.assignStatement.Left, null);
     decompilation.Append(" = ");
     RuleExpressionWalker.Decompile(decompilation, this.assignStatement.Right, null);
 }
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeDirectionExpression expression2 = (CodeDirectionExpression)expression;
            string str = null;

            if (expression2.Direction == FieldDirection.Out)
            {
                str = "out ";
            }
            else if (expression2.Direction == FieldDirection.Ref)
            {
                str = "ref ";
            }
            if (str != null)
            {
                stringBuilder.Append(str);
            }
            RuleExpressionWalker.Decompile(stringBuilder, expression2.Expression, expression2);
        }
Exemple #10
0
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            CodeMethodInvokeExpression expression2 = (CodeMethodInvokeExpression)expression;

            if ((expression2.Method == null) || (expression2.Method.TargetObject == null))
            {
                RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullMethodTarget, new object[] { expression2.Method.MethodName }));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            CodeExpression targetObject = expression2.Method.TargetObject;

            RuleExpressionWalker.Decompile(stringBuilder, targetObject, expression2);
            stringBuilder.Append('.');
            stringBuilder.Append(expression2.Method.MethodName);
            stringBuilder.Append('(');
            if (expression2.Parameters != null)
            {
                for (int i = 0; i < expression2.Parameters.Count; i++)
                {
                    CodeExpression expression4 = expression2.Parameters[i];
                    if (expression4 == null)
                    {
                        RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullMethodTypeParameter, new object[] { i.ToString(CultureInfo.CurrentCulture), expression2.Method.MethodName }));
                        exception2.Data["ErrorObject"] = expression2;
                        throw exception2;
                    }
                    if (i > 0)
                    {
                        stringBuilder.Append(", ");
                    }
                    RuleExpressionWalker.Decompile(stringBuilder, expression4, null);
                }
            }
            stringBuilder.Append(')');
        }
        internal override void Decompile(CodeExpression expression, StringBuilder stringBuilder, CodeExpression parentExpression)
        {
            string str3;
            bool   flag = false;
            CodeBinaryOperatorExpression childExpr = (CodeBinaryOperatorExpression)expression;

            if (childExpr.Left == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullBinaryOpLHS, new object[] { childExpr.Operator.ToString() }));
                exception.Data["ErrorObject"] = childExpr;
                throw exception;
            }
            if (childExpr.Right == null)
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.NullBinaryOpRHS, new object[] { childExpr.Operator.ToString() }));
                exception2.Data["ErrorObject"] = childExpr;
                throw exception2;
            }
            switch (childExpr.Operator)
            {
            case CodeBinaryOperatorType.Add:
                str3 = " + ";
                break;

            case CodeBinaryOperatorType.Subtract:
                str3 = " - ";
                break;

            case CodeBinaryOperatorType.Multiply:
                str3 = " * ";
                break;

            case CodeBinaryOperatorType.Divide:
                str3 = " / ";
                break;

            case CodeBinaryOperatorType.Modulus:
                str3 = " % ";
                break;

            case CodeBinaryOperatorType.IdentityInequality:
                str3 = " != ";
                break;

            case CodeBinaryOperatorType.IdentityEquality:
            case CodeBinaryOperatorType.ValueEquality:
                str3 = " == ";
                break;

            case CodeBinaryOperatorType.BitwiseOr:
                str3 = " | ";
                break;

            case CodeBinaryOperatorType.BitwiseAnd:
                str3 = " & ";
                break;

            case CodeBinaryOperatorType.BooleanOr:
                str3 = " || ";
                break;

            case CodeBinaryOperatorType.BooleanAnd:
                str3 = " && ";
                break;

            case CodeBinaryOperatorType.LessThan:
                str3 = " < ";
                break;

            case CodeBinaryOperatorType.LessThanOrEqual:
                str3 = " <= ";
                break;

            case CodeBinaryOperatorType.GreaterThan:
                str3 = " > ";
                break;

            case CodeBinaryOperatorType.GreaterThanOrEqual:
                str3 = " >= ";
                break;

            default:
            {
                NotSupportedException exception3 = new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Messages.BinaryOpNotSupported, new object[] { childExpr.Operator.ToString() }));
                exception3.Data["ErrorObject"] = childExpr;
                throw exception3;
            }
            }
            CodeExpression left  = childExpr.Left;
            CodeExpression right = childExpr.Right;

            if (childExpr.Operator == CodeBinaryOperatorType.ValueEquality)
            {
                CodePrimitiveExpression expression5 = right as CodePrimitiveExpression;
                if (expression5 != null)
                {
                    object obj2 = expression5.Value;
                    if (((obj2 != null) && (obj2.GetType() == typeof(bool))) && !((bool)obj2))
                    {
                        CodeBinaryOperatorExpression expression6 = left as CodeBinaryOperatorExpression;
                        if ((expression6 == null) || (expression6.Operator != CodeBinaryOperatorType.ValueEquality))
                        {
                            flag = RuleDecompiler.MustParenthesize(left, parentExpression);
                            if (flag)
                            {
                                stringBuilder.Append("(");
                            }
                            stringBuilder.Append("!");
                            RuleExpressionWalker.Decompile(stringBuilder, left, new CodeCastExpression());
                            if (flag)
                            {
                                stringBuilder.Append(")");
                            }
                            return;
                        }
                        str3  = " != ";
                        left  = expression6.Left;
                        right = expression6.Right;
                    }
                }
            }
            else if (childExpr.Operator == CodeBinaryOperatorType.Subtract)
            {
                CodePrimitiveExpression expression7 = left as CodePrimitiveExpression;
                if ((expression7 != null) && (expression7.Value != null))
                {
                    object   obj3     = expression7.Value;
                    TypeCode typeCode = Type.GetTypeCode(obj3.GetType());
                    bool     flag2    = false;
                    switch (typeCode)
                    {
                    case TypeCode.Int32:
                        flag2 = ((int)obj3) == 0;
                        break;

                    case TypeCode.Int64:
                        flag2 = ((long)obj3) == 0L;
                        break;

                    case TypeCode.Single:
                        flag2 = ((float)obj3) == 0f;
                        break;

                    case TypeCode.Double:
                        flag2 = ((double)obj3) == 0.0;
                        break;

                    case TypeCode.Decimal:
                        flag2 = ((decimal)obj3) == 0M;
                        break;
                    }
                    if (flag2)
                    {
                        flag = RuleDecompiler.MustParenthesize(right, parentExpression);
                        if (flag)
                        {
                            stringBuilder.Append("(");
                        }
                        stringBuilder.Append("-");
                        RuleExpressionWalker.Decompile(stringBuilder, right, new CodeCastExpression());
                        if (flag)
                        {
                            stringBuilder.Append(")");
                        }
                        return;
                    }
                }
            }
            flag = RuleDecompiler.MustParenthesize(childExpr, parentExpression);
            if (flag)
            {
                stringBuilder.Append("(");
            }
            RuleExpressionWalker.Decompile(stringBuilder, left, childExpr);
            stringBuilder.Append(str3);
            RuleExpressionWalker.Decompile(stringBuilder, right, childExpr);
            if (flag)
            {
                stringBuilder.Append(")");
            }
        }