| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 var end = lastMatchInfo[CAPTURE1]; | 133 var end = lastMatchInfo[CAPTURE1]; |
| 134 var result = %_RegExpConstructResult(numResults, start, s); | 134 var result = %_RegExpConstructResult(numResults, start, s); |
| 135 if (start + 1 == end) { | 135 if (start + 1 == end) { |
| 136 result[0] = %_StringCharAt(s, start); | 136 result[0] = %_StringCharAt(s, start); |
| 137 } else { | 137 } else { |
| 138 result[0] = %_SubString(s, start, end); | 138 result[0] = %_SubString(s, start, end); |
| 139 } | 139 } |
| 140 var j = REGEXP_FIRST_CAPTURE + 2; | 140 var j = REGEXP_FIRST_CAPTURE + 2; |
| 141 for (var i = 1; i < numResults; i++) { | 141 for (var i = 1; i < numResults; i++) { |
| 142 start = lastMatchInfo[j++]; | 142 start = lastMatchInfo[j++]; |
| 143 if (start != -1) { | 143 end = lastMatchInfo[j++]; |
| 144 end = lastMatchInfo[j]; | 144 if (end != -1) { |
| 145 if (start + 1 == end) { | 145 if (start + 1 == end) { |
| 146 result[i] = %_StringCharAt(s, start); | 146 result[i] = %_StringCharAt(s, start); |
| 147 } else { | 147 } else { |
| 148 result[i] = %_SubString(s, start, end); | 148 result[i] = %_SubString(s, start, end); |
| 149 } | 149 } |
| 150 } else { |
| 151 // Make sure the element is present. Avoid reading the undefined |
| 152 // property from the global object since this may change. |
| 153 result[i] = void 0; |
| 150 } | 154 } |
| 151 j++; | |
| 152 } | 155 } |
| 153 return result; | 156 return result; |
| 154 } | 157 } |
| 155 | 158 |
| 156 | 159 |
| 157 function RegExpExecNoTests(regexp, string, start) { | 160 function RegExpExecNoTests(regexp, string, start) { |
| 158 // Must be called with RegExp, string and positive integer as arguments. | 161 // Must be called with RegExp, string and positive integer as arguments. |
| 159 var matchInfo = %_RegExpExec(regexp, string, start, lastMatchInfo); | 162 var matchInfo = %_RegExpExec(regexp, string, start, lastMatchInfo); |
| 160 if (matchInfo !== null) { | 163 if (matchInfo !== null) { |
| 161 lastMatchInfoOverride = null; | 164 lastMatchInfoOverride = null; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 479 |
| 477 for (var i = 1; i < 10; ++i) { | 480 for (var i = 1; i < 10; ++i) { |
| 478 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 481 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 479 RegExpMakeCaptureGetter(i), NoOpSetter, | 482 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 480 DONT_DELETE); | 483 DONT_DELETE); |
| 481 } | 484 } |
| 482 %ToFastProperties($RegExp); | 485 %ToFastProperties($RegExp); |
| 483 } | 486 } |
| 484 | 487 |
| 485 SetUpRegExp(); | 488 SetUpRegExp(); |
| OLD | NEW |