>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
> --
> --
> mono-cecil
--
--
mono-cecil
>So char, the integer types and bool are all interchangable?
Technically, yes. The CLR treats bools and chars as 32-bit integers
(even if a char really is only 16 bits and a bool 8 bits).
>How about the 'ceq' instruction? Does it only work on the types above (lets call them 'numeric types'), or does it have some magic way of comparing other types?
All such instructions only operate on primitive types that the VES
knows how to compare. Object.Equals(), IEquatable<T>, etc are all
independent of CIL and must be called manually.
Regards,
Alex
> --
> --
> mono-cecil
--
--
mono-cecil
Just a fancy ECMA 335 abbreviation for Virtual Execution System (i.e.
the runtime). :)
Regards,
Alex
> --
> --
> mono-cecil