Fabian Schmied wrote:
>> Since I can't see a reply, I guess my email trying to clear this up has
>> still left you confused :-). Can you maybe be a little more specific
>> about what I need to explain better? I gave some C# code to try and
>> illustrate it already..
>>     
>
> You say you want to emit code like this:
>   
>> ldarga bar
>> call [mscorlib]System.Nullable`1<int>.get_HasValue
>> brtrue LABEL
>> ldstr "bar"
>> ldstr "Yes this is a stupid example"
>> newobj [mscorlib]System.ArgumentNullException
>> throw
>> LABEL: nop
>> // Some stuff goes here
>>     
>
> But you need to substitute Nullable`1<int> with other nullable types, right?
>
> So you can't use this code:
>   
>> this.module.Import(typeof(Nullable<int>).GetProperty("HasValue").GetGetMethod())
>>     
>
> But when emitting the code, you probably know the concrete nullable
> types you want to work with, right? So, if you have nullable type NT
> at the time of emitting code, why not just do this:
>
>   
>> this.module.Import(typeof(NT).GetProperty("HasValue").GetGetMethod())
>>     
>
> ?
>
> I'm probably missing something, but maybe you could elaborate on what it is.
>
> Fabian
>   
Hi Fabian, thanks for your reply.

I can't do what you suggest, though I would love to. The problem is that
I don't know the nullable type at compile time because I am
instrumenting arbitrary user code. Essentially I am trying to create the
equivalent of the Default macro provided in Boo, but for arbitrary .NET
languages. I also can't get the nullable Type object at runtime because
I only have the TypeReference from Cecil, which is hard to change into a
.NET capital T Type.

Cheers,
Max



--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to