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

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

Issue 1421593009: Revert of Use in-object fields instead of private symbols for regexp slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/macros.py ('k') | src/js/string.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 (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 InternalPackedArray = utils.InternalPackedArray; 15 var InternalPackedArray = utils.InternalPackedArray;
16 var MakeTypeError; 16 var MakeTypeError;
17 var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol");
18 var regExpSourceSymbol = utils.ImportNow("regexp_source_symbol");
17 19
18 utils.ImportFromExperimental(function(from) { 20 utils.ImportFromExperimental(function(from) {
19 FLAG_harmony_tolength = from.FLAG_harmony_tolength; 21 FLAG_harmony_tolength = from.FLAG_harmony_tolength;
20 }); 22 });
21 23
22 utils.Import(function(from) { 24 utils.Import(function(from) {
23 MakeTypeError = from.MakeTypeError; 25 MakeTypeError = from.MakeTypeError;
24 }); 26 });
25 27
26 // ------------------------------------------------------------------- 28 // -------------------------------------------------------------------
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)]; 327 var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)];
326 if (matchStart == -1 || matchEnd == -1) return ''; 328 if (matchStart == -1 || matchEnd == -1) return '';
327 return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd); 329 return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd);
328 }; 330 };
329 } 331 }
330 332
331 333
332 // ES6 21.2.5.4, 21.2.5.5, 21.2.5.7, 21.2.5.12, 21.2.5.15. 334 // ES6 21.2.5.4, 21.2.5.5, 21.2.5.7, 21.2.5.12, 21.2.5.15.
333 function GetRegExpFlagGetter(name, mask) { 335 function GetRegExpFlagGetter(name, mask) {
334 var getter = function() { 336 var getter = function() {
335 if (!IS_REGEXP(this)) { 337 if (!IS_SPEC_OBJECT(this)) {
336 throw MakeTypeError(kRegExpNonObject, name, TO_STRING(this)); 338 throw MakeTypeError(kRegExpNonObject, name, TO_STRING(this));
337 } 339 }
338 return !!(%_RegExpFlags(this) & mask); 340 var flags = this[regExpFlagsSymbol];
341 if (IS_UNDEFINED(flags)) {
342 throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this));
343 }
344 return !!(flags & mask);
339 }; 345 };
340 %FunctionSetName(getter, name); 346 %FunctionSetName(getter, name);
341 %SetNativeFlag(getter); 347 %SetNativeFlag(getter);
342 return getter; 348 return getter;
343 } 349 }
344 350
345 351
346 // ES6 21.2.5.10. 352 // ES6 21.2.5.10.
347 function RegExpGetSource() { 353 function RegExpGetSource() {
348 if (!IS_REGEXP(this)) { 354 if (!IS_SPEC_OBJECT(this)) {
349 throw MakeTypeError(kRegExpNonObject, "RegExp.prototype.source", 355 throw MakeTypeError(kRegExpNonObject, "RegExp.prototype.source",
350 TO_STRING(this)); 356 TO_STRING(this));
351 } 357 }
352 return %_RegExpSource(this); 358 var source = this[regExpSourceSymbol];
359 if (IS_UNDEFINED(source)) {
360 throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this));
361 }
362 return source;
353 } 363 }
354 364
355 %SetNativeFlag(RegExpGetSource); 365 %SetNativeFlag(RegExpGetSource);
356 366
357 // ------------------------------------------------------------------- 367 // -------------------------------------------------------------------
358 368
359 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); 369 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
360 %FunctionSetPrototype(GlobalRegExp, new GlobalObject()); 370 %FunctionSetPrototype(GlobalRegExp, new GlobalObject());
361 %AddNamedProperty( 371 %AddNamedProperty(
362 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); 372 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 465
456 utils.Export(function(to) { 466 utils.Export(function(to) {
457 to.GetRegExpFlagGetter = GetRegExpFlagGetter; 467 to.GetRegExpFlagGetter = GetRegExpFlagGetter;
458 to.RegExpExec = DoRegExpExec; 468 to.RegExpExec = DoRegExpExec;
459 to.RegExpExecNoTests = RegExpExecNoTests; 469 to.RegExpExecNoTests = RegExpExecNoTests;
460 to.RegExpLastMatchInfo = RegExpLastMatchInfo; 470 to.RegExpLastMatchInfo = RegExpLastMatchInfo;
461 to.RegExpTest = RegExpTest; 471 to.RegExpTest = RegExpTest;
462 }); 472 });
463 473
464 }) 474 })
OLDNEW
« no previous file with comments | « src/js/macros.py ('k') | src/js/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698