상속: Mono.CSharp.ShimExpression
예제 #1
0
        public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);
            var t_args = typeArguments == null ?
                         null :
                         new Compiler.TypeArguments(typeArguments.Select(l => new Compiler.TypeExpression(ctx.ImportType(l), Compiler.Location.Null)).ToArray());

            var expr = ctx.CreateCompilerExpression(argumentInfo[0], target);

            //
            // Simple name invocation is actually member access invocation
            // to capture original this argument. This  brings problem when
            // simple name is resolved as a static invocation and member access
            // has to be reduced back to simple name without reporting an error
            //
            if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0)
            {
                var value = expr as Compiler.RuntimeValueExpression;
                if (value != null)
                {
                    value.IsSuggestionOnly = true;
                }
            }

            expr = new Compiler.MemberAccess(expr, Name, t_args, Compiler.Location.Null);
            expr = new Invocation(expr, c_args, this);

            if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.DynamicResultCast(ctx.ImportType(ReturnType), expr);
            }

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
            {
                binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;
            }

            return(binder.Bind(ctx, callingContext));
        }
예제 #2
0
		public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
			expr = new Compiler.Invocation (expr, c_args);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			return binder.Bind (callingContext, target);
		}
예제 #3
0
        public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var expr   = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);

            expr = new Compiler.Invocation(expr, c_args);

            if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.DynamicResultCast(ctx.ImportType(ReturnType), expr);
            }

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            return(binder.Bind(ctx, callingContext));
        }
예제 #4
0
		public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var c_args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), args);
			var t_args = typeArguments == null ?
				null :
				new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (ctx.ImportType (l), Compiler.Location.Null)).ToArray ());

			var expr = ctx.CreateCompilerExpression (argumentInfo[0], target);

			//
			// Simple name invocation is actually member access invocation
 			// to capture original this argument. This  brings problem when
			// simple name is resolved as a static invocation and member access
			// has to be reduced back to simple name without reporting an error
			//
			if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
				var value = expr as Compiler.RuntimeValueExpression;
				if (value != null)
					value.IsSuggestionOnly = true;
			}

			expr = new Compiler.MemberAccess (expr, Name, t_args, Compiler.Location.Null);
			expr = new Invocation (expr, c_args, this);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (ctx.ImportType (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
				binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;

			return binder.Bind (ctx, callingContext);
		}