Exemple #1
0
 protected MethodCallExpression CastFromBinding(Expression expr)
 {
     var me = expr.CastExpr<MethodCallExpression> (ExpressionType.Call);
     return  me != null && me.Method.IsLiftMethod () ? me : null;
 }
Exemple #2
0
 protected void FunctionBody(Expression expr)
 {
     var node = expr.CastExpr<MethodCallExpression> (ExpressionType.Call);
     CodeOut ("return {0};", Expr (RemoveAggregates (
         node != null && node.Method.IsEvaluate (_linqType) ? ParseLinqExpression (node.Arguments [0]) : expr)));
 }
Exemple #3
0
 protected void Return(Expression expr)
 {
     expr = RemoveAggregates (expr);
     var ne = expr.CastExpr<NewExpression> (ExpressionType.New);
     if (ne == null)
     {
         var mie = expr.CastExpr<MemberInitExpression> (ExpressionType.MemberInit);
         if (mie == null)
             throw new ParseException ("Unsupported expression: " + expr);
         foreach (MemberAssignment assign in mie.Bindings)
             CodeOut ("{0} = {1};", assign.Member.Name, Expr (assign.Expression));
     }
     else
     {
         for (int i = 0; i < ne.Members.Count; i++)
         {
             var prop = (PropertyInfo)ne.Members[i];
             if (!prop.Name.StartsWith ("<>"))
                 CodeOut ("{0} = {1};", prop.Name, Expr (ne.Arguments[i]));
         }
     }
 }
Exemple #4
0
 protected void ConditionalReturn(Expression expr, Action<Expression> returnAction)
 {
     var ce = expr.CastExpr<ConditionalExpression> (ExpressionType.Conditional);
     if (ce == null)
         returnAction (expr);
     else
     {
         CodeOut ("if ({0})", Expr (ce.Test));
         CodeOut ("{");
         _tabLevel++;
         returnAction (ce.IfTrue);
         _tabLevel--;
         CodeOut ("}");
         CodeOut ("else");
         CodeOut ("{");
         _tabLevel++;
         ConditionalReturn (ce.IfFalse, returnAction);
         _tabLevel--;
         CodeOut ("}");
     }
 }