From 04a6340227b371c984132c1cb72baf490a5b0499 Mon Sep 17 00:00:00 2001 From: "christian.plesner.hansen@gmail.com" Date: Mon, 17 Aug 2009 10:19:00 +0000 Subject: [PATCH] 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 --- src/execution.cc | 7 +------ src/runtime.cc | 2 +- test/mozilla/mozilla.status | 5 +++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/execution.cc b/src/execution.cc index 4ab6b61..9080f5e 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -174,12 +174,7 @@ Handle Execution::GetFunctionDelegate(Handle 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 exec = Factory::exec_symbol(); return Handle(object->GetProperty(*exec)); } diff --git a/src/runtime.cc b/src/runtime.cc index 5518d15..36fdd65 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -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 diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status index e2de2ef..a1551dc 100644 --- a/test/mozilla/mozilla.status +++ b/test/mozilla/mozilla.status @@ -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 -- 2.7.4