Fixed bug where regexps were not callable across contexts since the
callable test used object identity on the regexp constructor. Changed
typeof RegExp from 'object' to 'function' for compatibility.
Review URL: http://codereview.chromium.org/171039
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2696
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
// Regular expressions can be called as functions in both Firefox
// and Safari so we allow it too.
- bool is_regexp =
- object->IsHeapObject() &&
- (HeapObject::cast(*object)->map()->constructor() ==
- *Top::regexp_function());
-
- if (is_regexp) {
+ if (object->IsJSRegExp()) {
Handle<String> exec = Factory::exec_symbol();
return Handle<Object>(object->GetProperty(*exec));
}
}
ASSERT(heap_obj->IsUndefined());
return Heap::undefined_symbol();
- case JS_FUNCTION_TYPE:
+ case JS_FUNCTION_TYPE: case JS_REGEXP_TYPE:
return Heap::function_symbol();
default:
// For any kind of object not handled above, the spec rule for
js1_2/regexp/endLine: FAIL_OK
+# To be compatible with safari typeof a regexp yields 'function';
+# in firefox it yields 'object'.
+js1_2/function/regexparg-1: FAIL_OK
+
+
# Date trouble?
js1_5/Date/regress-301738-02: FAIL_OK