OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
8 | 8 |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 // Imports | 10 // Imports |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 function RegExpToString() { | 272 function RegExpToString() { |
273 if (!IS_REGEXP(this)) { | 273 if (!IS_REGEXP(this)) { |
274 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; | 274 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; |
275 // a UseCounter is incremented to track it. | 275 // a UseCounter is incremented to track it. |
276 // TODO(littledan): Remove this workaround or standardize it | 276 // TODO(littledan): Remove this workaround or standardize it |
277 if (this === GlobalRegExpPrototype) { | 277 if (this === GlobalRegExpPrototype) { |
278 %IncrementUseCounter(kRegExpPrototypeToString); | 278 %IncrementUseCounter(kRegExpPrototypeToString); |
279 return '/(?:)/'; | 279 return '/(?:)/'; |
280 } | 280 } |
281 throw MakeTypeError(kIncompatibleMethodReceiver, | 281 if (!IS_RECEIVER(this)) { |
282 'RegExp.prototype.toString', this); | 282 throw MakeTypeError( |
| 283 kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this); |
| 284 } |
| 285 return '/' + TO_STRING(this.pattern()) + '/' + TO_STRING(this.flags()); |
283 } | 286 } |
284 var result = '/' + REGEXP_SOURCE(this) + '/'; | 287 var result = '/' + REGEXP_SOURCE(this) + '/'; |
285 if (REGEXP_GLOBAL(this)) result += 'g'; | 288 if (REGEXP_GLOBAL(this)) result += 'g'; |
286 if (REGEXP_IGNORE_CASE(this)) result += 'i'; | 289 if (REGEXP_IGNORE_CASE(this)) result += 'i'; |
287 if (REGEXP_MULTILINE(this)) result += 'm'; | 290 if (REGEXP_MULTILINE(this)) result += 'm'; |
288 if (REGEXP_UNICODE(this)) result += 'u'; | 291 if (REGEXP_UNICODE(this)) result += 'u'; |
289 if (REGEXP_STICKY(this)) result += 'y'; | 292 if (REGEXP_STICKY(this)) result += 'y'; |
290 return result; | 293 return result; |
291 } | 294 } |
292 | 295 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 // Exports | 753 // Exports |
751 | 754 |
752 utils.Export(function(to) { | 755 utils.Export(function(to) { |
753 to.RegExpExec = DoRegExpExec; | 756 to.RegExpExec = DoRegExpExec; |
754 to.RegExpExecNoTests = RegExpExecNoTests; | 757 to.RegExpExecNoTests = RegExpExecNoTests; |
755 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 758 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
756 to.RegExpTest = RegExpTest; | 759 to.RegExpTest = RegExpTest; |
757 }); | 760 }); |
758 | 761 |
759 }) | 762 }) |
OLD | NEW |