Пример #1
0
        public override Expression CreateExpressionTree(ResolveContext ec)
        {
            MemberAccess ma = new MemberAccess(new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);

            Arguments args = new Arguments(3);

            args.Add(new Argument(new TypeOf(type, loc)));

            if (method_group.InstanceExpression == null)
            {
                args.Add(new Argument(new NullLiteral(loc)));
            }
            else
            {
                args.Add(new Argument(method_group.InstanceExpression));
            }

            args.Add(new Argument(method_group.CreateExpressionTree(ec)));
            Expression e = new Invocation(ma, args).Resolve(ec);

            if (e == null)
            {
                return(null);
            }

            e = Convert.ExplicitConversion(ec, e, type, loc);
            if (e == null)
            {
                return(null);
            }

            return(e.CreateExpressionTree(ec));
        }
Пример #2
0
        public override Expression CreateExpressionTree(ResolveContext ec)
        {
            Arguments args = new Arguments(2);

            args.Add(new Argument(new TypeOf(type, loc)));

            if (method_group.InstanceExpression == null)
            {
                args.Add(new Argument(new NullLiteral(loc)));
            }
            else
            {
                args.Add(new Argument(method_group.InstanceExpression));
            }

            Expression ma;
            var        create_v45 = ec.Module.PredefinedMembers.MethodInfoCreateDelegate.Get();

            if (create_v45 != null)
            {
                //
                // .NET 4.5 has better API but it produces different instance than Delegate::CreateDelegate
                // and because csc uses this enhancement we have to as well to be fully compatible
                //
                var mg = MethodGroupExpr.CreatePredefined(create_v45, create_v45.DeclaringType, loc);
                mg.InstanceExpression = method_group.CreateExpressionTree(ec);
                ma = mg;
            }
            else
            {
                ma = new MemberAccess(new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);
                args.Add(new Argument(method_group.CreateExpressionTree(ec)));
            }

            Expression e = new Invocation(ma, args).Resolve(ec);

            if (e == null)
            {
                return(null);
            }

            e = Convert.ExplicitConversion(ec, e, type, loc);
            if (e == null)
            {
                return(null);
            }

            return(e.CreateExpressionTree(ec));
        }
Пример #3
0
        public override Expression CreateExpressionTree(EmitContext ec)
        {
            MemberAccess ma = new MemberAccess(new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);

            ArrayList args = new ArrayList(3);

            args.Add(new Argument(new TypeOf(new TypeExpression(type, loc), loc)));
            args.Add(new Argument(new NullLiteral(loc)));
            args.Add(new Argument(new TypeOfMethodInfo(delegate_method, loc)));
            Expression e = new Invocation(ma, args).Resolve(ec);

            if (e == null)
            {
                return(null);
            }

            e = Convert.ExplicitConversion(ec, e, type, loc);
            if (e == null)
            {
                return(null);
            }

            return(e.CreateExpressionTree(ec));
        }
Пример #4
0
 public override Expression CreateExpressionTree(ResolveContext ec)
 {
     return(removeExpr.CreateExpressionTree(ec));
 }
Пример #5
0
		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			MemberAccess ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);

			Arguments args = new Arguments (3);
			args.Add (new Argument (new TypeOf (type, loc)));

			if (method_group.InstanceExpression == null)
				args.Add (new Argument (new NullLiteral (loc)));
			else
				args.Add (new Argument (method_group.InstanceExpression));

			args.Add (new Argument (method_group.CreateExpressionTree (ec)));
			Expression e = new Invocation (ma, args).Resolve (ec);
			if (e == null)
				return null;

			e = Convert.ExplicitConversion (ec, e, type, loc);
			if (e == null)
				return null;

			return e.CreateExpressionTree (ec);
		}
Пример #6
0
        public override Expression CreateExpressionTree(ResolveContext ec)
        {
            var invoke = new Invocation(expr, arguments);

            return(invoke.CreateExpressionTree(ec));
        }
Пример #7
0
		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			Arguments args = new Arguments (2);
			args.Add (new Argument (new TypeOf (type, loc)));

			if (method_group.InstanceExpression == null)
				args.Add (new Argument (new NullLiteral (loc)));
			else
				args.Add (new Argument (method_group.InstanceExpression));

			Expression ma;
			var create_v45 = ec.Module.PredefinedMembers.MethodInfoCreateDelegate.Get ();
			if (create_v45 != null) {
				//
				// .NET 4.5 has better API but it produces different instance than Delegate::CreateDelegate
				// and because csc uses this enhancement we have to as well to be fully compatible
				//
				var mg = MethodGroupExpr.CreatePredefined (create_v45, create_v45.DeclaringType, loc);
				mg.InstanceExpression = method_group.CreateExpressionTree (ec);
				ma = mg;
			} else {
				ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);
				args.Add (new Argument (method_group.CreateExpressionTree (ec)));
			}

			Expression e = new Invocation (ma, args).Resolve (ec);
			if (e == null)
				return null;

			e = Convert.ExplicitConversion (ec, e, type, loc);
			if (e == null)
				return null;

			return e.CreateExpressionTree (ec);
		}
Пример #8
0
		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			var invoke = new Invocation (expr, arguments);
			return invoke.CreateExpressionTree (ec);
		}
Пример #9
0
		public override Expression CreateExpressionTree (EmitContext ec)
		{
			MemberAccess ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);

			ArrayList args = new ArrayList (3);
			args.Add (new Argument (new TypeOf (new TypeExpression (type, loc), loc)));
			args.Add (new Argument (new NullLiteral (loc)));
			args.Add (new Argument (new TypeOfMethodInfo (delegate_method, loc)));
			Expression e = new Invocation (ma, args).Resolve (ec);
			if (e == null)
				return null;

			e = Convert.ExplicitConversion (ec, e, type, loc);
			if (e == null)
				return null;

			return e.CreateExpressionTree (ec);
		}