Add better handling of messages returning floating point values sent to nil.

main
theraven 14 years ago
parent 0eeff38f1b
commit f059be5337

@ -10,8 +10,14 @@
void objc_send_initialize(id object);
static long long nil_method(id self, SEL _cmd) { return 0; }
static long double nil_method_D(id self, SEL _cmd) { return 0; }
static double nil_method_d(id self, SEL _cmd) { return 0; }
static float nil_method_f(id self, SEL _cmd) { return 0; }
static struct objc_slot nil_slot = { Nil, Nil, 0, 1, (IMP)nil_method };
static struct objc_slot nil_slot_D = { Nil, Nil, 0, 1, (IMP)nil_method_D };
static struct objc_slot nil_slot_d = { Nil, Nil, 0, 1, (IMP)nil_method_d };
static struct objc_slot nil_slot_f = { Nil, Nil, 0, 1, (IMP)nil_method_f };
typedef struct objc_slot *Slot_t;
@ -134,6 +140,23 @@ Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender)
// inlined trivially.
if (UNLIKELY(*receiver == nil))
{
// Return the correct kind of zero, depending on the type encoding.
if (selector->types)
{
const char *t = selector->types;
// Skip type qualifiers
while ('r' == *t || 'n' == *t || 'N' == *t || 'o' == *t ||
'O' == *t || 'R' == *t || 'V' == *t)
{
t++;
}
switch (selector->types[0])
{
case 'D': return &nil_slot_D;
case 'd': return &nil_slot_d;
case 'f': return &nil_slot_f;
}
}
return &nil_slot;
}

Loading…
Cancel
Save