OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 regexp_val = | 271 regexp_val = |
272 new $RegExp(SubString(regexp.source, 2, regexp.source.length), | 272 new $RegExp(SubString(regexp.source, 2, regexp.source.length), |
273 (regexp.ignoreCase ? regexp.multiline ? "im" : "i" | 273 (regexp.ignoreCase ? regexp.multiline ? "im" : "i" |
274 : regexp.multiline ? "m" : "")); | 274 : regexp.multiline ? "m" : "")); |
275 } | 275 } |
276 return regexp_val; | 276 return regexp_val; |
277 } | 277 } |
278 | 278 |
279 | 279 |
280 function RegExpToString() { | 280 function RegExpToString() { |
| 281 if (!IS_REGEXP(this)) { |
| 282 throw MakeTypeError('incompatible_method_receiver', |
| 283 ['RegExp.prototype.toString', this]); |
| 284 } |
281 var result = '/' + this.source + '/'; | 285 var result = '/' + this.source + '/'; |
282 if (this.global) result += 'g'; | 286 if (this.global) result += 'g'; |
283 if (this.ignoreCase) result += 'i'; | 287 if (this.ignoreCase) result += 'i'; |
284 if (this.multiline) result += 'm'; | 288 if (this.multiline) result += 'm'; |
285 return result; | 289 return result; |
286 } | 290 } |
287 | 291 |
288 | 292 |
289 // Getters for the static properties lastMatch, lastParen, leftContext, and | 293 // Getters for the static properties lastMatch, lastParen, leftContext, and |
290 // rightContext of the RegExp constructor. The properties are computed based | 294 // rightContext of the RegExp constructor. The properties are computed based |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 NoOpSetter, DONT_ENUM | DONT_DELETE); | 477 NoOpSetter, DONT_ENUM | DONT_DELETE); |
474 | 478 |
475 for (var i = 1; i < 10; ++i) { | 479 for (var i = 1; i < 10; ++i) { |
476 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 480 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
477 RegExpMakeCaptureGetter(i), NoOpSetter, | 481 RegExpMakeCaptureGetter(i), NoOpSetter, |
478 DONT_DELETE); | 482 DONT_DELETE); |
479 } | 483 } |
480 } | 484 } |
481 | 485 |
482 SetUpRegExp(); | 486 SetUpRegExp(); |
OLD | NEW |