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

Side by Side Diff: src/regexp.js

Issue 1095573002: Revert of Migrate error messages, part 2. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/objects.cc ('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 $regexpExec; 5 var $regexpExec;
6 var $regexpExecNoTests; 6 var $regexpExecNoTests;
7 var $regexpLastMatchInfo; 7 var $regexpLastMatchInfo;
8 var $regexpLastMatchInfoOverride; 8 var $regexpLastMatchInfoOverride;
9 var harmony_regexps = false; 9 var harmony_regexps = false;
10 var harmony_unicode_regexps = false; 10 var harmony_unicode_regexps = false;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 function RegExpCompileJS(pattern, flags) { 81 function RegExpCompileJS(pattern, flags) {
82 // Both JSC and SpiderMonkey treat a missing pattern argument as the 82 // Both JSC and SpiderMonkey treat a missing pattern argument as the
83 // empty subject string, and an actual undefined value passed as the 83 // empty subject string, and an actual undefined value passed as the
84 // pattern as the string 'undefined'. Note that JSC is inconsistent 84 // pattern as the string 'undefined'. Note that JSC is inconsistent
85 // here, treating undefined values differently in 85 // here, treating undefined values differently in
86 // RegExp.prototype.compile and in the constructor, where they are 86 // RegExp.prototype.compile and in the constructor, where they are
87 // the empty string. For compatibility with JSC, we match their 87 // the empty string. For compatibility with JSC, we match their
88 // behavior. 88 // behavior.
89 if (this == GlobalRegExp.prototype) { 89 if (this == GlobalRegExp.prototype) {
90 // We don't allow recompiling RegExp.prototype. 90 // We don't allow recompiling RegExp.prototype.
91 throw MakeTypeError(kIncompatibleMethodReceiver, 91 throw MakeTypeError('incompatible_method_receiver',
92 'RegExp.prototype.compile', this); 92 ['RegExp.prototype.compile', this]);
93 } 93 }
94 if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) { 94 if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) {
95 DoConstructRegExp(this, 'undefined', flags); 95 DoConstructRegExp(this, 'undefined', flags);
96 } else { 96 } else {
97 DoConstructRegExp(this, pattern, flags); 97 DoConstructRegExp(this, pattern, flags);
98 } 98 }
99 } 99 }
100 100
101 101
102 function DoRegExpExec(regexp, string, index) { 102 function DoRegExpExec(regexp, string, index) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 $regexpLastMatchInfoOverride = null; 139 $regexpLastMatchInfoOverride = null;
140 RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string); 140 RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
141 } 141 }
142 regexp.lastIndex = 0; 142 regexp.lastIndex = 0;
143 return null; 143 return null;
144 } 144 }
145 145
146 146
147 function RegExpExecJS(string) { 147 function RegExpExecJS(string) {
148 if (!IS_REGEXP(this)) { 148 if (!IS_REGEXP(this)) {
149 throw MakeTypeError(kIncompatibleMethodReceiver, 149 throw MakeTypeError('incompatible_method_receiver',
150 'RegExp.prototype.exec', this); 150 ['RegExp.prototype.exec', this]);
151 } 151 }
152 152
153 string = TO_STRING_INLINE(string); 153 string = TO_STRING_INLINE(string);
154 var lastIndex = this.lastIndex; 154 var lastIndex = this.lastIndex;
155 155
156 // Conversion is required by the ES5 specification (RegExp.prototype.exec 156 // Conversion is required by the ES5 specification (RegExp.prototype.exec
157 // algorithm, step 5) even if the value is discarded for non-global RegExps. 157 // algorithm, step 5) even if the value is discarded for non-global RegExps.
158 var i = TO_INTEGER(lastIndex); 158 var i = TO_INTEGER(lastIndex);
159 159
160 var updateLastIndex = this.global || (harmony_regexps && this.sticky); 160 var updateLastIndex = this.global || (harmony_regexps && this.sticky);
(...skipping 26 matching lines...) Expand all
187 // One-element cache for the simplified test regexp. 187 // One-element cache for the simplified test regexp.
188 var regexp_key; 188 var regexp_key;
189 var regexp_val; 189 var regexp_val;
190 190
191 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be 191 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be
192 // that test is defined in terms of String.prototype.exec. However, it probably 192 // that test is defined in terms of String.prototype.exec. However, it probably
193 // means the original value of String.prototype.exec, which is what everybody 193 // means the original value of String.prototype.exec, which is what everybody
194 // else implements. 194 // else implements.
195 function RegExpTest(string) { 195 function RegExpTest(string) {
196 if (!IS_REGEXP(this)) { 196 if (!IS_REGEXP(this)) {
197 throw MakeTypeError(kIncompatibleMethodReceiver, 197 throw MakeTypeError('incompatible_method_receiver',
198 'RegExp.prototype.test', this); 198 ['RegExp.prototype.test', this]);
199 } 199 }
200 string = TO_STRING_INLINE(string); 200 string = TO_STRING_INLINE(string);
201 201
202 var lastIndex = this.lastIndex; 202 var lastIndex = this.lastIndex;
203 203
204 // Conversion is required by the ES5 specification (RegExp.prototype.exec 204 // Conversion is required by the ES5 specification (RegExp.prototype.exec
205 // algorithm, step 5) even if the value is discarded for non-global RegExps. 205 // algorithm, step 5) even if the value is discarded for non-global RegExps.
206 var i = TO_INTEGER(lastIndex); 206 var i = TO_INTEGER(lastIndex);
207 207
208 if (this.global || (harmony_regexps && this.sticky)) { 208 if (this.global || (harmony_regexps && this.sticky)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 new GlobalRegExp(%_SubString(regexp.source, 2, regexp.source.length), 249 new GlobalRegExp(%_SubString(regexp.source, 2, regexp.source.length),
250 (regexp.ignoreCase ? regexp.multiline ? "im" : "i" 250 (regexp.ignoreCase ? regexp.multiline ? "im" : "i"
251 : regexp.multiline ? "m" : "")); 251 : regexp.multiline ? "m" : ""));
252 } 252 }
253 return regexp_val; 253 return regexp_val;
254 } 254 }
255 255
256 256
257 function RegExpToString() { 257 function RegExpToString() {
258 if (!IS_REGEXP(this)) { 258 if (!IS_REGEXP(this)) {
259 throw MakeTypeError(kIncompatibleMethodReceiver, 259 throw MakeTypeError('incompatible_method_receiver',
260 'RegExp.prototype.toString', this); 260 ['RegExp.prototype.toString', this]);
261 } 261 }
262 var result = '/' + this.source + '/'; 262 var result = '/' + this.source + '/';
263 if (this.global) result += 'g'; 263 if (this.global) result += 'g';
264 if (this.ignoreCase) result += 'i'; 264 if (this.ignoreCase) result += 'i';
265 if (this.multiline) result += 'm'; 265 if (this.multiline) result += 'm';
266 if (harmony_unicode_regexps && this.unicode) result += 'u'; 266 if (harmony_unicode_regexps && this.unicode) result += 'u';
267 if (harmony_regexps && this.sticky) result += 'y'; 267 if (harmony_regexps && this.sticky) result += 'y';
268 return result; 268 return result;
269 } 269 }
270 270
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, 436 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i,
437 RegExpMakeCaptureGetter(i), NoOpSetter, 437 RegExpMakeCaptureGetter(i), NoOpSetter,
438 DONT_DELETE); 438 DONT_DELETE);
439 } 439 }
440 %ToFastProperties(GlobalRegExp); 440 %ToFastProperties(GlobalRegExp);
441 441
442 $regexpExecNoTests = RegExpExecNoTests; 442 $regexpExecNoTests = RegExpExecNoTests;
443 $regexpExec = DoRegExpExec; 443 $regexpExec = DoRegExpExec;
444 444
445 })(); 445 })();
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698