| 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 this.source is an empty string, output /(?:)/. | 281 var result = '/' + this.source + '/'; |
| 282 // http://bugzilla.mozilla.org/show_bug.cgi?id=225550 | |
| 283 // ecma_2/RegExp/properties-001.js. | |
| 284 var src = this.source ? this.source : '(?:)'; | |
| 285 var result = '/' + src + '/'; | |
| 286 if (this.global) result += 'g'; | 282 if (this.global) result += 'g'; |
| 287 if (this.ignoreCase) result += 'i'; | 283 if (this.ignoreCase) result += 'i'; |
| 288 if (this.multiline) result += 'm'; | 284 if (this.multiline) result += 'm'; |
| 289 return result; | 285 return result; |
| 290 } | 286 } |
| 291 | 287 |
| 292 | 288 |
| 293 // Getters for the static properties lastMatch, lastParen, leftContext, and | 289 // Getters for the static properties lastMatch, lastParen, leftContext, and |
| 294 // rightContext of the RegExp constructor. The properties are computed based | 290 // rightContext of the RegExp constructor. The properties are computed based |
| 295 // on the captures array of the last successful match and the subject string | 291 // on the captures array of the last successful match and the subject string |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 NoOpSetter, DONT_ENUM | DONT_DELETE); | 473 NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 478 | 474 |
| 479 for (var i = 1; i < 10; ++i) { | 475 for (var i = 1; i < 10; ++i) { |
| 480 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 476 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 481 RegExpMakeCaptureGetter(i), NoOpSetter, | 477 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 482 DONT_DELETE); | 478 DONT_DELETE); |
| 483 } | 479 } |
| 484 } | 480 } |
| 485 | 481 |
| 486 SetUpRegExp(); | 482 SetUpRegExp(); |
| OLD | NEW |