| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 var lastIndex = this.lastIndex; | 287 var lastIndex = this.lastIndex; |
| 288 var cache = regExpCache; | 288 var cache = regExpCache; |
| 289 if (%_ObjectEquals(cache.type, 'test') && | 289 if (%_ObjectEquals(cache.type, 'test') && |
| 290 %_ObjectEquals(cache.regExp, this) && | 290 %_ObjectEquals(cache.regExp, this) && |
| 291 %_ObjectEquals(cache.subject, string) && | 291 %_ObjectEquals(cache.subject, string) && |
| 292 %_ObjectEquals(cache.lastIndex, lastIndex)) { | 292 %_ObjectEquals(cache.lastIndex, lastIndex)) { |
| 293 return cache.answer; | 293 return cache.answer; |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Remove irrelevant '.*' around a test regexp. The expression | 296 // Remove irrelevant preceeding '.*' in a test regexp. The expression |
| 297 // checks whether this.source starts and ends with '.*' and that the third | 297 // checks whether this.source starts with '.*' and that the third |
| 298 // char is not a '?' and that the third to last char is not a '\'. | 298 // char is not a '?' |
| 299 if (%_StringCharCodeAt(this.source,0) == 46 && // '.' | 299 if (%_StringCharCodeAt(this.source,0) == 46 && // '.' |
| 300 %_StringCharCodeAt(this.source,1) == 42 && // '*' | 300 %_StringCharCodeAt(this.source,1) == 42 && // '*' |
| 301 %_StringCharCodeAt(this.source,2) != 63 && // '?' | 301 %_StringCharCodeAt(this.source,2) != 63) { // '?' |
| 302 %_StringCharCodeAt(this.source,this.source.length - 3) != 28 && // '\' | |
| 303 %_StringCharCodeAt(this.source,this.source.length - 2) == 46 && // '.' | |
| 304 %_StringCharCodeAt(this.source,this.source.length - 1) == 42) { // '*' | |
| 305 if (!%_ObjectEquals(regexp_key, this)) { | 302 if (!%_ObjectEquals(regexp_key, this)) { |
| 306 regexp_key = this; | 303 regexp_key = this; |
| 307 regexp_val = new $RegExp(this.source.substring(2, | 304 regexp_val = new $RegExp(this.source.substring(2, |
| 308 this.source.length - 2), | 305 this.source.length - 2), |
| 309 (this.global ? 'g' : '') | 306 (this.global ? 'g' : '') |
| 310 + (this.ignoreCase ? 'i' : '') | 307 + (this.ignoreCase ? 'i' : '') |
| 311 + (this.multiline ? 'm' : '')); | 308 + (this.multiline ? 'm' : '')); |
| 312 } | 309 } |
| 313 if (!regexp_val.test(s)) return false; | 310 if (!regexp_val.test(s)) return false; |
| 314 } | 311 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 538 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 542 | 539 |
| 543 for (var i = 1; i < 10; ++i) { | 540 for (var i = 1; i < 10; ++i) { |
| 544 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 541 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
| 545 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 542 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
| 546 } | 543 } |
| 547 } | 544 } |
| 548 | 545 |
| 549 | 546 |
| 550 SetupRegExp(); | 547 SetupRegExp(); |
| OLD | NEW |