RegExp tweaks

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
parent 910b5ef3
......@@ -174,12 +174,7 @@ Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
// 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));
}
......
......@@ -3099,7 +3099,7 @@ static Object* Runtime_Typeof(Arguments args) {
}
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
......
......@@ -278,6 +278,11 @@ js1_2/regexp/beginLine: FAIL_OK
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
......
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