| OLD | NEW | 
|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 230     } | 230     } | 
| 231     string = regExpInput; | 231     string = regExpInput; | 
| 232   } | 232   } | 
| 233 | 233 | 
| 234   var s; | 234   var s; | 
| 235   if (IS_STRING(string)) { | 235   if (IS_STRING(string)) { | 
| 236     s = string; | 236     s = string; | 
| 237   } else { | 237   } else { | 
| 238     s = ToString(string); | 238     s = ToString(string); | 
| 239   } | 239   } | 
| 240   var length = s.length; |  | 
| 241 | 240 | 
| 242   var lastIndex = this.lastIndex; | 241   var lastIndex = this.lastIndex; | 
| 243 | 242 | 
| 244   // Conversion is required by the ES5 specification (RegExp.prototype.exec | 243   // Conversion is required by the ES5 specification (RegExp.prototype.exec | 
| 245   // algorithm, step 5) even if the value is discarded for non-global RegExps. | 244   // algorithm, step 5) even if the value is discarded for non-global RegExps. | 
| 246   var i = TO_INTEGER(lastIndex); | 245   var i = TO_INTEGER(lastIndex); | 
| 247 | 246 | 
| 248   var global = this.global; | 247   var global = this.global; | 
| 249   if (global) { | 248   if (global) { | 
| 250     if (i < 0 || i > length) { | 249     if (i < 0 || i > s.length) { | 
| 251       this.lastIndex = 0; | 250       this.lastIndex = 0; | 
| 252       return false; | 251       return false; | 
| 253     } | 252     } | 
| 254   } else { | 253   } else { | 
| 255     i = 0; | 254     i = 0; | 
| 256   } | 255   } | 
| 257 | 256 | 
| 258   // Remove irrelevant preceeding '.*' in a test regexp. The expression | 257   // Remove irrelevant preceeding '.*' in a test regexp. The expression | 
| 259   // checks whether this.source starts with '.*' and that the third | 258   // checks whether this.source starts with '.*' and that the third | 
| 260   // char is not a '?' | 259   // char is not a '?' | 
| 261   if (%_StringCharCodeAt(this.source, 0) == 46 &&  // '.' | 260   if (%_StringCharCodeAt(this.source, 0) == 46 &&  // '.' | 
| 262       %_StringCharCodeAt(this.source, 1) == 42 &&  // '*' | 261       %_StringCharCodeAt(this.source, 1) == 42 &&  // '*' | 
| 263       %_StringCharCodeAt(this.source, 2) != 63) {  // '?' | 262       %_StringCharCodeAt(this.source, 2) != 63) {  // '?' | 
| 264     if (!%_ObjectEquals(regexp_key, this)) { | 263     if (!%_ObjectEquals(regexp_key, this)) { | 
| 265       regexp_key = this; | 264       regexp_key = this; | 
| 266       regexp_val = new $RegExp(this.source.substring(2, this.source.length), | 265       regexp_val = new $RegExp(this.source.substring(2, this.source.length), | 
| 267                                (global ? 'g' : '') | 266                                (global ? 'g' : '') | 
| 268                                + (this.ignoreCase ? 'i' : '') | 267                                + (this.ignoreCase ? 'i' : '') | 
| 269                                + (this.multiline ? 'm' : '')); | 268                                + (this.multiline ? 'm' : '')); | 
| 270     } | 269     } | 
| 271     if (!regexp_val.test(s)) return false; | 270     if (!regexp_val.test(s)) return false; | 
| 272   } | 271   } | 
| 273 | 272 | 
| 274   var length = s.length; |  | 
| 275 |  | 
| 276   if (i < 0 || i > length) { |  | 
| 277     this.lastIndex = 0; |  | 
| 278     return false; |  | 
| 279   } |  | 
| 280 |  | 
| 281   %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); | 273   %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); | 
| 282   // matchIndices is either null or the lastMatchInfo array. | 274   // matchIndices is either null or the lastMatchInfo array. | 
| 283   var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo); | 275   var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo); | 
| 284 | 276 | 
| 285   if (matchIndices === null) { | 277   if (matchIndices === null) { | 
| 286     if (global) this.lastIndex = 0; | 278     if (global) this.lastIndex = 0; | 
| 287     return false; | 279     return false; | 
| 288   } | 280   } | 
| 289   lastMatchInfoOverride = null; | 281   lastMatchInfoOverride = null; | 
| 290   if (global) this.lastIndex = lastMatchInfo[CAPTURE1]; | 282   if (global) this.lastIndex = lastMatchInfo[CAPTURE1]; | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 486   %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 478   %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 
| 487 | 479 | 
| 488   for (var i = 1; i < 10; ++i) { | 480   for (var i = 1; i < 10; ++i) { | 
| 489     %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
     ELETE); | 481     %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
     ELETE); | 
| 490     %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 482     %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 
| 491   } | 483   } | 
| 492 } | 484 } | 
| 493 | 485 | 
| 494 | 486 | 
| 495 SetupRegExp(); | 487 SetupRegExp(); | 
| OLD | NEW | 
|---|