Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/regexp-delay.js

Issue 39010: Removed some handlers and made regexp.test avoid creating a result array. (Closed)
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 if (this.global) 190 if (this.global)
191 this.lastIndex = lastMatchInfo[CAPTURE1]; 191 this.lastIndex = lastMatchInfo[CAPTURE1];
192 result.index = lastMatchInfo[CAPTURE0]; 192 result.index = lastMatchInfo[CAPTURE0];
193 result.input = s; 193 result.input = s;
194 return result; 194 return result;
195 } 195 }
196 196
197 197
198 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be 198 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be
199 // that test is defined in terms of String.prototype.exec even if it changes. 199 // that test is defined in terms of String.prototype.exec even if the method is
200 // called on a non-RegExp object. However, it probably means the original
201 // value of String.prototype.exec, which is what everybody else implements.
200 function RegExpTest(string) { 202 function RegExpTest(string) {
201 var result = (%_ArgumentsLength() == 0) ? this.exec() : this.exec(string); 203 if (%_ArgumentsLength() == 0) {
202 return result != null; 204 var regExpInput = LAST_INPUT(lastMatchInfo);
205 if (IS_UNDEFINED(regExpInput)) {
206 throw MakeError('no_input_to_regexp', [this]);
207 }
208 string = regExpInput;
209 }
210 var s = ToString(string);
211 var length = s.length;
212 var lastIndex = this.lastIndex;
213 var i = this.global ? TO_INTEGER(lastIndex) : 0;
214
215 if (i < 0 || i > s.length) {
216 this.lastIndex = 0;
217 return false;
218 }
219
220 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]);
221 // matchIndices is either null or the lastMatchInfo array.
222 var matchIndices = %RegExpExec(this, s, i, lastMatchInfo);
223
224 if (matchIndices == null) {
225 if (this.global) this.lastIndex = 0;
226 return false;
227 }
228 return true;
203 } 229 }
204 230
205 231
206 function RegExpToString() { 232 function RegExpToString() {
207 // If this.source is an empty string, output /(?:)/. 233 // If this.source is an empty string, output /(?:)/.
208 // http://bugzilla.mozilla.org/show_bug.cgi?id=225550 234 // http://bugzilla.mozilla.org/show_bug.cgi?id=225550
209 // ecma_2/RegExp/properties-001.js. 235 // ecma_2/RegExp/properties-001.js.
210 var src = this.source ? this.source : '(?:)'; 236 var src = this.source ? this.source : '(?:)';
211 var result = '/' + src + '/'; 237 var result = '/' + src + '/';
212 if (this.global) 238 if (this.global)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 395 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE);
370 396
371 for (var i = 1; i < 10; ++i) { 397 for (var i = 1; i < 10; ++i) {
372 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE); 398 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE);
373 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); 399 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE);
374 } 400 }
375 } 401 }
376 402
377 403
378 SetupRegExp(); 404 SetupRegExp();
OLDNEW
« src/jsregexp.cc ('K') | « src/jsregexp.cc ('k') | test/mjsunit/regexp-string-methods.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698