如何使用DefineMethodSpec来定义IL中调用的泛型方法实例

编程入门 行业动态 更新时间:2024-10-28 09:21:37
本文介绍了如何使用DefineMethodSpec来定义IL中调用的泛型方法实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用通用方法。更清楚的是,当jit compile start时,我想写IL来调用检测的泛型方法。但现在我不知道如何定义可以在IL中调用的泛型方法。我知道需要使用 DefineMethodSpec 来定义methodspec。但如何使用 DefineMethodSpec?如何设置参数 pvSigBlob for DefineMethodSpec?

解决方案

首先,使用 IMetaDataEmit :: DefineMethod 方法(签名的格式在ECMA-335 Partition II Section 23.2.1中定义)。

接下来,使用DefineMethodSpec创建一个元数据标记,它将您刚定义的方法与您想要的泛型类型参数组合在一起(签名的格式在ECMA-335 Partition II Section 23.2.15中定义) )。

传入DefineMethod的RVA是通过 IMethodMalloc.Alloc ,格式在ECMA-335 Partition II Section 25.4.2和25.4.3中定义。

Hi,

i need to instrument generic method. Be more clearly i want to write IL to call the instrumented generic method when jit compile start. but now i don't know how to define a generic method that can be called in the IL. i know it need to useDefineMethodSpec to define the methodspec. but how to useDefineMethodSpec? how to setup the parameterpvSigBlob for DefineMethodSpec?

解决方案

First, create the generic method definition using IMetaDataEmit::DefineMethod Method (the format of the signature is defined in ECMA-335 Partition II Section 23.2.1).

Next, use DefineMethodSpec to create a metadata token that combines the method you just defined with the generic type arguments you want (the format of the signature is defined in ECMA-335 Partition II Section 23.2.15).

The RVA passed into DefineMethod is allocated via IMethodMalloc.Alloc and the format is defined in ECMA-335 Partition II Sections 25.4.2 and 25.4.3.

更多推荐

如何使用DefineMethodSpec来定义IL中调用的泛型方法实例

本文发布于:2023-11-17 03:40:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608690.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   实例   定义   方法   DefineMethodSpec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!