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

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

Issue 1545633002: Reland of Add web compat workarounds for ES2015 RegExp semantics (patchset #3 id:40001 of https://c… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move var declaration up to fix debug build Created 5 years 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/js/harmony-regexp.js ('k') | src/runtime/runtime.h » ('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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
11 11
12 var FLAG_harmony_tolength; 12 var FLAG_harmony_tolength;
13 var GlobalObject = global.Object; 13 var GlobalObject = global.Object;
14 var GlobalRegExp = global.RegExp; 14 var GlobalRegExp = global.RegExp;
15 var GlobalRegExpPrototype;
15 var InternalArray = utils.InternalArray; 16 var InternalArray = utils.InternalArray;
16 var InternalPackedArray = utils.InternalPackedArray; 17 var InternalPackedArray = utils.InternalPackedArray;
17 var MakeTypeError; 18 var MakeTypeError;
18 var matchSymbol = utils.ImportNow("match_symbol"); 19 var matchSymbol = utils.ImportNow("match_symbol");
19 var searchSymbol = utils.ImportNow("search_symbol"); 20 var searchSymbol = utils.ImportNow("search_symbol");
20 var splitSymbol = utils.ImportNow("split_symbol"); 21 var splitSymbol = utils.ImportNow("split_symbol");
21 22
22 utils.ImportFromExperimental(function(from) { 23 utils.ImportFromExperimental(function(from) {
23 FLAG_harmony_tolength = from.FLAG_harmony_tolength; 24 FLAG_harmony_tolength = from.FLAG_harmony_tolength;
24 }); 25 });
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 regexp_val = 264 regexp_val =
264 new GlobalRegExp( 265 new GlobalRegExp(
265 %_SubString(REGEXP_SOURCE(regexp), 2, REGEXP_SOURCE(regexp).length), 266 %_SubString(REGEXP_SOURCE(regexp), 2, REGEXP_SOURCE(regexp).length),
266 (REGEXP_IGNORE_CASE(regexp) ? REGEXP_MULTILINE(regexp) ? "im" : "i" 267 (REGEXP_IGNORE_CASE(regexp) ? REGEXP_MULTILINE(regexp) ? "im" : "i"
267 : REGEXP_MULTILINE(regexp) ? "m" : "")); 268 : REGEXP_MULTILINE(regexp) ? "m" : ""));
268 } 269 }
269 return regexp_val; 270 return regexp_val;
270 } 271 }
271 272
272 273
274 var kRegExpPrototypeToString = 12;
275
273 function RegExpToString() { 276 function RegExpToString() {
274 if (!IS_REGEXP(this)) { 277 if (!IS_REGEXP(this)) {
278 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix;
279 // a UseCounter is incremented to track it.
280 // TODO(littledan): Remove this workaround or standardize it
281 if (this === GlobalRegExpPrototype) {
282 %IncrementUseCounter(kRegExpPrototypeToString);
283 return '/(?:)/';
284 }
275 throw MakeTypeError(kIncompatibleMethodReceiver, 285 throw MakeTypeError(kIncompatibleMethodReceiver,
276 'RegExp.prototype.toString', this); 286 'RegExp.prototype.toString', this);
277 } 287 }
278 var result = '/' + REGEXP_SOURCE(this) + '/'; 288 var result = '/' + REGEXP_SOURCE(this) + '/';
279 if (REGEXP_GLOBAL(this)) result += 'g'; 289 if (REGEXP_GLOBAL(this)) result += 'g';
280 if (REGEXP_IGNORE_CASE(this)) result += 'i'; 290 if (REGEXP_IGNORE_CASE(this)) result += 'i';
281 if (REGEXP_MULTILINE(this)) result += 'm'; 291 if (REGEXP_MULTILINE(this)) result += 'm';
282 if (REGEXP_UNICODE(this)) result += 'u'; 292 if (REGEXP_UNICODE(this)) result += 'u';
283 if (REGEXP_STICKY(this)) result += 'y'; 293 if (REGEXP_STICKY(this)) result += 'y';
284 return result; 294 return result;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source"); 494 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source");
485 } 495 }
486 return REGEXP_SOURCE(this); 496 return REGEXP_SOURCE(this);
487 } 497 }
488 %FunctionSetName(RegExpGetSource, "RegExp.prototype.source"); 498 %FunctionSetName(RegExpGetSource, "RegExp.prototype.source");
489 %SetNativeFlag(RegExpGetSource); 499 %SetNativeFlag(RegExpGetSource);
490 500
491 // ------------------------------------------------------------------- 501 // -------------------------------------------------------------------
492 502
493 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); 503 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
494 %FunctionSetPrototype(GlobalRegExp, new GlobalObject()); 504 GlobalRegExpPrototype = new GlobalObject();
505 %FunctionSetPrototype(GlobalRegExp, GlobalRegExpPrototype);
495 %AddNamedProperty( 506 %AddNamedProperty(
496 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); 507 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
497 %SetCode(GlobalRegExp, RegExpConstructor); 508 %SetCode(GlobalRegExp, RegExpConstructor);
498 509
499 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ 510 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
500 "exec", RegExpExecJS, 511 "exec", RegExpExecJS,
501 "test", RegExpTest, 512 "test", RegExpTest,
502 "toString", RegExpToString, 513 "toString", RegExpToString,
503 "compile", RegExpCompileJS, 514 "compile", RegExpCompileJS,
504 matchSymbol, RegExpMatch, 515 matchSymbol, RegExpMatch,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // Exports 574 // Exports
564 575
565 utils.Export(function(to) { 576 utils.Export(function(to) {
566 to.RegExpExec = DoRegExpExec; 577 to.RegExpExec = DoRegExpExec;
567 to.RegExpExecNoTests = RegExpExecNoTests; 578 to.RegExpExecNoTests = RegExpExecNoTests;
568 to.RegExpLastMatchInfo = RegExpLastMatchInfo; 579 to.RegExpLastMatchInfo = RegExpLastMatchInfo;
569 to.RegExpTest = RegExpTest; 580 to.RegExpTest = RegExpTest;
570 }); 581 });
571 582
572 }) 583 })
OLDNEW
« no previous file with comments | « src/js/harmony-regexp.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698