On 10 Jul '08, at 8:55 AM, an0 wrote:
But if different return types cause different native code, how could my program still work with the mistaken type(an NSString * returned from the inner message is treated as an NSInteger at the first place, then is passed as an NSString * to the outer message) guessed by compiler?
This isn't a problem because the compiled code doesn't care what type of object a pointer is to. It's just an address in a CPU register.
At the machine-code level there are only a few special types of return values that have to be handled differently:
* floating-point numbers * structs * 64-bit integers (long long)Almost anything else (a pointer or an integral values ≤ 32 bits) gets handled the same way.
If you look through disassembly of your code, you'll see that message- sends get turned into calls of a magic function objc_msgsend. There are a few other functions that handle the special cases above, such as objc_msgsend_stret [for "Structure RETurn".] The compiler has to know which of those functions to generate a call to.
(Disclaimer: The above is true on PPC, and I think it's true on x86 as well, but I'm not so sure, because I'm less familiar with the calling conventions.)
—Jens
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]