Esempio n. 1
0
 internal static System.Linq.Expressions.Expression TransformSimpleOperation(Runtime.TjsContext context, System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right, BinaryOperator binary)
 {
     if (binary == BinaryOperator.Assign)
     {
         return(right);
     }
     else if (binary == BinaryOperator.AndAlso || binary == BinaryOperator.AndAlsoAssign)
     {
         var v = System.Linq.Expressions.Expression.Variable(typeof(object));
         return(System.Linq.Expressions.Expression.Block(new[] { v },
                                                         System.Linq.Expressions.Expression.Assign(v, left),
                                                         System.Linq.Expressions.Expression.Condition(Binders.Convert(context, v, typeof(bool)), right, v)
                                                         ));
     }
     else if (binary == BinaryOperator.OrElse || binary == BinaryOperator.OrElseAssign)
     {
         var v = System.Linq.Expressions.Expression.Variable(typeof(object));
         return(System.Linq.Expressions.Expression.Block(new[] { v },
                                                         System.Linq.Expressions.Expression.Assign(v, left),
                                                         System.Linq.Expressions.Expression.Condition(Binders.Convert(context, v, typeof(bool)), v, right)
                                                         ));
     }
     else
     {
         return(DoBinaryOperation(context, left, right, binary));
     }
 }