Changeset 89946 in webkit
- Timestamp:
- Jun 28, 2011, 11:35:37 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/regex/constructor-expected.txt (added)
-
LayoutTests/fast/regex/constructor.html (added)
-
LayoutTests/fast/regex/script-tests/constructor.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/RegExpConstructor.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/RegExpConstructor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r89936 r89946 1 2011-06-28 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 https://bugs.webkit.org/show_bug.cgi?id=55040 6 RegExp constructor returns the argument regexp instead of a new object 7 8 Per 15.10.3.1, our current behaviour is correct if called as a function, 9 but incorrect when called as a constructor. 10 11 * fast/regex/constructor-expected.txt: Added. 12 * fast/regex/constructor.html: Added. 13 * fast/regex/script-tests/constructor.js: Added. 14 1 15 2011-06-28 Jessie Berlin <jberlin@apple.com> 2 16 -
trunk/Source/JavaScriptCore/ChangeLog
r89943 r89946 1 2011-06-28 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 https://bugs.webkit.org/show_bug.cgi?id=55040 6 RegExp constructor returns the argument regexp instead of a new object 7 8 Per 15.10.3.1, our current behaviour is correct if called as a function, 9 but incorrect when called as a constructor. 10 11 * runtime/RegExpConstructor.cpp: 12 (JSC::constructRegExp): 13 (JSC::constructWithRegExpConstructor): 14 * runtime/RegExpConstructor.h: 15 1 16 2011-06-28 Luke Macpherson <macpherson@chromium.org> 2 17 -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
r87445 r89946 294 294 295 295 // ECMA 15.10.4 296 JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args )296 JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, bool callAsConstructor) 297 297 { 298 298 JSValue arg0 = args.at(0); … … 302 302 if (!arg1.isUndefined()) 303 303 return throwError(exec, createTypeError(exec, "Cannot supply flags when constructing one RegExp from another.")); 304 // If called as a function, this just returns the first argument (see 15.10.3.1). 305 if (callAsConstructor) { 306 RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp(); 307 return new (exec) RegExpObject(globalObject, globalObject->regExpStructure(), regExp); 308 } 304 309 return asObject(arg0); 305 310 } … … 327 332 { 328 333 ArgList args(exec); 329 return JSValue::encode(constructRegExp(exec, asInternalFunction(exec->callee())->globalObject(), args ));334 return JSValue::encode(constructRegExp(exec, asInternalFunction(exec->callee())->globalObject(), args, true)); 330 335 } 331 336 -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h
r87327 r89946 97 97 RegExpConstructor* asRegExpConstructor(JSValue); 98 98 99 JSObject* constructRegExp(ExecState*, JSGlobalObject*, const ArgList& );99 JSObject* constructRegExp(ExecState*, JSGlobalObject*, const ArgList&, bool callAsConstructor = false); 100 100 101 101 inline RegExpConstructor* asRegExpConstructor(JSValue value)
Note:
See TracChangeset
for help on using the changeset viewer.