Exemplo n.º 1
0
 protected override IExpression ConvertUnary(IUnaryExpression iue)
 {
     iue = (IUnaryExpression)base.ConvertUnary(iue);
     if (iue.Operator == UnaryOperator.BooleanNot)
     {
         if (iue.Expression is ILiteralExpression expr)
         {
             if (expr.Value is bool b)
             {
                 return(Builder.LiteralExpr(!b));
             }
         }
         else if (iue.Expression is IUnaryExpression iue2)
         {
             if (iue2.Operator == UnaryOperator.BooleanNot) // double negation
             {
                 return(iue2.Expression);
             }
         }
         else if (iue.Expression is IBinaryExpression ibe)
         {
             if (Recognizer.TryNegateOperator(ibe.Operator, out BinaryOperator negatedOp))
             {
                 // replace !(i==0) with (i != 0)
                 return(Builder.BinaryExpr(ibe.Left, negatedOp, ibe.Right));
             }
         }
     }
     return(iue);
 }
Exemplo n.º 2
0
 public override IExpression Visit(IUnaryExpression expr, int context)
 {
     return(new UnaryExpression
     {
         Operator = expr.Operator,
         Operand = Anonymize(expr.Operand)
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a type assertion like 'x : YourType'.
        /// </summary>
        public static IExpression TypeAssertion(ITypeNode type, IUnaryExpression expression)
        {
            var result = new TypeAssertion();

            result.Type       = type;
            result.Expression = expression;
            return(result);
        }
Exemplo n.º 4
0
        private static void WriteUnary(LanguageWriter w, IUnaryExpression exp)
        {
            bool   post = false;
            string opName;

            switch (exp.Operator)
            {
            case UnaryOperator.Negate:
                opName = "-";
                break;

            case UnaryOperator.BooleanNot:
                opName = "!";
                break;

            case UnaryOperator.BitwiseNot:
                opName = "~";
                break;

            case UnaryOperator.PreIncrement:
                opName = "++";
                break;

            case UnaryOperator.PreDecrement:
                opName = "--";
                break;

            case UnaryOperator.PostIncrement:
                opName = "++";
                post   = true;
                break;

            case UnaryOperator.PostDecrement:
                opName = "--";
                post   = true;
                break;

            default:
                throw new System.NotSupportedException(
                          "指定した種類の単項演算には対応していません: " + exp.Operator.ToString()
                          );
            }

            // 書込
            if (post)
            {
                WriteExpression(w, exp.Expression, PREC_POST > GetExpressionPrecedence(exp.Expression));
                w.Write(opName);
            }
            else
            {
                w.Write(opName);
                WriteExpression(w, exp.Expression, PREC_PRE > GetExpressionPrecedence(exp.Expression));
            }
        }
        protected override IExpression ConvertUnary(IUnaryExpression iue)
        {
            var copy = (IUnaryExpression)base.ConvertUnary(iue);

            if (NeedsIntermediate(copy.Expression))
            {
                // TODO this breaks things
                //copy.Expression = MakeIntermediateVariable(copy.Expression);
            }
            return(copy);
        }
 public void Visit(IUnaryExpression expr, SSTPrintingContext c)
 {
     if (expr.Operator == UnaryOperator.PostIncrement || expr.Operator == UnaryOperator.PostDecrement)
     {
         expr.Operand.Accept(this, c);
         c.Text(expr.Operator.ToPrettyString());
     }
     else
     {
         c.Text(expr.Operator.ToPrettyString());
         expr.Operand.Accept(this, c);
     }
 }
Exemplo n.º 7
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            IUnaryExpression expr = obj as IUnaryExpression;

            if (expr == null)
            {
                return(false);
            }

            return(Expression.Equals(expr.Expression) && Operator.Equals(expr.Operator));
        }
Exemplo n.º 8
0
        private static IExpression HandleOp(IUnaryExpression op)
        {
            var e1  = op.Value;
            var e1s = e1.Simplify();

            if (e1s != e1)
            {
                switch (op)
                {
                case Neg _:
                    return(new Neg(e1s).Simplify());
                }
            }


            return(op);
        }
Exemplo n.º 9
0
 public static IExpression Simplify(IUnaryExpression e)
 {
     if (e.Operator == UnaryOperator.BooleanNot)
     {
         var be = e.Expression as IBinaryExpression;
         if (be != null)
         {
             var be2 = InvertBoolOrRelation(be);
             if (!ReferenceEquals(be2, be))
             {
                 return(be2);
             }
         }
         var e2 = Simplify(e.Expression);
         if (!ReferenceEquals(e2, e.Expression))
         {
             return(new UnaryExpression(e2, UnaryOperator.BooleanNot));
         }
     }
     return(e);
 }
Exemplo n.º 10
0
 public ConditionBinding(IExpression condition)
 {
     lhs = condition;
     rhs = Builder.LiteralExpr(true);
     if (condition is IBinaryExpression)
     {
         IBinaryExpression ibe = (IBinaryExpression)condition;
         if ((ibe.Operator == BinaryOperator.IdentityEquality) || (ibe.Operator == BinaryOperator.ValueEquality))
         {
             lhs = ibe.Left;
             rhs = ibe.Right;
         }
     }
     else if (condition is IUnaryExpression)
     {
         IUnaryExpression iue = (IUnaryExpression)condition;
         if (iue.Operator == UnaryOperator.BooleanNot)
         {
             lhs = iue.Expression;
             rhs = Builder.LiteralExpr(false);
         }
     }
 }
Exemplo n.º 11
0
        public override void VisitUnaryExpression(IUnaryExpression value)
        {
            switch (value.Operator)
            {
            case UnaryOperator.Negate:
            case UnaryOperator.BooleanNot:
                _formatter.Write("!");
                VisitExpression(value.Expression);
                break;

            case UnaryOperator.BitwiseNot:
                _formatter.Write("-bnot ");
                VisitExpression(value.Expression);
                break;

            case UnaryOperator.PreIncrement:
                _formatter.Write("++");
                VisitExpression(value.Expression);
                break;

            case UnaryOperator.PreDecrement:
                _formatter.Write("--");
                VisitExpression(value.Expression);
                break;

            case UnaryOperator.PostIncrement:
                VisitExpression(value.Expression);
                _formatter.Write("++");
                break;

            case UnaryOperator.PostDecrement:
                VisitExpression(value.Expression);
                _formatter.Write("--");
                break;
            }
        }
        public override bool IsAvailable(JetBrains.Util.IUserDataHolder cache)
        {
            var awaitExpression = provider.GetSelectedElement<IAwaitExpression>(true, false);

            if (awaitExpression != null && awaitExpression.AwaitKeyword == provider.SelectedElement)
            {
                awaitedExpression = awaitExpression.Task;
                var typeElement = (awaitedExpression?.Type() as IDeclaredType)?.GetTypeElement();
                if (typeElement != null)
                {
                    var hasConfigureAwaitMethod = typeElement.Methods.Any(
                        method =>
                        {
                            Debug.Assert(method != null);

                            if (method.ShortName == configureAwaitMethodName && method.Parameters.Count == 1)
                            {
                                Debug.Assert(method.Parameters[0] != null);

                                return method.Parameters[0].Type.IsBool();
                            }

                            return false;
                        });

                    if (hasConfigureAwaitMethod)
                    {
                        return true;
                    }
                }
            }

            awaitedExpression = null;

            return false;
        }
Exemplo n.º 13
0
 public virtual void VisitUnaryExpression(IUnaryExpression e)
 {
     VisitExpression(e.Expression);
 }
Exemplo n.º 14
0
 public int Visit(IUnaryExpression expr, int context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 15
0
 protected abstract IExpression VisitUnary(IUnaryExpression unaryExpression);
Exemplo n.º 16
0
 public virtual void VisitUnaryExpression(IUnaryExpression value)
 {
     VisitExpression(value.Expression);
 }
Exemplo n.º 17
0
 public object Evaluate(IExpression expr)
 {
     if (expr is IObjectCreateExpression)
     {
         return(Evaluate((IObjectCreateExpression)expr));
     }
     else if (expr is ILiteralExpression)
     {
         return(((ILiteralExpression)expr).Value);
     }
     else if (expr is ICastExpression)
     {
         return(Evaluate(((ICastExpression)expr).Expression));
     }
     else if (expr is ICheckedExpression)
     {
         return(Evaluate(((ICheckedExpression)expr).Expression));
     }
     else if (expr is IBinaryExpression)
     {
         IBinaryExpression ibe   = (IBinaryExpression)expr;
         object            left  = Evaluate(ibe.Left);
         object            right = Evaluate(ibe.Right);
         Type type = left.GetType();
         return(Microsoft.ML.Probabilistic.Compiler.Reflection.Invoker.InvokeStatic(type, binaryOperatorNames[(int)ibe.Operator], left, right));
     }
     else if (expr is IUnaryExpression)
     {
         IUnaryExpression iue    = (IUnaryExpression)expr;
         object           target = Evaluate(iue.Expression);
         Type             type   = target.GetType();
         return(Microsoft.ML.Probabilistic.Compiler.Reflection.Invoker.InvokeStatic(type, unaryOperatorNames[(int)iue.Operator], target));
     }
     else if (expr is IMethodInvokeExpression)
     {
         IMethodInvokeExpression imie = (IMethodInvokeExpression)expr;
         object[] args = EvaluateAll(imie.Arguments);
         return(Invoke(imie.Method, args));
     }
     else if (expr is IArrayCreateExpression)
     {
         IArrayCreateExpression iace = (IArrayCreateExpression)expr;
         Type  t    = Builder.ToType(iace.Type);
         int[] lens = new int[iace.Dimensions.Count];
         for (int i = 0; i < lens.Length; i++)
         {
             lens[i] = (int)Evaluate(iace.Dimensions[i]);
         }
         // TODO: evaluate initializer
         if (iace.Initializer != null)
         {
             throw new NotImplementedException("IArrayCreateExpression has an initializer block");
         }
         return(Array.CreateInstance(t, lens));
     }
     else if (expr is IFieldReferenceExpression)
     {
         IFieldReferenceExpression ifre = (IFieldReferenceExpression)expr;
         if (ifre.Target is ITypeReferenceExpression)
         {
             ITypeReferenceExpression itre = (ITypeReferenceExpression)ifre.Target;
             Type      type = Builder.ToType(itre.Type);
             FieldInfo info = type.GetField(ifre.Field.Name);
             return(info.GetValue(null));
         }
         else
         {
             object    target = Evaluate(ifre.Target);
             FieldInfo info   = target.GetType().GetField(ifre.Field.Name);
             return(info.GetValue(target));
         }
     }
     else
     {
         throw new InferCompilerException("Could not evaluate: " + expr);
     }
 }
        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            Debug.Assert(awaitedExpression != null);

            try
            {
                using (WriteLockCookie.Create())
                {
                    var factory = CSharpElementFactory.GetInstance(provider.PsiModule);

                    ModificationUtil.ReplaceChild(
                        awaitedExpression,
                        factory.CreateExpression($"$0.{configureAwaitMethodName}(false)", awaitedExpression));
                }

                return _ => { };
            }
            finally
            {
                awaitedExpression = null;
            }
        }
Exemplo n.º 19
0
        protected override IExpression VisitUnary(IUnaryExpression unaryExpression)
        {
            if ((object)unaryExpression == null)
                throw new ArgumentNullException("unaryExpression");

            switch (unaryExpression.UnaryOperator)
            {
                case UnaryOperator.Not:
                    this.Strings.Append(" NOT ");
                    this.Visit(unaryExpression.TheExpression);
                    break;
                case UnaryOperator.IsNull:
                    this.Visit(unaryExpression.TheExpression);
                    this.Strings.Append(" IS NULL ");
                    break;
                case UnaryOperator.IsNotNull:
                    this.Visit(unaryExpression.TheExpression);
                    this.Strings.Append(" IS NOT NULL ");
                    break;
                case UnaryOperator.Neg:
                    this.Strings.Append(" - ");
                    this.Visit(unaryExpression.TheExpression);
                    break;
                case UnaryOperator.Pos:
                    this.Strings.Append(" + ");
                    this.Visit(unaryExpression.TheExpression);
                    break;
                case UnaryOperator.Incr:
                    this.Strings.Append(" (");
                    this.Visit(unaryExpression.TheExpression);
                    this.Strings.Append(" + 1) ");
                    break;
                case UnaryOperator.Decr:
                    this.Strings.Append(" (");
                    this.Visit(unaryExpression.TheExpression);
                    this.Strings.Append(" - 1) ");
                    break;
                case UnaryOperator.BComp:
                    this.Strings.Append(" ~ ");
                    this.Visit(unaryExpression.TheExpression);
                    break;
                default:
                    throw new NotSupportedException(string.Format("The unary operator '{0}' is not supported.", unaryExpression.UnaryOperator));
            }

            return unaryExpression;
        }
Exemplo n.º 20
0
 public virtual void VisitUnaryExpression(IUnaryExpression value)
 {
     this.VisitExpression(value.Expression);
 }
            private void WriteUnaryExpression(IUnaryExpression expression, IFormatter formatter)
            {
                switch (expression.Operator)
                {
                    case UnaryOperator.BitwiseNot:
                        formatter.WriteKeyword("!");
                        this.WriteExpression(expression.Expression, formatter);
                        break;

                    case UnaryOperator.BooleanNot:
                        formatter.WriteKeyword("!");
                        this.WriteExpression(expression.Expression, formatter);
                        break;

                    case UnaryOperator.Negate:
                        formatter.Write("-");
                        this.WriteExpression(expression.Expression, formatter);
                        break;

                    case UnaryOperator.PreIncrement:
                        formatter.Write("++");
                        this.WriteExpression(expression.Expression, formatter);
                        break;

                    case UnaryOperator.PreDecrement:
                        formatter.Write("--");
                        this.WriteExpression(expression.Expression, formatter);
                        break;

                    case UnaryOperator.PostIncrement:
                        this.WriteExpression(expression.Expression, formatter);
                        formatter.Write("++");
                        break;

                    case UnaryOperator.PostDecrement:
                        this.WriteExpression(expression.Expression, formatter);
                        formatter.Write("--");
                        break;

                    default:
                        throw new NotSupportedException(expression.Operator.ToString());
                }
            }
Exemplo n.º 22
0
        protected override IExpression VisitUnary(IUnaryExpression unaryExpression)
        {
            DescriptionAttribute descriptionAttribute;
            FieldInfo fieldInfo;

            if ((object)unaryExpression == null)
                throw new ArgumentNullException("unaryExpression");

            fieldInfo = typeof(UnaryOperator).GetField(unaryExpression.UnaryOperator.ToString());

            if ((object)fieldInfo == null)
                throw new NotSupportedException(string.Format("The unary operator '{0}' is not supported.", unaryExpression.UnaryOperator));

            descriptionAttribute = Reflexion.GetOneAttribute<DescriptionAttribute>(fieldInfo);

            if ((object)descriptionAttribute == null)
                throw new NotSupportedException(string.Format("The unary operator '{0}' is not described.", unaryExpression.UnaryOperator));

            if (unaryExpression.UnaryOperator == UnaryOperator.Not)
                this.Visit(unaryExpression.TheExpression);

            this.Strings.Append(descriptionAttribute.Description);

            if (unaryExpression.UnaryOperator != UnaryOperator.Not)
                this.Visit(unaryExpression.TheExpression);

            return unaryExpression;
        }
Exemplo n.º 23
0
 public virtual void Visit(IUnaryExpression expr, TContext context)
 {
     expr.Operand.Accept(this, context);
 }
Exemplo n.º 24
0
            //===========================================================
            //		Expression 分岐
            //===========================================================
            public virtual void WriteExpression(IExpression expression)
            {
                if (expression == null)
                {
                    return;
                }

                mwg.Reflector.CppCli.ExpressionWriter.WriteExpression(this, expression, false);

#if FALSE
#pragma warning disable 612

                IMemberInitializerExpression expression3 = expression as IMemberInitializerExpression;
                if (expression3 != null)
                {
                    this.WriteMemberInitializerExpression(expression3);
                    return;
                }

                IAddressOutExpression expression27 = expression as IAddressOutExpression;
                if (expression27 != null)
                {
                    this.WriteAddressOutExpression(expression27);
                    return;
                }

                IAddressReferenceExpression expression26 = expression as IAddressReferenceExpression;
                if (expression26 != null)
                {
                    this.WriteAddressReferenceExpression(expression26);
                    return;
                }

                IDelegateCreateExpression iDelegateCreateExpression = expression as IDelegateCreateExpression;
                if (iDelegateCreateExpression != null)
                {
                    this.WriteDelegateCreateExpression(iDelegateCreateExpression);
                    return;
                }

                IMethodInvokeExpression iMethodInvokeExpression = expression as IMethodInvokeExpression;
                if (iMethodInvokeExpression != null)
                {
                    this.WriteMethodInvokeExpression(iMethodInvokeExpression);
                    return;
                }

                IVariableDeclarationExpression expression15 = expression as IVariableDeclarationExpression;
                if (expression15 != null)
                {
                    this.WriteVariableDeclaration(expression15.Variable);
                    return;
                }

                ITypeOfExpression iTypeOfExpression = expression as ITypeOfExpression;
                if (iTypeOfExpression != null)
                {
                    this.WriteTypeOfExpression(iTypeOfExpression);
                    return;
                }

                ISnippetExpression iSnippetExpression = expression as ISnippetExpression;
                if (iSnippetExpression != null)
                {
                    this.WriteSnippetExpression(iSnippetExpression);
                    return;
                }

                IUnaryExpression iUnaryExpression = expression as IUnaryExpression;
                if (iUnaryExpression != null)
                {
                    this.WriteUnaryExpression(iUnaryExpression);
                    return;
                }

                IObjectCreateExpression iObjectCreateExpression = expression as IObjectCreateExpression;
                if (iObjectCreateExpression != null)
                {
                    this.WriteObjectCreateExpression(iObjectCreateExpression);
                    return;
                }

                IVariableReferenceExpression iVariableReferenceExpression = expression as IVariableReferenceExpression;
                if (iVariableReferenceExpression != null)
                {
                    this.WriteVariableReferenceExpression(iVariableReferenceExpression);
                    return;
                }

                IThisReferenceExpression expression12 = expression as IThisReferenceExpression;
                if (expression12 != null)
                {
                    this.WriteThisReferenceExpression(expression12);
                    return;
                }

                ITryCastExpression iTryCastExpression = expression as ITryCastExpression;
                if (iTryCastExpression != null)
                {
                    this.WriteTryCastExpression(iTryCastExpression);
                    return;
                }

                IConditionExpression expression9 = expression as IConditionExpression;
                if (expression9 != null)
                {
                    this.WriteConditionExpression(expression9);
                    return;
                }

                IFieldReferenceExpression iFieldReferenceExpression = expression as IFieldReferenceExpression;
                if (iFieldReferenceExpression != null)
                {
                    this.WriteFieldReferenceExpression(iFieldReferenceExpression);
                    return;
                }

                IPropertyIndexerExpression iPropertyIndexerExpression = expression as IPropertyIndexerExpression;
                if (iPropertyIndexerExpression != null)
                {
                    this.WritePropertyIndexerExpression(iPropertyIndexerExpression);
                    return;
                }

                ITypeReferenceExpression iTypeReferenceExpression = expression as ITypeReferenceExpression;
                if (iTypeReferenceExpression != null)
                {
                    this.WriteTypeReferenceExpression(iTypeReferenceExpression);
                    return;
                }

                IMethodReferenceExpression iMethodReferenceExpression = expression as IMethodReferenceExpression;
                if (iMethodReferenceExpression != null)
                {
                    this.WriteMethodReferenceExpression(iMethodReferenceExpression);
                    return;
                }

                IPropertyReferenceExpression iPropertyReferenceExpression = expression as IPropertyReferenceExpression;
                if (iPropertyReferenceExpression != null)
                {
                    this.WritePropertyReferenceExpression(iPropertyReferenceExpression);
                    return;
                }

                ICastExpression expression5 = expression as ICastExpression;
                if (expression5 != null)
                {
                    this.WriteCastExpression(expression5);
                    return;
                }

                ICanCastExpression iCanCastExpression = expression as ICanCastExpression;
                if (iCanCastExpression != null)
                {
                    this.WriteCanCastExpression(iCanCastExpression);
                    return;
                }

                ICastExpression iCastExpression = expression as ICastExpression;
                if (iCastExpression != null)
                {
                    this.WriteCastExpression(iCastExpression);
                    return;
                }

                ILiteralExpression literalExpression = expression as ILiteralExpression;
                if (literalExpression != null)
                {
                    this.WriteLiteralExpression(literalExpression);
                    return;
                }

                IBinaryExpression iBinaryExpression = expression as IBinaryExpression;
                if (iBinaryExpression != null)
                {
                    mwg.Reflector.CppCli.ExpressionWriter.WriteExpression(this, expression, true);
                    //this.WriteBinaryExpression(iBinaryExpression);
                    return;
                }

                IArrayIndexerExpression expression30 = expression as IArrayIndexerExpression;
                if (expression30 != null)
                {
                    this.WriteArrayIndexerExpression(expression30);
                    return;
                }

                IAddressDereferenceExpression expression29 = expression as IAddressDereferenceExpression;
                if (expression29 != null)
                {
                    this.WriteAddressDereferenceExpression(expression29);
                    return;
                }

                IAddressOfExpression expression28 = expression as IAddressOfExpression;
                if (expression28 != null)
                {
                    this.WriteAddressOfExpression(expression28);
                    return;
                }

                IArgumentListExpression expression25 = expression as IArgumentListExpression;
                if (expression25 != null)
                {
                    this.WriteArgumentListExpression(expression25);
                    return;
                }

                IBaseReferenceExpression iBaseReferenceExpression = expression as IBaseReferenceExpression;
                if (iBaseReferenceExpression != null)
                {
                    this.WriteBaseReferenceExpression(iBaseReferenceExpression);
                    return;
                }

                IArgumentReferenceExpression expression13 = expression as IArgumentReferenceExpression;
                if (expression13 != null)
                {
                    this.WriteArgumentReferenceExpression(expression13);
                    return;
                }

                IArrayCreateExpression expression10 = expression as IArrayCreateExpression;
                if (expression10 != null)
                {
                    this.WriteArrayCreateExpression(expression10);
                    return;
                }

                IAssignExpression iAssignExpression = expression as IAssignExpression;
                if (iAssignExpression != null)
                {
                    this.WriteAssignExpression(iAssignExpression);
                    return;
                }

                IBlockExpression expression2 = expression as IBlockExpression;
                if (expression2 != null)
                {
                    this.WriteBlockExpression(expression2);
                    return;
                }
#pragma warning restore 612

                this.Write(expression.ToString());
#endif
            }
Exemplo n.º 25
0
        /// <summary>
        /// Only converts the contained statements in a for loop, leaving the initializer,
        /// condition and increment statements unchanged.
        /// </summary>
        /// <remarks>This method includes a number of checks to ensure the loop is valid e.g. that the initializer, condition and increment
        /// are all of the appropriate form.</remarks>
        protected override IStatement ConvertFor(IForStatement ifs)
        {
            IForStatement fs = Builder.ForStmt();

            context.SetPrimaryOutput(fs);
            // Check condition is valid
            fs.Condition = ifs.Condition;
            if ((!(fs.Condition is IBinaryExpression)) || (((IBinaryExpression)fs.Condition).Operator != BinaryOperator.LessThan))
            {
                Error("For statement condition must be of the form 'indexVar<loopSize', was " + fs.Condition);
            }

            // Check increment is valid
            fs.Increment = ifs.Increment;
            IExpressionStatement ies = fs.Increment as IExpressionStatement;
            bool validIncrement      = false;

            if (ies != null)
            {
                if (ies.Expression is IAssignExpression)
                {
                    IAssignExpression iae = (IAssignExpression)ies.Expression;
                    IBinaryExpression ibe = RemoveCast(iae.Expression) as IBinaryExpression;
                    validIncrement = (ibe != null) && (ibe.Operator == BinaryOperator.Add);
                }
                else if (ies.Expression is IUnaryExpression)
                {
                    IUnaryExpression iue = (IUnaryExpression)ies.Expression;
                    validIncrement = (iue.Operator == UnaryOperator.PostIncrement);
                }
            }
            if (!validIncrement)
            {
                Error("For statement increment must be of the form 'varname++' or 'varname=varname+1', was " + fs.Increment + ".");
            }


            // Check initializer is valid
            fs.Initializer = ifs.Initializer;
            ies            = fs.Initializer as IExpressionStatement;
            if (ies == null)
            {
                Error("For statement initializer must be an expression statement, was " + fs.Initializer.GetType());
            }
            else
            {
                if (!(ies.Expression is IAssignExpression))
                {
                    Error("For statement initializer must be an assignment, was " + fs.Initializer.GetType().Name);
                }
                else
                {
                    IAssignExpression iae2 = (IAssignExpression)ies.Expression;
                    if (!(iae2.Target is IVariableDeclarationExpression))
                    {
                        Error("For statement initializer must be a variable declaration, was " + iae2.Target.GetType().Name);
                    }
                    if (!Recognizer.IsLiteral(iae2.Expression, 0))
                    {
                        Error("Loop index must start at 0, was " + iae2.Expression);
                    }
                }
            }

            fs.Body = ConvertBlock(ifs.Body);
            return(fs);
        }
Exemplo n.º 26
0
 public virtual IExpression TransformUnaryExpression(IUnaryExpression value)
 {
     value.Expression = this.TransformExpression(value.Expression);
     return value;
 }