Commit 3bf8a26b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Reenable int, float, and long constructor ICs

Special case {int,float,long}.__new__({int,float,str}) for
rewriting.
parent fbb60a45
...@@ -116,7 +116,8 @@ extern "C" Box* abs_(Box* x) { ...@@ -116,7 +116,8 @@ extern "C" Box* abs_(Box* x) {
return longAbs(static_cast<BoxedLong*>(x)); return longAbs(static_cast<BoxedLong*>(x));
} else { } else {
static const std::string abs_str("__abs__"); static const std::string abs_str("__abs__");
return callattr(x, &abs_str, CallattrFlags({.cls_only = true }), ArgPassSpec(0), NULL, NULL, NULL, NULL, NULL); return callattr(x, &abs_str, CallattrFlags({.cls_only = true, .null_on_nonexistent = false }), ArgPassSpec(0),
NULL, NULL, NULL, NULL, NULL);
} }
} }
......
...@@ -3474,6 +3474,13 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp ...@@ -3474,6 +3474,13 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
} }
} }
if (!ok && (cls == int_cls || cls == float_cls || cls == long_cls)) {
if (npassed_args == 1)
ok = true;
else if (npassed_args == 2 && (arg2->cls == int_cls || arg2->cls == str_cls || arg2->cls == float_cls))
ok = true;
}
if (!ok) { if (!ok) {
// Uncomment this to try to find __new__ functions that we could either white- or blacklist: // Uncomment this to try to find __new__ functions that we could either white- or blacklist:
// ASSERT(cls->is_user_defined || cls == type_cls, "Does '%s' have a well-behaved __new__? if so, add to // ASSERT(cls->is_user_defined || cls == type_cls, "Does '%s' have a well-behaved __new__? if so, add to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment