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

Side by Side Diff: src/regexp.js

Issue 1323543002: [runtime] Replace %to_string_fun with %_ToString. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ToStringStub
Patch Set: REBASE. Fixes Created 5 years, 3 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
« no previous file with comments | « src/proxy.js ('k') | src/runtime.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $regexpLastMatchInfoOverride; 5 var $regexpLastMatchInfoOverride;
6 6
7 (function(global, utils) { 7 (function(global, utils) {
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 flags = (pattern.global ? 'g' : '') 59 flags = (pattern.global ? 'g' : '')
60 + (pattern.ignoreCase ? 'i' : '') 60 + (pattern.ignoreCase ? 'i' : '')
61 + (pattern.multiline ? 'm' : ''); 61 + (pattern.multiline ? 'm' : '');
62 if (FLAG_harmony_unicode_regexps) 62 if (FLAG_harmony_unicode_regexps)
63 flags += (pattern.unicode ? 'u' : ''); 63 flags += (pattern.unicode ? 'u' : '');
64 if (FLAG_harmony_regexps) 64 if (FLAG_harmony_regexps)
65 flags += (pattern.sticky ? 'y' : ''); 65 flags += (pattern.sticky ? 'y' : '');
66 pattern = pattern.source; 66 pattern = pattern.source;
67 } 67 }
68 68
69 pattern = IS_UNDEFINED(pattern) ? '' : $toString(pattern); 69 pattern = IS_UNDEFINED(pattern) ? '' : TO_STRING(pattern);
70 flags = IS_UNDEFINED(flags) ? '' : $toString(flags); 70 flags = IS_UNDEFINED(flags) ? '' : TO_STRING(flags);
71 71
72 %RegExpInitializeAndCompile(object, pattern, flags); 72 %RegExpInitializeAndCompile(object, pattern, flags);
73 } 73 }
74 74
75 75
76 function RegExpConstructor(pattern, flags) { 76 function RegExpConstructor(pattern, flags) {
77 if (%_IsConstructCall()) { 77 if (%_IsConstructCall()) {
78 DoConstructRegExp(this, pattern, flags); 78 DoConstructRegExp(this, pattern, flags);
79 } else { 79 } else {
80 // RegExp : Called as function; see ECMA-262, section 15.10.3.1. 80 // RegExp : Called as function; see ECMA-262, section 15.10.3.1.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return null; 154 return null;
155 } 155 }
156 156
157 157
158 function RegExpExecJS(string) { 158 function RegExpExecJS(string) {
159 if (!IS_REGEXP(this)) { 159 if (!IS_REGEXP(this)) {
160 throw MakeTypeError(kIncompatibleMethodReceiver, 160 throw MakeTypeError(kIncompatibleMethodReceiver,
161 'RegExp.prototype.exec', this); 161 'RegExp.prototype.exec', this);
162 } 162 }
163 163
164 string = TO_STRING_INLINE(string); 164 string = TO_STRING(string);
165 var lastIndex = this.lastIndex; 165 var lastIndex = this.lastIndex;
166 166
167 // Conversion is required by the ES5 specification (RegExp.prototype.exec 167 // Conversion is required by the ES5 specification (RegExp.prototype.exec
168 // algorithm, step 5) even if the value is discarded for non-global RegExps. 168 // algorithm, step 5) even if the value is discarded for non-global RegExps.
169 var i = TO_INTEGER(lastIndex); 169 var i = TO_INTEGER(lastIndex);
170 170
171 var updateLastIndex = this.global || (FLAG_harmony_regexps && this.sticky); 171 var updateLastIndex = this.global || (FLAG_harmony_regexps && this.sticky);
172 if (updateLastIndex) { 172 if (updateLastIndex) {
173 if (i < 0 || i > string.length) { 173 if (i < 0 || i > string.length) {
174 this.lastIndex = 0; 174 this.lastIndex = 0;
(...skipping 26 matching lines...) Expand all
201 201
202 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be 202 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be
203 // that test is defined in terms of String.prototype.exec. However, it probably 203 // that test is defined in terms of String.prototype.exec. However, it probably
204 // means the original value of String.prototype.exec, which is what everybody 204 // means the original value of String.prototype.exec, which is what everybody
205 // else implements. 205 // else implements.
206 function RegExpTest(string) { 206 function RegExpTest(string) {
207 if (!IS_REGEXP(this)) { 207 if (!IS_REGEXP(this)) {
208 throw MakeTypeError(kIncompatibleMethodReceiver, 208 throw MakeTypeError(kIncompatibleMethodReceiver,
209 'RegExp.prototype.test', this); 209 'RegExp.prototype.test', this);
210 } 210 }
211 string = TO_STRING_INLINE(string); 211 string = TO_STRING(string);
212 212
213 var lastIndex = this.lastIndex; 213 var lastIndex = this.lastIndex;
214 214
215 // Conversion is required by the ES5 specification (RegExp.prototype.exec 215 // Conversion is required by the ES5 specification (RegExp.prototype.exec
216 // algorithm, step 5) even if the value is discarded for non-global RegExps. 216 // algorithm, step 5) even if the value is discarded for non-global RegExps.
217 var i = TO_INTEGER(lastIndex); 217 var i = TO_INTEGER(lastIndex);
218 218
219 if (this.global || (FLAG_harmony_regexps && this.sticky)) { 219 if (this.global || (FLAG_harmony_regexps && this.sticky)) {
220 if (i < 0 || i > string.length) { 220 if (i < 0 || i > string.length) {
221 this.lastIndex = 0; 221 this.lastIndex = 0;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); 385 %FunctionSetLength(GlobalRegExp.prototype.compile, 1);
386 386
387 // The properties `input` and `$_` are aliases for each other. When this 387 // The properties `input` and `$_` are aliases for each other. When this
388 // value is set the value it is set to is coerced to a string. 388 // value is set the value it is set to is coerced to a string.
389 // Getter and setter for the input. 389 // Getter and setter for the input.
390 var RegExpGetInput = function() { 390 var RegExpGetInput = function() {
391 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); 391 var regExpInput = LAST_INPUT(RegExpLastMatchInfo);
392 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; 392 return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
393 }; 393 };
394 var RegExpSetInput = function(string) { 394 var RegExpSetInput = function(string) {
395 LAST_INPUT(RegExpLastMatchInfo) = $toString(string); 395 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string);
396 }; 396 };
397 397
398 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); 398 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
399 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, 399 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput,
400 RegExpSetInput, DONT_DELETE); 400 RegExpSetInput, DONT_DELETE);
401 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, 401 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput,
402 RegExpSetInput, DONT_ENUM | DONT_DELETE); 402 RegExpSetInput, DONT_ENUM | DONT_DELETE);
403 403
404 // The properties multiline and $* are aliases for each other. When this 404 // The properties multiline and $* are aliases for each other. When this
405 // value is set in SpiderMonkey, the value it is set to is coerced to a 405 // value is set in SpiderMonkey, the value it is set to is coerced to a
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Exports 454 // Exports
455 455
456 utils.Export(function(to) { 456 utils.Export(function(to) {
457 to.RegExpExec = DoRegExpExec; 457 to.RegExpExec = DoRegExpExec;
458 to.RegExpExecNoTests = RegExpExecNoTests; 458 to.RegExpExecNoTests = RegExpExecNoTests;
459 to.RegExpLastMatchInfo = RegExpLastMatchInfo; 459 to.RegExpLastMatchInfo = RegExpLastMatchInfo;
460 to.RegExpTest = RegExpTest; 460 to.RegExpTest = RegExpTest;
461 }); 461 });
462 462
463 }) 463 })
OLDNEW
« no previous file with comments | « src/proxy.js ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698