コード例 #1
0
        protected internal override CallingConventions GetFunctionCallingConvention(StaticFunctionWrapper function)
        {
            MethodDefinition   methodHandle = (MethodDefinition)function.Handle;
            CallingConventions flags        = 0;

            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, CallingConventions.HasThis, methodHandle.HasThis);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, CallingConventions.ExplicitThis, methodHandle.ExplicitThis);

            switch (methodHandle.CallingConvention)
            {
            case MethodCallingConvention.VarArg:
                flags |= CallingConventions.VarArgs;
                break;

            case MethodCallingConvention.ThisCall:
                break;

            default:
                flags |= CallingConventions.Standard;
                break;
            }

            return(flags);
        }
コード例 #2
0
 /// <summary>
 /// Gets the parameters of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The parameters.</returns>
 protected internal abstract IList<StaticParameterWrapper> GetFunctionParameters(StaticFunctionWrapper function);
コード例 #3
0
 /// <summary>
 /// Gets the calling conventions of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The function calling conventions.</returns>
 protected internal abstract CallingConventions GetFunctionCallingConvention(StaticFunctionWrapper function);
コード例 #4
0
 /// <summary>
 /// Gets the attributes of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The function attributes.</returns>
 protected internal abstract MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function);
コード例 #5
0
        protected override IList<StaticParameterWrapper> GetFunctionParameters(StaticFunctionWrapper function)
        {
            IFunction functionHandle = (IFunction)function.Handle;
            if (!functionHandle.IsValid())
                return EmptyArray<StaticParameterWrapper>.Instance;

            return GenericCollectionUtils.ConvertAllToArray<IParameter, StaticParameterWrapper>(functionHandle.Parameters, delegate(IParameter parameter)
            {
                return new StaticParameterWrapper(this, parameter, function);
            });
        }
コード例 #6
0
        protected override CallingConventions GetFunctionCallingConvention(StaticFunctionWrapper function)
        {
            IFunction functionHandle = (IFunction)function.Handle;

            // FIXME: No way to determine VarArgs convention.
            CallingConventions flags = CallingConventions.Standard;
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, CallingConventions.HasThis, !functionHandle.IsStatic);
            return flags;
        }
コード例 #7
0
        protected override MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function)
        {
            IFunction functionHandle = (IFunction)function.Handle;

            AccessRights accessRights = functionHandle.GetAccessRights();
            if (functionHandle is DefaultConstructor && function.DeclaringType.IsAbstract)
                accessRights = AccessRights.PROTECTED;

            MethodAttributes flags = 0;
            switch (accessRights)
            {
                case AccessRights.PUBLIC:
                    flags |= MethodAttributes.Public;
                    break;
                case AccessRights.NONE:
                case AccessRights.PRIVATE:
                    flags |= MethodAttributes.Private;
                    break;
                case AccessRights.INTERNAL:
                    flags |= MethodAttributes.Assembly;
                    break;
                case AccessRights.PROTECTED:
                    flags |= MethodAttributes.Family;
                    break;
                case AccessRights.PROTECTED_AND_INTERNAL:
                    flags |= MethodAttributes.FamANDAssem;
                    break;
                case AccessRights.PROTECTED_OR_INTERNAL:
                    flags |= MethodAttributes.FamORAssem;
                    break;
            }

            bool isVirtual = functionHandle.IsVirtual || functionHandle.IsAbstract || functionHandle.IsOverride;
            if (!isVirtual)
            {
                IOverridableMember overridableMember = functionHandle as IOverridableMember;
                if (overridableMember != null && overridableMember.IsExplicitImplementation)
                    isVirtual = true;
            }

            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.Abstract, functionHandle.IsAbstract);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.Final, isVirtual && ! CanBeOverriden(functionHandle));
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.Static, functionHandle.IsStatic);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.Virtual, isVirtual);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.NewSlot, isVirtual && !functionHandle.IsOverride);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, MethodAttributes.HideBySig, true); //FIXME unreliable: functionHandle.HidePolicy == MemberHidePolicy.HIDE_BY_SIGNATURE);
            return flags;
        }
コード例 #8
0
 /// <summary>
 /// Gets the parameters of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The parameters.</returns>
 protected internal abstract IList <StaticParameterWrapper> GetFunctionParameters(StaticFunctionWrapper function);
コード例 #9
0
 /// <summary>
 /// Gets the calling conventions of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The function calling conventions.</returns>
 protected internal abstract CallingConventions GetFunctionCallingConvention(StaticFunctionWrapper function);
コード例 #10
0
 /// <summary>
 /// Gets the attributes of a function.
 /// </summary>
 /// <param name="function">The function, not null.</param>
 /// <returns>The function attributes.</returns>
 protected internal abstract MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function);
コード例 #11
0
        protected internal override IList <StaticParameterWrapper> GetFunctionParameters(StaticFunctionWrapper function)
        {
            MethodDefinition methodHandle = (MethodDefinition)function.Handle;

            return(CollectionUtils.ConvertAllToArray <ParameterDefinition, StaticParameterWrapper>(methodHandle.Parameters, delegate(ParameterDefinition parameter)
            {
                return new StaticParameterWrapper(this, parameter, function);
            }));
        }
コード例 #12
0
        protected internal override MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function)
        {
            MethodDefinition methodHandle = (MethodDefinition)function.Handle;

            return((MethodAttributes)methodHandle.Attributes);
        }
コード例 #13
0
 protected internal override IList<StaticParameterWrapper> GetFunctionParameters(StaticFunctionWrapper function)
 {
     MethodDefinition methodHandle = (MethodDefinition)function.Handle;
     return CollectionUtils.ConvertAllToArray<ParameterDefinition, StaticParameterWrapper>(methodHandle.Parameters, delegate(ParameterDefinition parameter)
     {
         return new StaticParameterWrapper(this, parameter, function);
     });
 }
コード例 #14
0
        protected internal override CallingConventions GetFunctionCallingConvention(StaticFunctionWrapper function)
        {
            MethodDefinition methodHandle = (MethodDefinition)function.Handle;
            CallingConventions flags = 0;
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, CallingConventions.HasThis, methodHandle.HasThis);
            ReflectorFlagsUtils.AddFlagIfTrue(ref flags, CallingConventions.ExplicitThis, methodHandle.ExplicitThis);

            switch (methodHandle.CallingConvention)
            {
                case MethodCallingConvention.VarArg:
                    flags |= CallingConventions.VarArgs;
                    break;
                case MethodCallingConvention.ThisCall:
                    break;
                default:
                    flags |= CallingConventions.Standard;
                    break;
            }

            return flags;
        }
コード例 #15
0
 protected internal override MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function)
 {
     MethodDefinition methodHandle = (MethodDefinition)function.Handle;
     return (MethodAttributes)methodHandle.Attributes;
 }