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); }
/// <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);
/// <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);
/// <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);
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); }); }
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; }
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; }
/// <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);
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); })); }
protected internal override MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function) { MethodDefinition methodHandle = (MethodDefinition)function.Handle; return((MethodAttributes)methodHandle.Attributes); }
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); }); }
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; }
protected internal override MethodAttributes GetFunctionAttributes(StaticFunctionWrapper function) { MethodDefinition methodHandle = (MethodDefinition)function.Handle; return (MethodAttributes)methodHandle.Attributes; }