Serge, Thanks much for the explanations. As for question 5, please check the book's appendix C "IL Instruction Set Reference", look up the entry for 'mkrefany', the last (Push) column says '*'. ----- Original Message ----- From: Serge Lidin<mailto:[EMAIL PROTECTED]> To: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> Sent: Thursday, September 09, 2004 2:52 PM Subject: Re: [ADVANCED-DOTNET] ilasm questions
Please see inline... Thanks, Serge -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Tony Hal Sent: Thursday, September 09, 2004 1:28 PM To: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> Subject: [ADVANCED-DOTNET] ilasm questions Hi, I have various questions on ilasm: 1. 'beforefieldinit' attr seems to be always used for class without static ctor (.cctor). For type with static ctor, then it must not be used. Is this a correct assumption ? [SL] No it is not. "beforefieldinit" means "initialize before any static field is accessed", as opposed to default "initialize before any static field or method is accessed". Since running a .cctor represents the initialization, "beforefieldinit" flag really has no bearing on presence or absence of .cctor, but rather specifies when the .cctor is run if present. 2. What's really the purpose of 'preservesig' ? The spec says something about HRESULT retval, but this is always used for any retval type in pinvokeimpl. It seems all pinvokeimpl declarations use it, regardless the return type of the unmanaged method. [SL] If "preservesig" is not specified, the COM interop will change the COM method signature from HRESULT(...) to void(...), and if HRESULT is an error, an exception is thrown. If HRESULT is a success, no exception is thrown. So if you want to distinguish between S_OK and S_FALSE, better don't forget to specify "preservesig". 3. I don't quite understand the use for fault handler. What C# exception construct is related to this ? [SL] Fault handler is executed when any exception is thrown within the guarded block (see "Processing the Exceptions" on p.281 of the ILASM book). No Microsoft language except ILASM supports try-fault constructs. 4. Why does 'refanyval' opcode require the token param ? The 'refanytype' opcode does not need it. It seems having the typederf operand on the stack is sufficient [SL] "refanyval" requires token to indicate the type placed on the stack by this operation. Without it, the stack state would become unknown, and "refanyval" would be unverifiable in principle. "refanytype" doesn't require it, because it always puts a type handle on the stack. 5. What's the internal type used by eval stack to hold typedref data ? Specifically the result of mkrefany is of such type. Serge's book says the type is '*' which is for any type, but it seems it should be native unsigned int since it's some sort of opaque handle. [SL] You are correct, "opaque handle" == native int. I can't find the place in the book you refer to, where did you see it? Thanks =================================== This list is hosted by DevelopMentorŪ http://www.develop.com<http://www.develop.com/> Some .NET courses you may be interested in: Essential .NET: building applications and components with CSharp August 30 - September 3, in Los Angeles http://www.develop.com/courses/edotnet<http://www.develop.com/courses/edotnet> View archives and manage your subscription(s) at http://discuss.develop.com<http://discuss.develop.com/> =================================== This list is hosted by DevelopMentorŪ http://www.develop.com<http://www.develop.com/> Some .NET courses you may be interested in: Essential .NET: building applications and components with CSharp August 30 - September 3, in Los Angeles http://www.develop.com/courses/edotnet<http://www.develop.com/courses/edotnet> View archives and manage your subscription(s) at http://discuss.develop.com<http://discuss.develop.com/> =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with CSharp August 30 - September 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com