[Mono-devel-list] Re: emitting a MethodInfo instance
Valient Gough
valient at gmail.com
Mon May 30 18:24:50 EDT 2005
On 5/30/05, Valient Gough <valient at gmail.com> wrote:
> void Emit_MethodInfo( ILGenerator ig, MethodInfo method )
>
> It looks like it could be done by emitting code which looks something
> like "typeof([type]).GetMethod([name], [args])", but that is
> non-trivial and is not efficient:
Forgot to add, my first guess was actually to use OpCode.Ldtoken to
directly load MethodInfo, because I found the following snippet in
msdn online docs for OpCodes.LdToken:
The following Emit constructor overloads can use the ldtoken opcode:
* ILGenerator.Emit(OpCode, MethodInfo)
* ILGenerator.Emit(OpCode, FieldInfo)
* ILGenerator.Emit(OpCode, Type)
However, when I try and emit (OpCode.Ldtoken, MethodInfo), that causes
the ILGenerator to halt in mid-opcode, and monodis shows that last
opcode as "ldtoken" with no args.. Perhaps ILGenerator.Emit(OpCode,
MethodInfo) only works in mono 1.1.7 where OpCode == OpCode.Call* ?
Valient
More information about the Mono-devel-list
mailing list