コード例 #1
0
ファイル: delegate.cs プロジェクト: yehia2amer/Alter-Native
        public static Arguments CreateDelegateMethodArguments(AParametersCollection pd, TypeSpec[] types, Location loc)
        {
            Arguments delegate_arguments = new Arguments(pd.Count);

            for (int i = 0; i < pd.Count; ++i)
            {
                Argument.AType atype_modifier;
                switch (pd.FixedParameters [i].ModFlags)
                {
                case Parameter.Modifier.REF:
                    atype_modifier = Argument.AType.Ref;
                    break;

                case Parameter.Modifier.OUT:
                    atype_modifier = Argument.AType.Out;
                    break;

                default:
                    atype_modifier = 0;
                    break;
                }

                delegate_arguments.Add(new Argument(new TypeExpression(types [i], loc), atype_modifier));
            }

            return(delegate_arguments);
        }
コード例 #2
0
 ParametersCollection(AParametersCollection param, Type[] types)
 {
     this.parameters = param.FixedParameters;
     this.types      = types;
     has_arglist     = param.HasArglist;
     has_params      = param.HasParams;
 }
コード例 #3
0
ファイル: delegate.cs プロジェクト: EnergonV/mono
        public static Arguments CreateDelegateMethodArguments(ResolveContext rc, AParametersCollection pd, TypeSpec[] types, Location loc)
        {
            Arguments delegate_arguments = new Arguments(pd.Count);

            for (int i = 0; i < pd.Count; ++i)
            {
                Argument.AType atype_modifier;
                switch (pd.FixedParameters [i].ModFlags & Parameter.Modifier.RefOutMask)
                {
                case Parameter.Modifier.REF:
                    atype_modifier = Argument.AType.Ref;
                    break;

                case Parameter.Modifier.OUT:
                    atype_modifier = Argument.AType.Out;
                    break;

                default:
                    atype_modifier = 0;
                    break;
                }

                var ptype = types[i];
                if (ptype.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
                {
                    ptype = rc.BuiltinTypes.Object;
                }

                delegate_arguments.Add(new Argument(new TypeExpression(ptype, loc), atype_modifier));
            }

            return(delegate_arguments);
        }
コード例 #4
0
        static string GetParametersFormatted(MemberSpec mi)
        {
            var pm = mi as IParametersMember;

            if (pm == null || pm.Parameters.IsEmpty)
            {
                return(string.Empty);
            }

            AParametersCollection parameters = pm.Parameters;

/*
 *                      if (parameters == null || parameters.Count == 0)
 *                              return String.Empty;
 */
            StringBuilder sb = new StringBuilder();

            sb.Append('(');
            for (int i = 0; i < parameters.Count; i++)
            {
//				if (is_setter && i + 1 == parameters.Count)
//					break; // skip "value".
                if (i > 0)
                {
                    sb.Append(',');
                }
                TypeSpec t = parameters.Types [i];
                sb.Append(GetSignatureForDoc(t));
            }
            sb.Append(')');
            return(sb.ToString());
        }
コード例 #5
0
ファイル: delegate.cs プロジェクト: OpenFlex/playscript-mono
		public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
		{
			Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
			if (type_ns == null) {
				return null;
			}
			if (returnType == rc.BuiltinTypes.Void) {
				var actArgs = parameters.Types;
				var actionSpec = type_ns.LookupType (rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (actionSpec == null) {
					return null;
				}
				if (actArgs.Length == 0)
					return actionSpec;
				else
					return actionSpec.MakeGenericType(rc, actArgs);
			} else {
				TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
				parameters.Types.CopyTo(funcArgs, 0);
				funcArgs[parameters.Types.Length] = returnType;
				var funcSpec = type_ns.LookupType (rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (funcSpec == null)
					return null;
				return funcSpec.MakeGenericType(rc, funcArgs);
			}
		}
コード例 #6
0
            public static bool IsEqual(AParametersCollection a, AParametersCollection b)
            {
                if (a == b)
                {
                    return(true);
                }

                if (a.Count != b.Count)
                {
                    return(false);
                }

                for (int i = 0; i < a.Count; ++i)
                {
                    if (!IsEqual(a.Types[i], b.Types[i]))
                    {
                        return(false);
                    }

                    const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT;
                    if ((a.FixedParameters[i].ModFlags & ref_out) != (b.FixedParameters[i].ModFlags & ref_out))
                    {
                        return(false);
                    }
                }

                return(true);
            }
コード例 #7
0
        public static TypeSpec CreateDelegateType(ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
        {
            Namespace type_ns;
            string    paramsSuffix = "";

            TypeSpec[] paramTypes = parameters.Types;
            type_ns = rc.Module.GlobalRootNamespace.GetNamespace("System", true);

            // Do we have a PARAMS argument as the final argument?  (Only supported in PlayScript)
            if (rc.FileType == SourceFileType.PlayScript && parameters.FixedParameters.Length > 0 &&
                (parameters.FixedParameters [parameters.FixedParameters.Length - 1].ModFlags & Parameter.Modifier.PARAMS) != 0)
            {
                paramsSuffix = "P";
                TypeSpec[] newTypes = new TypeSpec[paramTypes.Length - 1];
                Array.Copy(paramTypes, 0, newTypes, 0, newTypes.Length);
                paramTypes = newTypes;
                type_ns    = rc.Module.GlobalRootNamespace.GetNamespace("PlayScript", true);
            }

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

            if (returnType == rc.BuiltinTypes.Void)
            {
                var actArgs    = paramTypes;
                var actionType = type_ns.LookupType(rc.Module, "Action" + paramsSuffix, actArgs.Length, LookupMode.Normal, loc);
                if (actionType == null)
                {
                    return(rc.BuiltinTypes.Delegate);
                }
                var actionSpec = actionType.ResolveAsType(rc);
                if (actionSpec == null)
                {
                    return(null);
                }
                if (actArgs.Length == 0)
                {
                    return(actionSpec);
                }
                else
                {
                    return(actionSpec.MakeGenericType(rc, actArgs));
                }
            }
            else
            {
                TypeSpec[] funcArgs = new TypeSpec[paramTypes.Length + 1];
                paramTypes.CopyTo(funcArgs, 0);
                funcArgs[paramTypes.Length] = returnType;
                var funcSpec = type_ns.LookupType(rc.Module, "Func" + paramsSuffix, funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
                if (funcSpec == null)
                {
                    return(rc.BuiltinTypes.Delegate);
                }
                return(funcSpec.MakeGenericType(rc, funcArgs));
            }
        }
コード例 #8
0
        // Resolve any dynamic params to the type of the target parameters list (for PlayScript only).
        public bool AsTryResolveDynamicArgs(ResolveContext ec, System.Collections.IEnumerable candidates)
        {
            AParametersCollection parameters = null;

            foreach (MemberSpec memberSpec in candidates)
            {
                AParametersCollection possibleParams = null;
                int fixedArgsLen = 0;

                if (memberSpec is MethodSpec)
                {
                    MethodSpec methodSpec = memberSpec as MethodSpec;
                    possibleParams = methodSpec.Parameters;
                    fixedArgsLen   = possibleParams.FixedParameters.Length;
                    if (methodSpec.IsExtensionMethod)
                    {
                        fixedArgsLen--;
                    }
                }
                else if (memberSpec is IndexerSpec)
                {
                    IndexerSpec indexerSpec = memberSpec as IndexerSpec;
                    possibleParams = indexerSpec.Parameters;
                    fixedArgsLen   = possibleParams.FixedParameters.Length;
                }

                if (fixedArgsLen == args.Count)
                {
                    if (parameters != null)
                    {
                        parameters = null;                              // Can't be more than one - or we give up and do a dynamic call..
                        break;
                    }
                    parameters = possibleParams;
                }
            }

            if (parameters != null)
            {
                for (var i = 0; i < args.Count; i++)
                {
                    var arg       = args [i];
                    var paramType = parameters.Types [i];
                    if (arg.Expr.Type == ec.BuiltinTypes.Dynamic)
                    {
                        var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
                        var new_arg     = new Argument(new Cast(
                                                           new TypeExpression(parCastType, arg.Expr.Location),
                                                           arg.Expr, arg.Expr.Location), arg.ArgType);
                        new_arg.Resolve(ec);
                        args [i] = new_arg;
                    }
                }
                return(true);
            }

            return(false);
        }
コード例 #9
0
        static MetaType[] GetVarargsTypes(MethodSpec method, Arguments arguments)
        {
            AParametersCollection pd = method.Parameters;

            Argument a    = arguments[pd.Count - 1];
            Arglist  list = (Arglist)a.Expr;

            return(list.ArgumentTypes);
        }
コード例 #10
0
        protected override ParametersCompiled ResolveParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegateType)
        {
            if (!delegateType.IsDelegate)
            {
                return(null);
            }

            AParametersCollection d_params = Delegate.GetParameters(delegateType);

            if (HasExplicitParameters)
            {
                if (!VerifyExplicitParameters(ec, delegateType, d_params))
                {
                    return(null);
                }

                return(Parameters);
            }

            //
            // If L has an implicitly typed parameter list we make implicit parameters explicit
            // Set each parameter of L is given the type of the corresponding parameter in D
            //
            if (!VerifyParameterCompatibility(ec, delegateType, d_params, ec.IsInProbingMode))
            {
                return(null);
            }

            TypeSpec [] ptypes = new TypeSpec [Parameters.Count];
            for (int i = 0; i < d_params.Count; i++)
            {
                // D has no ref or out parameters
                if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0)
                {
                    return(null);
                }

                TypeSpec d_param = d_params.Types [i];

                //
                // When type inference context exists try to apply inferred type arguments
                //
                if (tic != null)
                {
                    d_param = tic.InflateGenericArgument(ec, d_param);
                }

                ptypes [i] = d_param;
                ImplicitLambdaParameter ilp = (ImplicitLambdaParameter)Parameters.FixedParameters [i];
                ilp.SetParameterType(d_param);
                ilp.Resolve(null, i);
            }

            Parameters.Types = ptypes;
            return(Parameters);
        }
コード例 #11
0
        //
        // Returns the MethodBase for "Invoke" from a delegate type, this is used
        // to extract the signature of a delegate.
        //
        public static MethodInfo GetInvokeMethod(CompilerContext ctx, Type container_type, Type delegate_type)
        {
            Type dt = delegate_type;

            Type[] g_args = null;
            if (TypeManager.IsGenericType(delegate_type))
            {
                g_args        = TypeManager.GetTypeArguments(delegate_type);
                delegate_type = TypeManager.DropGenericTypeArguments(delegate_type);
            }

            Delegate   d = TypeManager.LookupDelegate(delegate_type);
            MethodInfo invoke;

            if (d != null)
            {
#if GMCS_SOURCE
                if (g_args != null)
                {
                    invoke = TypeBuilder.GetMethod(dt, d.InvokeBuilder);
#if MS_COMPATIBLE
                    ParametersCompiled p = (ParametersCompiled)d.Parameters.InflateTypes(g_args, g_args);
                    TypeManager.RegisterMethod(invoke, p);
#endif
                    return(invoke);
                }
#endif
                return(d.InvokeBuilder);
            }

            Expression ml = Expression.MemberLookup(ctx, container_type, null, dt,
                                                    "Invoke", Location.Null);

            MethodGroupExpr mg = ml as MethodGroupExpr;
            if (mg == null)
            {
                ctx.Report.Error(-100, Location.Null, "Internal error: could not find Invoke method!");
                // FIXME: null will cause a crash later
                return(null);
            }

            invoke = (MethodInfo)mg.Methods[0];
#if MS_COMPATIBLE
            if (g_args != null)
            {
                AParametersCollection p = TypeManager.GetParameterData(invoke);
                p = p.InflateTypes(g_args, g_args);
                TypeManager.RegisterMethod(invoke, p);
                return(invoke);
            }
#endif

            return(invoke);
        }
コード例 #12
0
ファイル: pending.cs プロジェクト: mdae/MonoRT
        /// <summary>
        ///   C# allows this kind of scenarios:
        ///   interface I { void M (); }
        ///   class X { public void M (); }
        ///   class Y : X, I { }
        ///
        ///   For that case, we create an explicit implementation function
        ///   I.M in Y.
        /// </summary>
        void DefineProxy(Type iface, MethodInfo base_method, MethodInfo iface_method,
                         AParametersCollection param)
        {
            // TODO: Handle nested iface names
            string proxy_name = SimpleName.RemoveGenericArity(iface.FullName) + "." + iface_method.Name;

            MethodBuilder proxy = container.TypeBuilder.DefineMethod(
                proxy_name,
                MethodAttributes.HideBySig |
                MethodAttributes.NewSlot |
                MethodAttributes.CheckAccessOnOverride |
                MethodAttributes.Virtual,
                CallingConventions.Standard | CallingConventions.HasThis,
                base_method.ReturnType, param.GetEmitTypes());

            Type[] gargs = TypeManager.GetGenericArguments(iface_method);
            if (gargs.Length > 0)
            {
                string[] gnames = new string[gargs.Length];
                for (int i = 0; i < gargs.Length; ++i)
                {
                    gnames[i] = gargs[i].Name;
                }

#if GMCS_SOURCE
                proxy.DefineGenericParameters(gnames);
#else
                throw new NotSupportedException();
#endif
            }

            for (int i = 0; i < param.Count; i++)
            {
                string name = param.FixedParameters [i].Name;
                ParameterAttributes attr = ParametersCompiled.GetParameterAttribute(param.FixedParameters [i].ModFlags);
                proxy.DefineParameter(i + 1, attr, name);
            }

            int         top = param.Count;
            ILGenerator ig  = proxy.GetILGenerator();

            for (int i = 0; i <= top; i++)
            {
                ParameterReference.EmitLdArg(ig, i);
            }

            ig.Emit(OpCodes.Call, base_method);
            ig.Emit(OpCodes.Ret);

            container.TypeBuilder.DefineMethodOverride(proxy, iface_method);
        }
コード例 #13
0
        public bool AsTryResolveDynamicArgs(ResolveContext ec, MemberSpec memberSpec)
        {
            AParametersCollection parameters = null;
            int fixedArgsLen = 0;

            if (memberSpec is MethodSpec)
            {
                MethodSpec methodSpec = memberSpec as MethodSpec;
                parameters   = methodSpec.Parameters;
                fixedArgsLen = parameters.FixedParameters.Length;
                if (methodSpec.IsExtensionMethod)
                {
                    fixedArgsLen--;
                }
            }
            else if (memberSpec is IndexerSpec)
            {
                IndexerSpec indexerSpec = memberSpec as IndexerSpec;
                parameters   = indexerSpec.Parameters;
                fixedArgsLen = parameters.FixedParameters.Length;
            }

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

            if (fixedArgsLen < args.Count)
            {
                // too many arguments
                return(false);
            }

            for (var i = 0; i < args.Count; i++)
            {
                var arg       = args [i];
                var paramType = parameters.Types [i];
                if (arg.Expr.Type == ec.BuiltinTypes.Dynamic)
                {
                    var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
                    var new_arg     = new Argument(new Cast(
                                                       new TypeExpression(parCastType, arg.Expr.Location),
                                                       arg.Expr, arg.Expr.Location), arg.ArgType);
                    new_arg.Resolve(ec);
                    args [i] = new_arg;
                }
            }
            return(true);
        }
コード例 #14
0
        //
        // Returns non-zero value for equal CLS parameter signatures
        //
        public static int IsSameClsSignature(AParametersCollection a, AParametersCollection b)
        {
            int res = 0;

            for (int i = 0; i < a.Count; ++i)
            {
                var a_type = a.Types[i];
                var b_type = b.Types[i];
                if (TypeSpecComparer.Override.IsEqual(a_type, b_type))
                {
                    const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT;
                    if ((a.FixedParameters[i].ModFlags & ref_out) != (b.FixedParameters[i].ModFlags & ref_out))
                    {
                        res |= 1;
                    }

                    continue;
                }

                var ac_a = a_type as ArrayContainer;
                if (ac_a == null)
                {
                    return(0);
                }

                var ac_b = b_type as ArrayContainer;
                if (ac_b == null)
                {
                    return(0);
                }

                if (ac_a.Element is ArrayContainer || ac_b.Element is ArrayContainer)
                {
                    res |= 2;
                    continue;
                }

                if (ac_a.Rank != ac_b.Rank && TypeSpecComparer.Override.IsEqual(ac_a.Element, ac_b.Element))
                {
                    res |= 1;
                    continue;
                }

                return(0);
            }

            return(res);
        }
コード例 #15
0
        // <summary>
        //  Verifies whether the invocation arguments are compatible with the
        //  delegate's target method
        // </summary>
        public static bool VerifyApplicability(EmitContext ec, Type delegate_type,
                                               ArrayList args, Location loc)
        {
            int arg_count;

            if (args == null)
            {
                arg_count = 0;
            }
            else
            {
                arg_count = args.Count;
            }

            Expression ml = Expression.MemberLookup(
                ec.ContainerType, delegate_type, "Invoke", loc);

            MethodGroupExpr me = ml as MethodGroupExpr;

            if (me == null)
            {
                Report.Error(-100, loc, "Internal error: could not find Invoke method!" + delegate_type);
                return(false);
            }

            MethodBase            mb = GetInvokeMethod(ec.ContainerType, delegate_type);
            AParametersCollection pd = TypeManager.GetParameterData(mb);

            int pd_count = pd.Count;

            bool params_method        = pd.HasParams;
            bool is_params_applicable = false;
            bool is_applicable        = me.IsApplicable(ec, args, arg_count, ref mb, ref is_params_applicable) == 0;

            if (!is_applicable && !params_method && arg_count != pd_count)
            {
                Report.Error(1593, loc, "Delegate `{0}' does not take `{1}' arguments",
                             TypeManager.CSharpName(delegate_type), arg_count.ToString());
                return(false);
            }

            return(me.VerifyArgumentsCompat(
                       ec, ref args, arg_count, mb,
                       is_params_applicable || (!is_applicable && params_method),
                       false, loc));
        }
コード例 #16
0
ファイル: doc.cs プロジェクト: mdae/MonoRT
        static string GetParametersFormatted(MemberInfo mi)
        {
            MethodBase   mb        = mi as MethodBase;
            bool         is_setter = false;
            PropertyInfo pi        = mi as PropertyInfo;

            if (pi != null)
            {
                mb = pi.GetGetMethod();
                if (mb == null)
                {
                    is_setter = true;
                    mb        = pi.GetSetMethod();
                }
            }
            if (mb == null)
            {
                return(String.Empty);
            }

            AParametersCollection parameters = TypeManager.GetParameterData(mb);

            if (parameters == null || parameters.Count == 0)
            {
                return(String.Empty);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append('(');
            for (int i = 0; i < parameters.Count; i++)
            {
                if (is_setter && i + 1 == parameters.Count)
                {
                    break;                     // skip "value".
                }
                if (i > 0)
                {
                    sb.Append(',');
                }
                Type t = parameters.Types [i];
                sb.Append(GetSignatureForDoc(t));
            }
            sb.Append(')');
            return(sb.ToString());
        }
コード例 #17
0
ファイル: delegate.cs プロジェクト: rlfqudxo/playscript-mono
		public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
		{
			Namespace type_ns;
			string paramsSuffix = "";
			TypeSpec[] paramTypes = parameters.Types;
			type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);

			// Do we have a PARAMS argument as the final argument?  (Only supported in PlayScript)
			if (rc.FileType == SourceFileType.PlayScript && parameters.FixedParameters.Length > 0 && 
				(parameters.FixedParameters [parameters.FixedParameters.Length - 1].ModFlags & Parameter.Modifier.PARAMS) != 0) {
				paramsSuffix = "P";
				TypeSpec[] newTypes = new TypeSpec[paramTypes.Length - 1];
				Array.Copy (paramTypes, 0, newTypes, 0, newTypes.Length);
				paramTypes = newTypes;
				type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("PlayScript", true);
			}

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

			if (returnType == rc.BuiltinTypes.Void) {
				var actArgs = paramTypes;
				var actionType = type_ns.LookupType (rc.Module, "Action" + paramsSuffix, actArgs.Length, LookupMode.Normal, loc);
				if (actionType == null) {
					return rc.BuiltinTypes.Delegate;
				}
				var actionSpec = actionType.ResolveAsType(rc);
				if (actionSpec == null) {
					return null;
				}
				if (actArgs.Length == 0)
					return actionSpec;
				else
					return actionSpec.MakeGenericType(rc, actArgs);
			} else {
				TypeSpec[] funcArgs = new TypeSpec[paramTypes.Length + 1];
				paramTypes.CopyTo(funcArgs, 0);
				funcArgs[paramTypes.Length] = returnType;
				var funcSpec = type_ns.LookupType (rc.Module, "Func" + paramsSuffix, funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (funcSpec == null) {
					return rc.BuiltinTypes.Delegate;
				}
				return funcSpec.MakeGenericType(rc, funcArgs);
			}
		}
コード例 #18
0
        /// <summary>
        ///   This function tells whether one of our base classes implements
        ///   the given method (which turns out, it is valid to have an interface
        ///   implementation in a base
        /// </summary>
        bool BaseImplements(Type iface_type, MethodInfo mi, out MethodInfo base_method)
        {
            MethodSignature ms;

            AParametersCollection param = TypeManager.GetParameterData(mi);

            ms = new MethodSignature(mi.Name, TypeManager.TypeToCoreType(mi.ReturnType), param.Types);
            MemberList list = TypeContainer.FindMembers(
                container.TypeBuilder.BaseType, MemberTypes.Method | MemberTypes.Property,
                BindingFlags.Public | BindingFlags.Instance,
                MethodSignature.method_signature_filter, ms);

            if (list.Count == 0)
            {
                base_method = null;
                return(false);
            }

            if (TypeManager.ImplementsInterface(container.TypeBuilder.BaseType, iface_type))
            {
                base_method = null;
                return(true);
            }

            base_method = (MethodInfo)list [0];

            if (base_method.DeclaringType.IsInterface)
            {
                return(false);
            }

            if (!base_method.IsPublic)
            {
                return(false);
            }

            if (!base_method.IsAbstract && !base_method.IsVirtual)
            {
                // FIXME: We can avoid creating a proxy if base_method can be marked 'final virtual' instead.
                //        However, it's too late now, the MethodBuilder has already been created (see bug 377519)
                DefineProxy(iface_type, base_method, mi, param);
            }

            return(true);
        }
コード例 #19
0
        //
        // Returns a MemberInfo that is referenced in XML documentation
        // (by "see" or "seealso" elements).
        //
        MemberSpec FindDocumentedMember(MemberCore mc,
                                        TypeSpec type, string member_name, AParametersCollection param_list,
                                        DeclSpace ds, out int warning_type, string cref,
                                        bool warn419, string name_for_error)
        {
//			for (; type != null; type = type.DeclaringType) {
            var mi = FindDocumentedMemberNoNest(
                mc, type, member_name, param_list, ds,
                out warning_type, cref, warn419,
                name_for_error);

            if (mi != null)
            {
                return(mi);                        // new FoundMember (type, mi);
            }
//			}
            warning_type = 0;
            return(null);
        }
コード例 #20
0
        // <summary>
        //  Verifies whether the invocation arguments are compatible with the
        //  delegate's target method
        // </summary>
        public static bool VerifyApplicability(ResolveContext ec, Type delegate_type, ref Arguments args, Location loc)
        {
            int arg_count;

            if (args == null)
            {
                arg_count = 0;
            }
            else
            {
                arg_count = args.Count;
            }

            MethodBase      mb = GetInvokeMethod(ec.Compiler, ec.CurrentType, delegate_type);
            MethodGroupExpr me = new MethodGroupExpr(new MemberInfo [] { mb }, delegate_type, loc);

            AParametersCollection pd = TypeManager.GetParameterData(mb);

            int pd_count = pd.Count;

            bool params_method        = pd.HasParams;
            bool is_params_applicable = false;
            bool is_applicable        = me.IsApplicable(ec, ref args, arg_count, ref mb, ref is_params_applicable) == 0;

            if (args != null)
            {
                arg_count = args.Count;
            }

            if (!is_applicable && !params_method && arg_count != pd_count)
            {
                ec.Report.Error(1593, loc, "Delegate `{0}' does not take `{1}' arguments",
                                TypeManager.CSharpName(delegate_type), arg_count.ToString());
                return(false);
            }

            return(me.VerifyArgumentsCompat(
                       ec, ref args, arg_count, mb,
                       is_params_applicable || (!is_applicable && params_method),
                       false, loc));
        }
コード例 #21
0
        //
        // Generic method parameters importer, param is shared between all instances
        //
        public static AParametersCollection Create(AParametersCollection param, MethodBase method)
        {
            if (param.IsEmpty)
            {
                return(param);
            }

            ParameterInfo [] pi    = method.GetParameters();
            Type []          types = new Type [pi.Length];
            for (int i = 0; i < types.Length; i++)
            {
                Type t = pi [i].ParameterType;
                if (t.IsByRef)
                {
                    t = TypeManager.GetElementType(t);
                }

                types [i] = TypeManager.TypeToCoreType(t);
            }

            return(new ParametersImported(param, types));
        }
コード例 #22
0
        public static TypeSpec CreateDelegateType(ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
        {
            Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace("System", true);

            if (type_ns == null)
            {
                return(null);
            }
            if (returnType == rc.BuiltinTypes.Void)
            {
                var actArgs    = parameters.Types;
                var actionSpec = type_ns.LookupType(rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
                if (actionSpec == null)
                {
                    return(null);
                }
                if (actArgs.Length == 0)
                {
                    return(actionSpec);
                }
                else
                {
                    return(actionSpec.MakeGenericType(rc, actArgs));
                }
            }
            else
            {
                TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
                parameters.Types.CopyTo(funcArgs, 0);
                funcArgs[parameters.Types.Length] = returnType;
                var funcSpec = type_ns.LookupType(rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
                if (funcSpec == null)
                {
                    return(null);
                }
                return(funcSpec.MakeGenericType(rc, funcArgs));
            }
        }
コード例 #23
0
        public AParametersCollection InflateTypes(Type[] genArguments, Type[] argTypes)
        {
            AParametersCollection p = (AParametersCollection)MemberwiseClone();               // Clone ();

            for (int i = 0; i < Count; ++i)
            {
                if (types[i].IsGenericType)
                {
                    Type[] gen_arguments_open = new Type[types[i].GetGenericTypeDefinition().GetGenericArguments().Length];
                    Type[] gen_arguments      = types[i].GetGenericArguments();
                    for (int ii = 0; ii < gen_arguments_open.Length; ++ii)
                    {
                        if (gen_arguments[ii].IsGenericParameter)
                        {
                            Type t = argTypes[gen_arguments[ii].GenericParameterPosition];
                            gen_arguments_open[ii] = t;
                        }
                        else
                        {
                            gen_arguments_open[ii] = gen_arguments[ii];
                        }
                    }

                    p.types[i] = types[i].GetGenericTypeDefinition().MakeGenericType(gen_arguments_open);
                    continue;
                }

                if (types[i].IsGenericParameter)
                {
                    Type gen_argument = argTypes[types[i].GenericParameterPosition];
                    p.types[i] = gen_argument;
                    continue;
                }
            }

            return(p);
        }
コード例 #24
0
ファイル: ecore.cs プロジェクト: speier/shake
 protected virtual int GetApplicableParametersCount(MethodSpec method, AParametersCollection parameters)
 {
     return parameters.Count;
 }
コード例 #25
0
		public IndexerSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, AParametersCollection parameters, PropertyInfo info, Modifiers modifiers)
			: base (MemberKind.Indexer, declaringType, definition, memberType, info, modifiers)
		{
			this.parameters = parameters;
		}
コード例 #26
0
		/// <summary>
		/// Returns true if parameters of two compared methods are CLS-Compliant.
		/// It tests differing only in ref or out, or in array rank.
		/// </summary>
		public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb) 
		{
			Type [] types_a = pa.Types;
			Type [] types_b = pb.Types;
			if (types_a == null || types_b == null)
				return Result.Ok;

			if (types_a.Length != types_b.Length)
				return Result.Ok;

			Result result = Result.Ok;
			for (int i = 0; i < types_b.Length; ++i) {
				Type aType = types_a [i];
				Type bType = types_b [i];

				if (aType.IsArray && bType.IsArray) {
					Type a_el_type = TypeManager.GetElementType (aType);
					Type b_el_type = TypeManager.GetElementType (bType);
					if (aType.GetArrayRank () != bType.GetArrayRank () && a_el_type == b_el_type) {
						result = Result.RefOutArrayError;
						continue;
					}

					if (a_el_type.IsArray || b_el_type.IsArray) {
						result = Result.ArrayArrayError;
						continue;
					}
				}

				if (aType != bType)
					return Result.Ok;

				const Parameter.Modifier out_ref_mod = (Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
				if ((pa.FixedParameters[i].ModFlags & out_ref_mod) != (pb.FixedParameters[i].ModFlags & out_ref_mod))
					result = Result.RefOutArrayError;
			}
			return result;
		}
コード例 #27
0
ファイル: import.cs プロジェクト: Gobiner/ILSpy
		public ImportedGenericMethodDefinition (MethodInfo provider, TypeSpec type, AParametersCollection parameters, TypeParameterSpec[] tparams, MetadataImporter importer)
			: base (provider, type, parameters, importer)
		{
			this.tparams = tparams;
		}
コード例 #28
0
			public void AddParameter (MonoDevelop.Projects.Dom.AbstractMember member, AParametersCollection parameters)
			{
				for (int i = 0; i < parameters.Count; i++) {
					var p = (Parameter)parameters.FixedParameters[i];
					DomParameter parameter = new DomParameter ();
					parameter.Name = ConvertQuoted (p.Name);
					parameter.Location = Convert (p.Location);
					parameter.ReturnType = ConvertReturnType (p.TypeExpression);
					var modifiers = MonoDevelop.Projects.Dom.ParameterModifiers.None;
					if ((p.ParameterModifier & Parameter.Modifier.OUT) == Parameter.Modifier.OUT)
						modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Out;
					if ((p.ParameterModifier & Parameter.Modifier.REF) == Parameter.Modifier.REF)
						modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Ref;
					if ((p.ParameterModifier & Parameter.Modifier.PARAMS) == Parameter.Modifier.PARAMS)
						modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.Params;
					if ((p.ParameterModifier & Parameter.Modifier.This) == Parameter.Modifier.This)
						modifiers |= MonoDevelop.Projects.Dom.ParameterModifiers.This;
					parameter.ParameterModifiers = modifiers;
					member.Add (parameter);
				}
			}
コード例 #29
0
ファイル: import.cs プロジェクト: telurmasin/mono
		public ImportedGenericMethodDefinition (MethodInfo provider, AParametersCollection parameters, TypeParameterSpec[] tparams)
			: base (provider, parameters)
		{
			this.tparams = tparams;
		}
コード例 #30
0
ファイル: anonymous.cs プロジェクト: erik-kallen/NRefactory
		protected bool VerifyParameterCompatibility (ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection invoke_pd, bool ignore_errors)
		{
			if (Parameters.Count != invoke_pd.Count) {
				if (ignore_errors)
					return false;
				
				ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
					      delegate_type.GetSignatureForError (), Parameters.Count.ToString ());
				return false;
			}

			bool has_implicit_parameters = !HasExplicitParameters;
			bool error = false;

			for (int i = 0; i < Parameters.Count; ++i) {
				Parameter.Modifier p_mod = invoke_pd.FixedParameters [i].ModFlags;
				if (Parameters.FixedParameters [i].ModFlags != p_mod && p_mod != Parameter.Modifier.PARAMS) {
					if (ignore_errors)
						return false;
					
					if (p_mod == Parameter.Modifier.NONE)
						ec.Report.Error (1677, Parameters[i].Location, "Parameter `{0}' should not be declared with the `{1}' keyword",
							      (i + 1).ToString (), Parameter.GetModifierSignature (Parameters [i].ModFlags));
					else
						ec.Report.Error (1676, Parameters[i].Location, "Parameter `{0}' must be declared with the `{1}' keyword",
							      (i+1).ToString (), Parameter.GetModifierSignature (p_mod));
					error = true;
				}

				if (has_implicit_parameters)
					continue;

				TypeSpec type = invoke_pd.Types [i];

				if (tic != null)
					type = tic.InflateGenericArgument (ec, type);
				
				if (!TypeSpecComparer.IsEqual (type, Parameters.Types [i])) {
					if (ignore_errors)
						return false;
					
					ec.Report.Error (1678, Parameters [i].Location, "Parameter `{0}' is declared as type `{1}' but should be `{2}'",
						      (i+1).ToString (),
						      Parameters.Types [i].GetSignatureForError (),
						      invoke_pd.Types [i].GetSignatureForError ());
					error = true;
				}
			}

			return !error;
		}
コード例 #31
0
ファイル: delegate.cs プロジェクト: silk/monodevelop
		public static Arguments CreateDelegateMethodArguments (AParametersCollection pd, TypeSpec[] types, Location loc)
		{
			Arguments delegate_arguments = new Arguments (pd.Count);
			for (int i = 0; i < pd.Count; ++i) {
				Argument.AType atype_modifier;
				switch (pd.FixedParameters [i].ModFlags) {
				case Parameter.Modifier.REF:
					atype_modifier = Argument.AType.Ref;
					break;
				case Parameter.Modifier.OUT:
					atype_modifier = Argument.AType.Out;
					break;
				default:
					atype_modifier = 0;
					break;
				}

				delegate_arguments.Add (new Argument (new TypeExpression (types [i], loc), atype_modifier));
			}

			return delegate_arguments;
		}
コード例 #32
0
			protected override int GetApplicableParametersCount (MethodBase method, AParametersCollection parameters)
			{
				//
				// Here is the trick, decrease number of arguments by 1 when only
				// available property method is setter. This makes overload resolution
				// work correctly for indexers.
				//
				
				if (method.Name [0] == 'g')
					return parameters.Count;

				return parameters.Count - 1;
			}
コード例 #33
0
ファイル: doc.cs プロジェクト: liquidboy/ILSpy
        private static MemberSpec FindDocumentedMemberNoNest(
            MemberCore mc, TypeSpec type, string member_name,
            AParametersCollection param_list, DeclSpace ds, out int warning_type,
            string cref, bool warn419, string name_for_error, Report Report)
        {
            warning_type = 0;
//			var filter = new MemberFilter (member_name, 0, MemberKind.All, param_list, null);
            IList <MemberSpec> found = null;

            while (type != null && found == null)
            {
                found = MemberCache.FindMembers(type, member_name, false);
                type  = type.DeclaringType;
            }

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

            if (warn419 && found.Count > 1)
            {
                Report419(mc, name_for_error, found.ToArray(), Report);
            }

            return(found [0]);

/*
 *                      if (param_list == null) {
 *                              // search for fields/events etc.
 *                              mis = TypeManager.MemberLookup (type, null,
 *                                      type, MemberKind.All,
 *                                      BindingRestriction.None,
 *                                      member_name, null);
 *                              mis = FilterOverridenMembersOut (mis);
 *                              if (mis == null || mis.Length == 0)
 *                                      return null;
 *                              if (warn419 && IsAmbiguous (mis))
 *                                      Report419 (mc, name_for_error, mis, Report);
 *                              return mis [0];
 *                      }
 *
 *                      MethodSignature msig = new MethodSignature (member_name, null, param_list);
 *                      mis = FindMethodBase (type,
 *                              BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
 *                              msig);
 *
 *                      if (warn419 && mis.Length > 0) {
 *                              if (IsAmbiguous (mis))
 *                                      Report419 (mc, name_for_error, mis, Report);
 *                              return mis [0];
 *                      }
 *
 *                      // search for operators (whose parameters exactly
 *                      // matches with the list) and possibly report CS1581.
 *                      string oper = null;
 *                      string return_type_name = null;
 *                      if (member_name.StartsWith ("implicit operator ")) {
 *                              Operator.GetMetadataName (Operator.OpType.Implicit);
 *                              return_type_name = member_name.Substring (18).Trim (wsChars);
 *                      }
 *                      else if (member_name.StartsWith ("explicit operator ")) {
 *                              oper = Operator.GetMetadataName (Operator.OpType.Explicit);
 *                              return_type_name = member_name.Substring (18).Trim (wsChars);
 *                      }
 *                      else if (member_name.StartsWith ("operator ")) {
 *                              oper = member_name.Substring (9).Trim (wsChars);
 *                              switch (oper) {
 *                              // either unary or binary
 *                              case "+":
 *                                      oper = param_list.Length == 2 ?
 *                                              Operator.GetMetadataName (Operator.OpType.Addition) :
 *                                              Operator.GetMetadataName (Operator.OpType.UnaryPlus);
 *                                      break;
 *                              case "-":
 *                                      oper = param_list.Length == 2 ?
 *                                              Operator.GetMetadataName (Operator.OpType.Subtraction) :
 *                                              Operator.GetMetadataName (Operator.OpType.UnaryNegation);
 *                                      break;
 *                              default:
 *                                      oper = Operator.GetMetadataName (oper);
 *                                      if (oper != null)
 *                                              break;
 *
 *                                      warning_type = 1584;
 *                                      Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", param_list.Length == 2 ? "binary" : "unary");
 *                                      Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
 *                                              mc.GetSignatureForError (), cref);
 *                                      return null;
 *                              }
 *                      }
 *                      // here we still don't consider return type (to
 *                      // detect CS1581 or CS1002+CS1584).
 *                      msig = new MethodSignature (oper, null, param_list);
 *
 *                      mis = FindMethodBase (type,
 *                              BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
 *                              msig);
 *                      if (mis.Length == 0)
 *                              return null; // CS1574
 *                      var mi = mis [0];
 *                      TypeSpec expected = mi is MethodSpec ?
 *                              ((MethodSpec) mi).ReturnType :
 *                              mi is PropertySpec ?
 *                              ((PropertySpec) mi).PropertyType :
 *                              null;
 *                      if (return_type_name != null) {
 *                              TypeSpec returnType = FindDocumentedType (mc, return_type_name, ds, cref, Report);
 *                              if (returnType == null || returnType != expected) {
 *                                      warning_type = 1581;
 *                                      Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute `{0}'", cref);
 *                                      return null;
 *                              }
 *                      }
 *                      return mis [0];
 */
        }
コード例 #34
0
ファイル: attribute.cs プロジェクト: alisci01/mono
		/// <summary>
		/// Returns true if parameters of two compared methods are CLS-Compliant.
		/// It tests differing only in ref or out, or in array rank.
		/// </summary>
		public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb) 
		{
			TypeSpec [] types_a = pa.Types;
			TypeSpec [] types_b = pb.Types;
			if (types_a == null || types_b == null)
				return Result.Ok;

			if (types_a.Length != types_b.Length)
				return Result.Ok;

			Result result = Result.Ok;
			for (int i = 0; i < types_b.Length; ++i) {
				TypeSpec aType = types_a [i];
				TypeSpec bType = types_b [i];

				var ac_a = aType as ArrayContainer;
				var ac_b = aType as ArrayContainer;

				if (ac_a != null && ac_b != null) {
					if (ac_a.Rank != ac_b.Rank && ac_a.Element == ac_b.Element) {
						result = Result.RefOutArrayError;
						continue;
					}

					if (ac_a.Element.IsArray || ac_b.Element.IsArray) {
						result = Result.ArrayArrayError;
						continue;
					}
				}

				if (aType != bType)
					return Result.Ok;

				const Parameter.Modifier out_ref_mod = (Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
				if ((pa.FixedParameters[i].ModFlags & out_ref_mod) != (pb.FixedParameters[i].ModFlags & out_ref_mod))
					result = Result.RefOutArrayError;
			}
			return result;
		}
コード例 #35
0
ファイル: ecore.cs プロジェクト: speier/shake
        protected virtual void Error_InvalidArguments(ResolveContext ec, Location loc, int idx, MethodSpec method,
            Argument a, AParametersCollection expected_par, TypeSpec paramType)
        {
            ExtensionMethodGroupExpr emg = this as ExtensionMethodGroupExpr;

            if (a is CollectionElementInitializer.ElementInitializerArgument) {
                ec.Report.SymbolRelatedToPreviousError (method);
                if ((expected_par.FixedParameters [idx].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
                    ec.Report.Error (1954, loc, "The best overloaded collection initalizer method `{0}' cannot have 'ref', or `out' modifier",
                        TypeManager.CSharpSignature (method));
                    return;
                }
                ec.Report.Error (1950, loc, "The best overloaded collection initalizer method `{0}' has some invalid arguments",
                      TypeManager.CSharpSignature (method));
            } else if (TypeManager.IsDelegateType (method.DeclaringType)) {
                ec.Report.Error (1594, loc, "Delegate `{0}' has some invalid arguments",
                    TypeManager.CSharpName (method.DeclaringType));
            } else {
                ec.Report.SymbolRelatedToPreviousError (method);
                if (emg != null) {
                    ec.Report.Error (1928, loc,
                        "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments",
                        emg.ExtensionExpression.GetSignatureForError (),
                        emg.Name, TypeManager.CSharpSignature (method));
                } else {
                    ec.Report.Error (1502, loc, "The best overloaded method match for `{0}' has some invalid arguments",
                        TypeManager.CSharpSignature (method));
                }
            }

            Parameter.Modifier mod = idx >= expected_par.Count ? 0 : expected_par.FixedParameters [idx].ModFlags;

            string index = (idx + 1).ToString ();
            if (((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) ^
                (a.Modifier & (Parameter.Modifier.REF | Parameter.Modifier.OUT))) != 0) {
                if ((mod & Parameter.Modifier.ISBYREF) == 0)
                    ec.Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier",
                        index, Parameter.GetModifierSignature (a.Modifier));
                else
                    ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier",
                        index, Parameter.GetModifierSignature (mod));
            } else {
                string p1 = a.GetSignatureForError ();
                string p2 = TypeManager.CSharpName (paramType);

                if (p1 == p2) {
                    ec.Report.ExtraInformation (loc, "(equally named types possibly from different assemblies in previous ");
                    ec.Report.SymbolRelatedToPreviousError (a.Expr.Type);
                    ec.Report.SymbolRelatedToPreviousError (paramType);
                }

                if (idx == 0 && emg != null) {
                    ec.Report.Error (1929, loc,
                        "Extension method instance type `{0}' cannot be converted to `{1}'", p1, p2);
                } else {
                    ec.Report.Error (1503, loc,
                        "Argument `#{0}' cannot convert `{1}' expression to type `{2}'", index, p1, p2);
                }
            }
        }
コード例 #36
0
ファイル: anonymous.cs プロジェクト: rabink/mono
		protected bool VerifyExplicitParameters (ResolveContext ec, TypeSpec delegate_type, AParametersCollection parameters)
		{
			if (VerifyParameterCompatibility (ec, delegate_type, parameters, ec.IsInProbingMode))
				return true;

			if (!ec.IsInProbingMode)
				ec.Report.Error (1661, loc,
					"Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch",
					GetSignatureForError (), TypeManager.CSharpName (delegate_type));

			return false;
		}
コード例 #37
0
        PendingImplementation(TypeContainer container, MissingInterfacesInfo [] missing_ifaces, ArrayList abstract_methods, int total)
        {
            TypeBuilder type_builder = container.TypeBuilder;

            this.container          = container;
            pending_implementations = new TypeAndMethods [total];

            int i = 0;

            if (abstract_methods != null)
            {
                int count = abstract_methods.Count;
                pending_implementations [i].methods    = new MethodInfo [count];
                pending_implementations [i].need_proxy = new MethodInfo [count];

                abstract_methods.CopyTo(pending_implementations [i].methods, 0);
                pending_implementations [i].found = new MethodData [count];
                pending_implementations [i].args  = new Type [count][];
                pending_implementations [i].mods  = new Parameter.Modifier [count][];
                pending_implementations [i].type  = type_builder;

                int j = 0;
                foreach (MemberInfo m in abstract_methods)
                {
                    MethodInfo mi = (MethodInfo)m;

                    AParametersCollection pd = TypeManager.GetParameterData(mi);
                    Type [] types            = pd.Types;

                    pending_implementations [i].args [j] = types;
                    pending_implementations [i].mods [j] = null;
                    if (pd.Count > 0)
                    {
                        Parameter.Modifier [] pm = new Parameter.Modifier [pd.Count];
                        for (int k = 0; k < pd.Count; k++)
                        {
                            pm [k] = pd.FixedParameters[k].ModFlags;
                        }
                        pending_implementations [i].mods [j] = pm;
                    }

                    j++;
                }
                ++i;
            }

            foreach (MissingInterfacesInfo missing in missing_ifaces)
            {
                MethodInfo [] mi;
                Type          t = missing.Type;

                if (!t.IsInterface)
                {
                    continue;
                }

                if (t is TypeBuilder)
                {
                    TypeContainer iface;

                    iface = TypeManager.LookupInterface(t);

                    mi = iface.GetMethods();
                }
                else
                {
                    mi = t.GetMethods();
                }

                int count = mi.Length;
                pending_implementations [i].type       = t;
                pending_implementations [i].optional   = missing.Optional;
                pending_implementations [i].methods    = mi;
                pending_implementations [i].args       = new Type [count][];
                pending_implementations [i].mods       = new Parameter.Modifier [count][];
                pending_implementations [i].found      = new MethodData [count];
                pending_implementations [i].need_proxy = new MethodInfo [count];

                int j = 0;
                foreach (MethodInfo m in mi)
                {
                    pending_implementations [i].args [j] = Type.EmptyTypes;
                    pending_implementations [i].mods [j] = null;

                    // If there is a previous error, just ignore
                    if (m == null)
                    {
                        continue;
                    }

                    AParametersCollection pd = TypeManager.GetParameterData(m);
                    pending_implementations [i].args [j] = pd.Types;

                    if (pd.Count > 0)
                    {
                        Parameter.Modifier [] pm = new Parameter.Modifier [pd.Count];
                        for (int k = 0; k < pd.Count; k++)
                        {
                            pm [k] = pd.FixedParameters [k].ModFlags;
                        }
                        pending_implementations [i].mods [j] = pm;
                    }

                    j++;
                }
                i++;
            }
        }
コード例 #38
0
ファイル: import.cs プロジェクト: telurmasin/mono
		public ImportedMethodDefinition (MethodBase provider, AParametersCollection parameters)
			: base (provider)
		{
			this.parameters = parameters;
		}
コード例 #39
0
ファイル: doc.cs プロジェクト: speier/shake
        private static MemberSpec FindDocumentedMemberNoNest(
            MemberCore mc, TypeSpec type, string member_name,
            AParametersCollection param_list, DeclSpace ds, out int warning_type,
            string cref, bool warn419, string name_for_error, Report Report)
        {
            warning_type = 0;
            var filter = new MemberFilter (member_name, 0, MemberKind.All, param_list, null);
            IList<MemberSpec> found = null;
            while (type != null && found == null) {
                found = MemberCache.FindMembers (type, filter, BindingRestriction.None);
                type = type.DeclaringType;
            }

            if (found == null)
                return null;

            if (warn419 && found.Count > 1) {
                Report419 (mc, name_for_error, found.ToArray (), Report);
            }

            return found [0];

            /*
            if (param_list == null) {
                // search for fields/events etc.
                mis = TypeManager.MemberLookup (type, null,
                    type, MemberKind.All,
                    BindingRestriction.None,
                    member_name, null);
                mis = FilterOverridenMembersOut (mis);
                if (mis == null || mis.Length == 0)
                    return null;
                if (warn419 && IsAmbiguous (mis))
                    Report419 (mc, name_for_error, mis, Report);
                return mis [0];
            }

            MethodSignature msig = new MethodSignature (member_name, null, param_list);
            mis = FindMethodBase (type,
                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
                msig);

            if (warn419 && mis.Length > 0) {
                if (IsAmbiguous (mis))
                    Report419 (mc, name_for_error, mis, Report);
                return mis [0];
            }

            // search for operators (whose parameters exactly
            // matches with the list) and possibly report CS1581.
            string oper = null;
            string return_type_name = null;
            if (member_name.StartsWith ("implicit operator ")) {
                Operator.GetMetadataName (Operator.OpType.Implicit);
                return_type_name = member_name.Substring (18).Trim (wsChars);
            }
            else if (member_name.StartsWith ("explicit operator ")) {
                oper = Operator.GetMetadataName (Operator.OpType.Explicit);
                return_type_name = member_name.Substring (18).Trim (wsChars);
            }
            else if (member_name.StartsWith ("operator ")) {
                oper = member_name.Substring (9).Trim (wsChars);
                switch (oper) {
                // either unary or binary
                case "+":
                    oper = param_list.Length == 2 ?
                        Operator.GetMetadataName (Operator.OpType.Addition) :
                        Operator.GetMetadataName (Operator.OpType.UnaryPlus);
                    break;
                case "-":
                    oper = param_list.Length == 2 ?
                        Operator.GetMetadataName (Operator.OpType.Subtraction) :
                        Operator.GetMetadataName (Operator.OpType.UnaryNegation);
                    break;
                default:
                    oper = Operator.GetMetadataName (oper);
                    if (oper != null)
                        break;

                    warning_type = 1584;
                    Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", param_list.Length == 2 ? "binary" : "unary");
                    Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
                        mc.GetSignatureForError (), cref);
                    return null;
                }
            }
            // here we still don't consider return type (to
            // detect CS1581 or CS1002+CS1584).
            msig = new MethodSignature (oper, null, param_list);

            mis = FindMethodBase (type,
                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
                msig);
            if (mis.Length == 0)
                return null; // CS1574
            var mi = mis [0];
            TypeSpec expected = mi is MethodSpec ?
                ((MethodSpec) mi).ReturnType :
                mi is PropertySpec ?
                ((PropertySpec) mi).PropertyType :
                null;
            if (return_type_name != null) {
                TypeSpec returnType = FindDocumentedType (mc, return_type_name, ds, cref, Report);
                if (returnType == null || returnType != expected) {
                    warning_type = 1581;
                    Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute `{0}'", cref);
                    return null;
                }
            }
            return mis [0];
            */
        }
コード例 #40
0
ファイル: import.cs プロジェクト: telurmasin/mono
		public ImportedIndexerDefinition (PropertyInfo provider, AParametersCollection parameters)
			: base (provider)
		{
			this.parameters = parameters;
		}
コード例 #41
0
ファイル: parameter.cs プロジェクト: lewurm/benchmarker
		//
		// Generic method parameters importer, param is shared between all instances
		//
		public static AParametersCollection Create (AParametersCollection param, MethodBase method)
		{
			if (param.IsEmpty)
				return param;

			ParameterInfo [] pi = method.GetParameters ();
			Type [] types = new Type [pi.Length];
			for (int i = 0; i < types.Length; i++) {
				Type t = pi [i].ParameterType;
				if (t.IsByRef)
					t = TypeManager.GetElementType (t);

				types [i] = TypeManager.TypeToCoreType (t);
			}

			return new ParametersCollection (param, types);
		}
コード例 #42
0
ファイル: delegate.cs プロジェクト: psni/mono
		public static Arguments CreateDelegateMethodArguments (ResolveContext rc, AParametersCollection pd, TypeSpec[] types, Location loc)
		{
			Arguments delegate_arguments = new Arguments (pd.Count);
			for (int i = 0; i < pd.Count; ++i) {
				Argument.AType atype_modifier;
				switch (pd.FixedParameters [i].ModFlags & Parameter.Modifier.RefOutMask) {
				case Parameter.Modifier.REF:
					atype_modifier = Argument.AType.Ref;
					break;
				case Parameter.Modifier.OUT:
					atype_modifier = Argument.AType.Out;
					break;
				default:
					atype_modifier = 0;
					break;
				}

				var ptype = types[i];
				if (ptype.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
					ptype = rc.BuiltinTypes.Object;

				delegate_arguments.Add (new Argument (new TypeExpression (ptype, loc), atype_modifier));
			}

			return delegate_arguments;
		}
コード例 #43
0
		//
		// This finds the method or property for us to override. invocation_type is the type where
		// the override is going to be declared, name is the name of the method/property, and
		// param_types is the parameters, if any to the method or property
		//
		// Because the MemberCache holds members from this class and all the base classes,
		// we can avoid tons of reflection stuff.
		//
		public MemberInfo FindMemberToOverride (Type invocation_type, string name, AParametersCollection parameters, GenericMethod generic_method, bool is_property)
		{
			ArrayList applicable;
			if (method_hash != null && !is_property)
				applicable = (ArrayList) method_hash [name];
			else
				applicable = (ArrayList) member_hash [name];
			
			if (applicable == null)
				return null;
			//
			// Walk the chain of methods, starting from the top.
			//
			for (int i = applicable.Count - 1; i >= 0; i--) {
				CacheEntry entry = (CacheEntry) applicable [i];
				
				if ((entry.EntryType & (is_property ? (EntryType.Property | EntryType.Field) : EntryType.Method)) == 0)
					continue;

				PropertyInfo pi = null;
				MethodInfo mi = null;
				FieldInfo fi = null;
				AParametersCollection cmp_attrs;
				
				if (is_property) {
					if ((entry.EntryType & EntryType.Field) != 0) {
						fi = (FieldInfo)entry.Member;
						cmp_attrs = ParametersCompiled.EmptyReadOnlyParameters;
					} else {
						pi = (PropertyInfo) entry.Member;
						cmp_attrs = TypeManager.GetParameterData (pi);
					}
				} else {
					mi = (MethodInfo) entry.Member;
					cmp_attrs = TypeManager.GetParameterData (mi);
				}

				if (fi != null) {
					// TODO: Almost duplicate !
					// Check visibility
					switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
					case FieldAttributes.PrivateScope:
						continue;
					case FieldAttributes.Private:
						//
						// A private method is Ok if we are a nested subtype.
						// The spec actually is not very clear about this, see bug 52458.
						//
						if (!invocation_type.Equals (entry.Container.Type) &&
						    !TypeManager.IsNestedChildOf (invocation_type, entry.Container.Type))
							continue;
						break;
					case FieldAttributes.FamANDAssem:
					case FieldAttributes.Assembly:
						//
						// Check for assembly methods
						//
						if (fi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
							continue;
						break;
					}
					return entry.Member;
				}

				//
				// Check the arguments
				//
				if (cmp_attrs.Count != parameters.Count)
					continue;
	
				int j;
				for (j = 0; j < cmp_attrs.Count; ++j) {
					//
					// LAMESPEC: No idea why `params' modifier is ignored
					//
					if ((parameters.FixedParameters [j].ModFlags & ~Parameter.Modifier.PARAMS) != 
						(cmp_attrs.FixedParameters [j].ModFlags & ~Parameter.Modifier.PARAMS))
						break;

					if (!TypeManager.IsEqual (parameters.Types [j], cmp_attrs.Types [j]))
						break;
				}

				if (j < cmp_attrs.Count)
					continue;

				//
				// check generic arguments for methods
				//
				if (mi != null) {
					Type [] cmpGenArgs = TypeManager.GetGenericArguments (mi);
					if (generic_method == null && cmpGenArgs != null && cmpGenArgs.Length != 0)
						continue;
					if (generic_method != null && cmpGenArgs != null && cmpGenArgs.Length != generic_method.TypeParameters.Length)
						continue;
				}

				//
				// get one of the methods because this has the visibility info.
				//
				if (is_property) {
					mi = pi.GetGetMethod (true);
					if (mi == null)
						mi = pi.GetSetMethod (true);
				}
				
				//
				// Check visibility
				//
				switch (mi.Attributes & MethodAttributes.MemberAccessMask) {
				case MethodAttributes.PrivateScope:
					continue;
				case MethodAttributes.Private:
					//
					// A private method is Ok if we are a nested subtype.
					// The spec actually is not very clear about this, see bug 52458.
					//
					if (!invocation_type.Equals (entry.Container.Type) &&
					    !TypeManager.IsNestedChildOf (invocation_type, entry.Container.Type))
						continue;
					break;
				case MethodAttributes.FamANDAssem:
				case MethodAttributes.Assembly:
					//
					// Check for assembly methods
					//
					if (!TypeManager.IsThisOrFriendAssembly (mi.DeclaringType.Assembly))
						continue;
					break;
				}
				return entry.Member;
			}
			
			return null;
		}
コード例 #44
0
ファイル: import.cs プロジェクト: Gobiner/ILSpy
		public ImportedParameterMemberDefinition (PropertyInfo provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
			: base (provider, type, importer)
		{
			this.parameters = parameters;
		}
コード例 #45
0
        protected override Parameters ResolveParameters(EmitContext ec, TypeInferenceContext tic, Type delegateType)
        {
            if (!TypeManager.IsDelegateType(delegateType))
            {
                return(null);
            }

            AParametersCollection d_params = TypeManager.GetDelegateParameters(delegateType);

            if (HasExplicitParameters)
            {
                if (!VerifyExplicitParameters(delegateType, d_params, ec.IsInProbingMode))
                {
                    return(null);
                }

                return(Parameters);
            }

            //
            // If L has an implicitly typed parameter list we make implicit parameters explicit
            // Set each parameter of L is given the type of the corresponding parameter in D
            //
            if (!VerifyParameterCompatibility(delegateType, d_params, ec.IsInProbingMode))
            {
                return(null);
            }

            Type [] ptypes = new Type [Parameters.Count];
            for (int i = 0; i < d_params.Count; i++)
            {
                // D has no ref or out parameters
                if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0)
                {
                    return(null);
                }

                Type d_param = d_params.Types [i];

#if MS_COMPATIBLE
                // Blablabla, because reflection does not work with dynamic types
                if (d_param.IsGenericParameter)
                {
                    d_param = delegateType.GetGenericArguments() [d_param.GenericParameterPosition];
                }
#endif
                //
                // When type inference context exists try to apply inferred type arguments
                //
                if (tic != null)
                {
                    d_param = tic.InflateGenericArgument(d_param);
                }

                ptypes [i] = d_param;
                ((ImplicitLambdaParameter)Parameters.FixedParameters [i]).Type = d_param;
            }

            Parameters.Types = ptypes;
            return(Parameters);
        }
コード例 #46
0
ファイル: parameter.cs プロジェクト: bl8/mono
		//
		// Returns non-zero value for equal CLS parameter signatures
		//
		public static int IsSameClsSignature (AParametersCollection a, AParametersCollection b)
		{
			int res = 0;

			for (int i = 0; i < a.Count; ++i) {
				var a_type = a.Types[i];
				var b_type = b.Types[i];
				if (TypeSpecComparer.Override.IsEqual (a_type, b_type)) {
					if ((a.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (b.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask))
						res |= 1;

					continue;
				}

				var ac_a = a_type as ArrayContainer;
				if (ac_a == null)
					return 0;

				var ac_b = b_type as ArrayContainer;
				if (ac_b == null)
					return 0;

				if (ac_a.Element is ArrayContainer || ac_b.Element is ArrayContainer) {
					res |= 2;
					continue;
				}

				if (ac_a.Rank != ac_b.Rank && TypeSpecComparer.Override.IsEqual (ac_a.Element, ac_b.Element)) {
					res |= 1;
					continue;
				}

				return 0;
			}

			return res;
		}
コード例 #47
0
ファイル: import.cs プロジェクト: frje/SharpLang
		protected ImportedParameterMemberDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
			: base (provider, type, importer)
		{
			this.parameters = parameters;
		}
コード例 #48
0
ファイル: CSharpParser.cs プロジェクト: 0xb1dd1e/NRefactory
			void AddParameter(AstNode parent, AParametersCollection parameters)
			{
				if (parameters == null)
					return;
				var paramLocation = LocationsBag.GetLocations(parameters);
				
				for (int i = 0; i < parameters.Count; i++) {
					var p = (Parameter)parameters.FixedParameters [i];
					if (p == null)
						continue;
					var location = LocationsBag.GetLocations(p);
					var parameterDeclarationExpression = new ParameterDeclaration();
					AddAttributeSection(parameterDeclarationExpression, p);
					switch (p.ModFlags) {
						case Parameter.Modifier.OUT:
							parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out;
							if (location != null)
								parameterDeclarationExpression.AddChild(new CSharpTokenNode(Convert(location [0]), ParameterDeclaration.OutModifierRole), ParameterDeclaration.OutModifierRole);
							break;
						case Parameter.Modifier.REF:
							parameterDeclarationExpression.ParameterModifier = ParameterModifier.Ref;
							if (location != null)
								parameterDeclarationExpression.AddChild(new CSharpTokenNode(Convert(location [0]), ParameterDeclaration.RefModifierRole), ParameterDeclaration.RefModifierRole);
							break;
						case Parameter.Modifier.PARAMS:
							parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params;
							if (location != null)
								parameterDeclarationExpression.AddChild(new CSharpTokenNode(Convert(location [0]), ParameterDeclaration.ParamsModifierRole), ParameterDeclaration.ParamsModifierRole);
							break;
						default:
							if (p.HasExtensionMethodModifier) {
								parameterDeclarationExpression.ParameterModifier = ParameterModifier.This;
								if (location != null) {
									parameterDeclarationExpression.AddChild(new CSharpTokenNode(Convert(location [0]), ParameterDeclaration.ThisModifierRole), ParameterDeclaration.ThisModifierRole);
								}
							}
							break;
					}
					if (p.TypeExpression != null) // lambdas may have no types (a, b) => ...
						parameterDeclarationExpression.AddChild(ConvertToType(p.TypeExpression), Roles.Type);
					if (p.Name != null)
						parameterDeclarationExpression.AddChild(Identifier.Create(p.Name, Convert(p.Location)), Roles.Identifier);
					if (p.HasDefaultValue) {
						if (location != null && location.Count > 1)
							parameterDeclarationExpression.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.Assign), Roles.Assign);
						parameterDeclarationExpression.AddChild((Expression)p.DefaultValue.Accept(this), Roles.Expression);
					}
					parent.AddChild(parameterDeclarationExpression, Roles.Parameter);
					if (paramLocation != null && i < paramLocation.Count) {
						parent.AddChild(new CSharpTokenNode(Convert(paramLocation [i]), Roles.Comma), Roles.Comma);
					}
				}
			}
コード例 #49
0
ファイル: import.cs プロジェクト: frje/SharpLang
		public ImportedMethodDefinition (MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer)
			: base (provider, type, parameters, importer)
		{
		}
コード例 #50
0
ファイル: method.cs プロジェクト: OpenFlex/playscript-mono
		public MethodSpec (MemberKind kind, TypeSpec declaringType, IMethodDefinition details, TypeSpec returnType,
			AParametersCollection parameters, Modifiers modifiers)
			: base (kind, declaringType, details, modifiers)
		{
			this.parameters = parameters;
			this.returnType = returnType;
		}
コード例 #51
0
ファイル: attribute.cs プロジェクト: lewurm/benchmarker
		/// <summary>
		/// Returns true if parameters of two compared methods are CLS-Compliant.
		/// It tests differing only in ref or out, or in array rank.
		/// </summary>
		public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb) 
		{
			Type [] types_a = pa.Types;
			Type [] types_b = pb.Types;
			if (types_a == null || types_b == null)
				return Result.Ok;

			if (types_a.Length != types_b.Length)
				return Result.Ok;

			Result result = Result.Ok;
			for (int i = 0; i < types_b.Length; ++i) {
				Type aType = types_a [i];
				Type bType = types_b [i];

				if (aType.IsArray && bType.IsArray) {
					Type a_el_type = aType.GetElementType ();
					Type b_el_type = bType.GetElementType ();
					if (aType.GetArrayRank () != bType.GetArrayRank () && a_el_type == b_el_type) {
						result = Result.RefOutArrayError;
						continue;
					}

					if (a_el_type.IsArray || b_el_type.IsArray) {
						result = Result.ArrayArrayError;
						continue;
					}
				}

				if (aType != bType)
					return Result.Ok;

				if (pa.FixedParameters [i].ModFlags != pb.FixedParameters [i].ModFlags)
					result = Result.RefOutArrayError;
			}
			return result;
		}
コード例 #52
0
ファイル: doc.cs プロジェクト: speier/shake
 //
 // Returns a MemberInfo that is referenced in XML documentation
 // (by "see" or "seealso" elements).
 //
 private static MemberSpec FindDocumentedMember(MemberCore mc,
     TypeSpec type, string member_name, AParametersCollection param_list,
     DeclSpace ds, out int warning_type, string cref,
     bool warn419, string name_for_error, Report r)
 {
     //			for (; type != null; type = type.DeclaringType) {
         var mi = FindDocumentedMemberNoNest (
             mc, type, member_name, param_list, ds,
             out warning_type, cref, warn419,
             name_for_error, r);
         if (mi != null)
             return mi; // new FoundMember (type, mi);
     //			}
     warning_type = 0;
     return null;
 }
コード例 #53
0
        /// <summary>
        ///  Verifies whether the method in question is compatible with the delegate
        ///  Returns the method itself if okay and null if not.
        /// </summary>
        public static MethodBase VerifyMethod(Type container_type, Type delegate_type,
                                              MethodGroupExpr old_mg, MethodBase mb)
        {
            bool is_method_definition = TypeManager.IsGenericMethodDefinition(mb);

            MethodInfo invoke_mb = GetInvokeMethod(container_type, delegate_type);

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

            if (is_method_definition)
            {
                invoke_mb = (MethodInfo)TypeManager.DropGenericMethodArguments(invoke_mb);
            }

            AParametersCollection invoke_pd = TypeManager.GetParameterData(invoke_mb);

#if GMCS_SOURCE
            if (!is_method_definition && old_mg.type_arguments == null &&
                !TypeManager.InferTypeArguments(invoke_pd, ref mb))
            {
                return(null);
            }
#endif
            AParametersCollection pd = TypeManager.GetParameterData(mb);

            if (invoke_pd.Count != pd.Count)
            {
                return(null);
            }

            for (int i = pd.Count; i > 0;)
            {
                i--;

                Type invoke_pd_type = invoke_pd.Types [i];
                Type pd_type        = pd.Types [i];
                Parameter.Modifier invoke_pd_type_mod = invoke_pd.FixedParameters [i].ModFlags;
                Parameter.Modifier pd_type_mod        = pd.FixedParameters [i].ModFlags;

                invoke_pd_type_mod &= ~Parameter.Modifier.PARAMS;
                pd_type_mod        &= ~Parameter.Modifier.PARAMS;

                if (invoke_pd_type_mod != pd_type_mod)
                {
                    return(null);
                }

                if (TypeManager.IsEqual(invoke_pd_type, pd_type))
                {
                    continue;
                }

                if (IsTypeCovariant(new EmptyExpression(invoke_pd_type), pd_type))
                {
                    continue;
                }

                return(null);
            }

            Type invoke_mb_retval = ((MethodInfo)invoke_mb).ReturnType;
            Type mb_retval        = ((MethodInfo)mb).ReturnType;
            if (TypeManager.TypeToCoreType(invoke_mb_retval) == TypeManager.TypeToCoreType(mb_retval))
            {
                return(mb);
            }

            //if (!IsTypeCovariant (mb_retval, invoke_mb_retval))
            //	return null;

            if (RootContext.Version == LanguageVersion.ISO_1)
            {
                return(null);
            }

            return(mb);
        }
コード例 #54
0
ファイル: anonymous.cs プロジェクト: rabink/mono
		protected bool VerifyParameterCompatibility (ResolveContext ec, TypeSpec delegate_type, AParametersCollection invoke_pd, bool ignore_errors)
		{
			if (Parameters.Count != invoke_pd.Count) {
				if (ignore_errors)
					return false;
				
				ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
					      TypeManager.CSharpName (delegate_type), Parameters.Count.ToString ());
				return false;
			}

			bool has_implicit_parameters = !HasExplicitParameters;
			bool error = false;

			for (int i = 0; i < Parameters.Count; ++i) {
				Parameter.Modifier p_mod = invoke_pd.FixedParameters [i].ModFlags;
				if (Parameters.FixedParameters [i].ModFlags != p_mod && p_mod != Parameter.Modifier.PARAMS) {
					if (ignore_errors)
						return false;
					
					if (p_mod == Parameter.Modifier.NONE)
						ec.Report.Error (1677, loc, "Parameter `{0}' should not be declared with the `{1}' keyword",
							      (i + 1).ToString (), Parameter.GetModifierSignature (Parameters.FixedParameters [i].ModFlags));
					else
						ec.Report.Error (1676, loc, "Parameter `{0}' must be declared with the `{1}' keyword",
							      (i+1).ToString (), Parameter.GetModifierSignature (p_mod));
					error = true;
				}

				if (has_implicit_parameters)
					continue;

				TypeSpec type = invoke_pd.Types [i];
				
				// We assume that generic parameters are always inflated
				if (TypeManager.IsGenericParameter (type))
					continue;
				
				if (TypeManager.HasElementType (type) && TypeManager.IsGenericParameter (TypeManager.GetElementType (type)))
					continue;
				
				if (!TypeSpecComparer.IsEqual (invoke_pd.Types [i], Parameters.Types [i])) {
					if (ignore_errors)
						return false;
					
					ec.Report.Error (1678, loc, "Parameter `{0}' is declared as type `{1}' but should be `{2}'",
						      (i+1).ToString (),
						      TypeManager.CSharpName (Parameters.Types [i]),
						      TypeManager.CSharpName (invoke_pd.Types [i]));
					error = true;
				}
			}

			return !error;
		}
コード例 #55
0
ファイル: parameter.cs プロジェクト: afaerber/mono
		ParametersImported (AParametersCollection param, TypeSpec[] types)
		{
			this.parameters = param.FixedParameters;
			this.types = types;
			has_arglist = param.HasArglist;
			has_params = param.HasParams;
		}