• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Emit.SignatureHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Reflection.Emit.SignatureHelper的典型用法代码示例。如果您正苦于以下问题:C# SignatureHelper类的具体用法?C# SignatureHelper怎么用?C# SignatureHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SignatureHelper类属于System.Reflection.Emit命名空间,在下文中一共展示了SignatureHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SymbolMethod

        //***********************************************
        //
        // Constructor
        // 
        //***********************************************
        internal SymbolMethod(
            ModuleBuilder mod,
            MethodToken token,
            Type        arrayClass, 
            String      methodName, 
            CallingConventions callingConvention,
            Type        returnType,
            Type[]      parameterTypes)

        {
            m_module = mod;
            m_containingType = arrayClass;
            m_name = methodName;
            m_callingConvention = callingConvention;
            m_returnType = returnType;
            m_mdMethod = token;
            if (parameterTypes != null)
            {
                m_parameterTypes = new Type[parameterTypes.Length];
                Array.Copy(parameterTypes, m_parameterTypes, parameterTypes.Length);
            }
            else
                m_parameterTypes = null;    
            m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, returnType, parameterTypes);
        }
开发者ID:ArildF,项目名称:masters,代码行数:30,代码来源:symbolmethod.cs


示例2: SymbolMethod

        internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName, 
            CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
        {
            // This is a kind of MethodInfo to represent methods for array type of unbaked type

            // Another way to look at this class is as a glorified MethodToken wrapper. At the time of this comment
            // this class is only constructed inside ModuleBuilder.GetArrayMethod and the only interesting thing 
            // passed into it is this MethodToken. The MethodToken was forged using a TypeSpec for an Array type and
            // the name of the method on Array. 
            // As none of the methods on Array have CustomModifiers their is no need to pass those around in here.
            m_mdMethod = token;

            // The ParameterTypes are also a bit interesting in that they may be unbaked TypeBuilders.
            m_returnType = returnType;
            if (parameterTypes != null)
            {
                m_parameterTypes = new Type[parameterTypes.Length];
                Array.Copy(parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length);
            }
            else
            {
                m_parameterTypes = EmptyArray<Type>.Value; 
            }
   
            m_module = mod;
            m_containingType = arrayClass;
            m_name = methodName;
            m_callingConvention = callingConvention;

            m_signature = SignatureHelper.GetMethodSigHelper(
                mod, callingConvention, returnType, null, null, parameterTypes, null, null);
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:32,代码来源:SymbolMethod.cs


示例3: PropertyBuilder

 // Constructs a PropertyBuilder.  
 //
 internal PropertyBuilder(
     ModuleBuilder       mod,            // the module containing this PropertyBuilder
     String              name,           // property name
     SignatureHelper     sig,            // property signature descriptor info
     PropertyAttributes  attr,           // property attribute such as DefaultProperty, Bindable, DisplayBind, etc
     Type                returnType,     // return type of the property.
     PropertyToken       prToken,        // the metadata token for this property
     TypeBuilder         containingType) // the containing type
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (name.Length == 0)
         throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
     if (name[0] == '\0')
         throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
     Contract.EndContractBlock();
     
     m_name = name;
     m_moduleBuilder = mod;
     m_signature = sig;
     m_attributes = attr;
     m_returnType = returnType;
     m_prToken = prToken;
     m_tkProperty = prToken.Token;
     m_containingType = containingType;
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:28,代码来源:PropertyBuilder.cs


示例4: GetMethodSpecSigHelper

 internal static SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst)
 {
     SignatureHelper sigHelp = new SignatureHelper(scope, MdSigCallingConvention.GenericInst);
     sigHelp.AddData(inst.Length);
     foreach(Type t in inst)
         sigHelp.AddArgument(t);
     return sigHelp;
 }
开发者ID:kouvel,项目名称:coreclr,代码行数:8,代码来源:SignatureHelper.cs


示例5: PropertyBuilder

 internal PropertyBuilder(ModuleBuilder mod, string name, SignatureHelper sig, PropertyAttributes attr, Type returnType, System.Reflection.Emit.PropertyToken prToken, TypeBuilder containingType)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
     }
     if (name[0] == '\0')
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
     }
     this.m_name = name;
     this.m_moduleBuilder = mod;
     this.m_signature = sig;
     this.m_attributes = attr;
     this.m_returnType = returnType;
     this.m_prToken = prToken;
     this.m_tkProperty = prToken.Token;
     this.m_containingType = containingType;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:PropertyBuilder.cs


示例6: ILGenerator

 internal ILGenerator(MethodInfo methodBuilder, int size)
 {
     if (size < 0x10)
     {
         this.m_ILStream = new byte[0x10];
     }
     else
     {
         this.m_ILStream = new byte[size];
     }
     this.m_length = 0;
     this.m_labelCount = 0;
     this.m_fixupCount = 0;
     this.m_labelList = null;
     this.m_fixupData = null;
     this.m_exceptions = null;
     this.m_exceptionCount = 0;
     this.m_currExcStack = null;
     this.m_currExcStackCount = 0;
     this.m_RelocFixupList = new int[0x40];
     this.m_RelocFixupCount = 0;
     this.m_RVAFixupList = new int[0x40];
     this.m_RVAFixupCount = 0;
     this.m_ScopeTree = new ScopeTree();
     this.m_LineNumberInfo = new LineNumberInfo();
     this.m_methodBuilder = methodBuilder;
     this.m_localCount = 0;
     MethodBuilder builder = this.m_methodBuilder as MethodBuilder;
     if (builder == null)
     {
         this.m_localSignature = SignatureHelper.GetLocalVarSigHelper(null);
     }
     else
     {
         this.m_localSignature = SignatureHelper.GetLocalVarSigHelper(builder.GetTypeBuilder().Module);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:ILGenerator.cs


示例7: GetSignatureToken

		public SignatureToken GetSignatureToken (SignatureHelper sigHelper)
		{
			if (sigHelper == null)
				throw new ArgumentNullException ("sigHelper");
			return new SignatureToken (GetToken (sigHelper));
		}
开发者ID:carrie901,项目名称:mono,代码行数:6,代码来源:ModuleBuilder.cs


示例8: GetPropertySigHelper

        /// <include file='doc\SignatureHelper.uex' path='docs/doc[@for="SignatureHelper.GetPropertySigHelper"]/*' />
        public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes) 
        {
            SignatureHelper sigHelp;
                
            if (returnType == null)
            {
                returnType = typeof(void);
            }            

            sigHelp = new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_PROPERTY, (Type)returnType);
            
            if (parameterTypes != null)
            {
                for (int i=0; i<parameterTypes.Length; i++) 
                {
                    sigHelp.AddArgument(parameterTypes[i]);
                }
            }
            return sigHelp;
        }
开发者ID:ArildF,项目名称:masters,代码行数:21,代码来源:signaturehelper.cs


示例9: GetMethodSigHelper

        /// <include file='doc\SignatureHelper.uex' path='docs/doc[@for="SignatureHelper.GetMethodSigHelper2"]/*' />
        public static SignatureHelper GetMethodSigHelper(
            Module          mod, 
            CallingConvention unmanagedCallConv, 
            Type            returnType) 
        {
            SignatureHelper sigHelp;
            int             intCall;
                
            if (returnType == null)
            {
                returnType = typeof(void);
            }            

            if (unmanagedCallConv ==  CallingConvention.Cdecl)
                intCall = IMAGE_CEE_UNMANAGED_CALLCONV_C;
            else if (unmanagedCallConv ==  CallingConvention.StdCall)
                intCall = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL;
            else if (unmanagedCallConv ==  CallingConvention.ThisCall)
                intCall = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL;
            else if (unmanagedCallConv ==  CallingConvention.FastCall)
                intCall = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL;
            else
                throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), "unmanagedCallConv");                          
            
            sigHelp = new SignatureHelper(mod, intCall, (Type)returnType);
            
            return sigHelp;
        }
开发者ID:ArildF,项目名称:masters,代码行数:29,代码来源:signaturehelper.cs


示例10: GetToken

		public int GetToken (SignatureHelper helper) {
			return m.AddRef (helper);
		}
开发者ID:saga,项目名称:mono,代码行数:3,代码来源:DynamicMethod.cs


示例11: VarArgMethod

 internal VarArgMethod(RuntimeMethodInfo method, SignatureHelper signature)
 {
     m_method = method;
     m_signature = signature;
 }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:5,代码来源:DynamicILGenerator.cs


示例12: Emit

		public virtual void Emit (OpCode opcode, SignatureHelper signature)
		{
			int token = token_gen.GetToken (signature);
			make_room (6);
			ll_emit (opcode);
			emit_int (token);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:ILGenerator.cs


示例13: Init

        private void Init(String name, MethodAttributes attributes, CallingConventions callingConvention,
            Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
            Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, 
            Module mod, TypeBuilder type, bool bIsGlobalMethod)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (name.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");

            if (name[0] == '\0')
                throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");

            if (mod == null)
                throw new ArgumentNullException("mod");

            if (parameterTypes != null)
            {
                foreach(Type t in parameterTypes)
                {
                    if (t == null)
                        throw new ArgumentNullException("parameterTypes");
                }
            }

            m_link = type.m_currentMethod;
            type.m_currentMethod = this;
            m_strName = name;
            m_module = mod;
            m_containingType = type;
            m_localSignature = SignatureHelper.GetLocalVarSigHelper(mod);

            // 
            //if (returnType == null)
            //{
            //    m_returnType = typeof(void);
            //}
            //else
            {
                m_returnType = returnType;
            }

            if ((attributes & MethodAttributes.Static) == 0)
            {
                // turn on the has this calling convention
                callingConvention = callingConvention | CallingConventions.HasThis;
            }
            else if ((attributes & MethodAttributes.Virtual) != 0)
            {
                // A method can't be both static and virtual
                throw new ArgumentException(Environment.GetResourceString("Arg_NoStaticVirtual"));
            }

            if ((attributes & MethodAttributes.SpecialName) != MethodAttributes.SpecialName)
            {
                if ((type.Attributes & TypeAttributes.Interface) == TypeAttributes.Interface)
                {
                    // methods on interface have to be abstract + virtual except special name methods such as type initializer
                    if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) != 
                        (MethodAttributes.Abstract | MethodAttributes.Virtual) &&                         
                        (attributes & MethodAttributes.Static) == 0)
                        throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));               
                }
            }

            m_callingConvention = callingConvention;

            if (parameterTypes != null)
            {
                m_parameterTypes = new Type[parameterTypes.Length];
                Array.Copy(parameterTypes, m_parameterTypes, parameterTypes.Length);
            }
            else
            {
                m_parameterTypes = null;
            }

            m_returnTypeRequiredCustomModifiers = returnTypeRequiredCustomModifiers;
            m_returnTypeOptionalCustomModifiers = returnTypeOptionalCustomModifiers;
            m_parameterTypeRequiredCustomModifiers = parameterTypeRequiredCustomModifiers;
            m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers;

//            m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, 
//                returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
//                parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);

            m_iAttributes = attributes;
            m_bIsGlobalMethod = bIsGlobalMethod;
            m_bIsBaked = false;
            m_fInitLocals = true;

            m_localSymInfo = new LocalSymInfo();
            m_ubBody = null;
            m_ilGenerator = null;

            // Default is managed IL. Manged IL has bit flag 0x0020 set off
            m_dwMethodImplFlags = MethodImplAttributes.IL;

            //int i = MetadataTokenInternal;
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:methodbuilder.cs


示例14: GetMethodSignature

        internal SignatureHelper GetMethodSignature()
        {
            if (m_parameterTypes == null)
                m_parameterTypes = new Type[0];

            m_signature = SignatureHelper.GetMethodSigHelper (m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0, 
                m_returnType == null ? typeof(void) : m_returnType, m_returnTypeRequiredCustomModifiers, m_returnTypeOptionalCustomModifiers,
                m_parameterTypes, m_parameterTypeRequiredCustomModifiers, m_parameterTypeOptionalCustomModifiers);

            return m_signature;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:11,代码来源:methodbuilder.cs


示例15: GetMethodSigHelper

        public static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType)
        {
            SignatureHelper sigHelp;
            MdSigCallingConvention intCall;
                
            if (returnType == null)
                returnType = typeof(void);

            if (unmanagedCallConv == CallingConvention.Cdecl)
            {
                intCall = MdSigCallingConvention.C;
            }
            else if (unmanagedCallConv == CallingConvention.StdCall || unmanagedCallConv == CallingConvention.Winapi)
            {
                intCall = MdSigCallingConvention.StdCall;
            }
            else if (unmanagedCallConv == CallingConvention.ThisCall)
            {
                intCall = MdSigCallingConvention.ThisCall;
            }
            else if (unmanagedCallConv == CallingConvention.FastCall)
            {
                intCall = MdSigCallingConvention.FastCall;
            }
            else
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), nameof(unmanagedCallConv));                          
            }
            
            sigHelp = new SignatureHelper(mod, intCall, returnType, null, null);
            
            return sigHelp;
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:33,代码来源:SignatureHelper.cs


示例16: Emit

 public virtual void Emit(OpCode opcode, SignatureHelper signature)
 {
     if (signature == null)
     {
         throw new ArgumentNullException("signature");
     }
     int stackchange = 0;
     ModuleBuilder module = (ModuleBuilder) this.m_methodBuilder.Module;
     int token = module.GetSignatureToken(signature).Token;
     this.EnsureCapacity(7);
     this.InternalEmit(opcode);
     if (opcode.m_pop == StackBehaviour.Varpop)
     {
         stackchange -= signature.ArgumentCount;
         stackchange--;
         this.UpdateStackSize(opcode, stackchange);
     }
     this.RecordTokenFixup();
     this.PutInteger4(token);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:ILGenerator.cs


示例17: GetToken

		internal int GetToken (SignatureHelper helper) {
			return getToken (this, helper, true);
		}
开发者ID:carrie901,项目名称:mono,代码行数:3,代码来源:ModuleBuilder.cs


示例18: GetSignatureToken

        [System.Security.SecuritySafeCritical]  // auto-generated
        public SignatureToken GetSignatureToken(SignatureHelper sigHelper)
        {
            // Define signature token given a signature helper. This will define a metadata
            // token for the signature described by SignatureHelper.

            if (sigHelper == null)
            {
                throw new ArgumentNullException("sigHelper");
            }
            Contract.EndContractBlock();

            int sigLength;
            byte[] sigBytes;
    
            // get the signature in byte form
            sigBytes = sigHelper.InternalGetSignature(out sigLength);
            return new SignatureToken(TypeBuilder.GetTokenFromSig(GetNativeHandle(), sigBytes, sigLength), this);
        }           
开发者ID:crummel,项目名称:dotnet_coreclr,代码行数:19,代码来源:ModuleBuilder.cs


示例19: Emit

        public virtual void Emit(OpCode opcode, SignatureHelper signature)
        {
            if (signature == null)
                throw new ArgumentNullException("signature");
            Contract.EndContractBlock();

            int stackchange = 0;
            ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
            SignatureToken sig = modBuilder.GetSignatureToken(signature);

            int tempVal = sig.Token;

            EnsureCapacity(7);
            InternalEmit(opcode);

            // The only IL instruction that has VarPop behaviour, that takes a
            // Signature token as a parameter is calli.  Pop the parameters and
            // the native function pointer.  To be conservative, do not pop the
            // this pointer since this information is not easily derived from
            // SignatureHelper.
            if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
            {
                Contract.Assert(opcode.Equals(OpCodes.Calli),
                                "Unexpected opcode encountered for StackBehaviour VarPop.");
                // Pop the arguments..
                stackchange -= signature.ArgumentCount;
                // Pop native function pointer off the stack.
                stackchange--;
                UpdateStackSize(opcode, stackchange);
            }

            RecordTokenFixup();
            PutInteger4(tempVal);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:34,代码来源:ilgenerator.cs


示例20: GetMethodSigHelper

		internal static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions callingConvention, CallingConvention unmanagedCallingConvention, Type returnType,
														   Type [] parameters)
		{
			if (mod != null && !(mod is ModuleBuilder))
				throw new ArgumentException ("ModuleBuilder is expected");

			if (returnType == null)
				returnType = typeof (void);

			if (returnType.IsUserType)
				throw new NotSupportedException ("User defined subclasses of System.Type are not yet supported.");
			if (parameters != null) {
				for (int i = 0; i < parameters.Length; ++i)
					if (parameters [i].IsUserType)
						throw new NotSupportedException ("User defined subclasses of System.Type are not yet supported.");

			}

			SignatureHelper helper = 
				new SignatureHelper ((ModuleBuilder)mod, SignatureHelperType.HELPER_METHOD);
			helper.returnType = returnType;
			helper.callConv = callingConvention;
			helper.unmanagedCallConv = unmanagedCallingConvention;

			if (parameters != null) {
				helper.arguments = new Type [parameters.Length];
				for (int i = 0; i < parameters.Length; ++i)
					helper.arguments [i] = parameters [i];
			}

			return helper;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:32,代码来源:SignatureHelper.cs



注:本文中的System.Reflection.Emit.SignatureHelper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Emit.TypeBuilder类代码示例发布时间:2022-05-26
下一篇:
C# Emit.PropertyBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap