Hello,

>So apparently, the int32 value of '1' is bool 'true' as far as CIL is 
>concerned. So what are the rules here? Are there any other such 'implicit 
>conversions' I should be aware of?

The only other case I can think of is 'char'.

>Another thing that's not quite clear for me are the 'add', 'div', 'rem', 'clt' 
>etc. instructions, specifically, the values they use. Do they work only on 
>Int32? What happens if they get Int16 or Int64?

In CIL, types are not encoded in instructions, but rather in local
variables, parameters, fields, etc. So, the instructions you mention
operate on both integers and floats (don't misunderstand; they're
still type-safe).

>Is there a site or a tutorial or a book, or whatever that can teach me CIL? I 
>did some searches, but only found some very basic examples - nothing too 
>useful.

I would recommend Expert .NET 2.0 IL Assembler and generally ECMA 335
Partition II and III.

Regards,
Alex

On Sun, Jun 26, 2011 at 5:19 PM, Gábor Kozár <[email protected]> wrote:
> Hey,
>
> I'm writing a stack analyzer using Mono.Cecil: ideally it should be able to
> tell me what is on the evaluation stack at the given instruction of a method
> body.
> For this, I need to be able to tell the type of the values pushed to /
> pulled from the evaluation stack by the instructions.
> This is mostly fine, however, there are some things around the native CIL
> types that are confusing.
> For example, when I write this in C#:
> return true;
> this is the CIL emitted:
> ldc.i4.1
> ret
> So apparently, the int32 value of '1' is bool 'true' as far as CIL is
> concerned. So what are the rules here? Are there any other such 'implicit
> conversions' I should be aware of?
> Another thing that's not quite clear for me are the 'add', 'div', 'rem',
> 'clt' etc. instructions, specifically, the values they use. Do they work
> only on Int32? What happens if they get Int16 or Int64?
> Is there a site or a tutorial or a book, or whatever that can teach me CIL?
> I did some searches, but only found some very basic examples - nothing too
> useful.
> Thank you very much!
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to