Thank you very much Alex, you've been a great deal of help! Just a final stupid question: what is VES?
2011/6/27 Alex <[email protected]> > Hi, > > >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 > > On Mon, Jun 27, 2011 at 4:17 PM, Gábor Kozár <[email protected]> wrote: > > So char, the integer types and bool are all interchangable? > > 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? > > Thanks for the book recommendation, I have ordered it! :) > > 2011/6/26 Alex <[email protected]> > >> > >> 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 > > > > -- > > -- > > mono-cecil > > -- > -- > mono-cecil -- -- mono-cecil
