Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 regexp_val = | 263 regexp_val = |
| 264 new GlobalRegExp( | 264 new GlobalRegExp( |
| 265 %_SubString(REGEXP_SOURCE(regexp), 2, REGEXP_SOURCE(regexp).length), | 265 %_SubString(REGEXP_SOURCE(regexp), 2, REGEXP_SOURCE(regexp).length), |
| 266 (REGEXP_IGNORE_CASE(regexp) ? REGEXP_MULTILINE(regexp) ? "im" : "i" | 266 (REGEXP_IGNORE_CASE(regexp) ? REGEXP_MULTILINE(regexp) ? "im" : "i" |
| 267 : REGEXP_MULTILINE(regexp) ? "m" : "")); | 267 : REGEXP_MULTILINE(regexp) ? "m" : "")); |
| 268 } | 268 } |
| 269 return regexp_val; | 269 return regexp_val; |
| 270 } | 270 } |
| 271 | 271 |
| 272 | 272 |
| 273 const kRegExpPrototypeToString = 12; | |
| 274 | |
| 273 function RegExpToString() { | 275 function RegExpToString() { |
| 274 if (!IS_REGEXP(this)) { | 276 if (!IS_REGEXP(this)) { |
| 277 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; | |
| 278 // a UseCounter is incremented to track it. | |
| 279 // TODO(littledan): Remove this workaround or standardize it | |
| 280 if (this === GlobalRegExpPrototype) { | |
| 281 %IncrementUseCounter(kRegExpPrototypeToString); | |
| 282 return '/(?:)/'; | |
| 283 } | |
| 275 throw MakeTypeError(kIncompatibleMethodReceiver, | 284 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 276 'RegExp.prototype.toString', this); | 285 'RegExp.prototype.toString', this); |
| 277 } | 286 } |
| 278 var result = '/' + REGEXP_SOURCE(this) + '/'; | 287 var result = '/' + REGEXP_SOURCE(this) + '/'; |
| 279 if (REGEXP_GLOBAL(this)) result += 'g'; | 288 if (REGEXP_GLOBAL(this)) result += 'g'; |
| 280 if (REGEXP_IGNORE_CASE(this)) result += 'i'; | 289 if (REGEXP_IGNORE_CASE(this)) result += 'i'; |
| 281 if (REGEXP_MULTILINE(this)) result += 'm'; | 290 if (REGEXP_MULTILINE(this)) result += 'm'; |
| 282 if (REGEXP_UNICODE(this)) result += 'u'; | 291 if (REGEXP_UNICODE(this)) result += 'u'; |
| 283 if (REGEXP_STICKY(this)) result += 'y'; | 292 if (REGEXP_STICKY(this)) result += 'y'; |
| 284 return result; | 293 return result; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source"); | 493 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source"); |
| 485 } | 494 } |
| 486 return REGEXP_SOURCE(this); | 495 return REGEXP_SOURCE(this); |
| 487 } | 496 } |
| 488 %FunctionSetName(RegExpGetSource, "RegExp.prototype.source"); | 497 %FunctionSetName(RegExpGetSource, "RegExp.prototype.source"); |
| 489 %SetNativeFlag(RegExpGetSource); | 498 %SetNativeFlag(RegExpGetSource); |
| 490 | 499 |
| 491 // ------------------------------------------------------------------- | 500 // ------------------------------------------------------------------- |
| 492 | 501 |
| 493 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); | 502 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); |
| 494 %FunctionSetPrototype(GlobalRegExp, new GlobalObject()); | 503 const GlobalRegExpPrototype = new GlobalObject(); |
|
Yang
2015/12/22 06:31:22
Regexp.js is one of the remaining native scripts t
Dan Ehrenberg
2015/12/22 07:20:42
I think this makes sense, since it'll be a clean u
| |
| 504 %FunctionSetPrototype(GlobalRegExp, GlobalRegExpPrototype); | |
| 495 %AddNamedProperty( | 505 %AddNamedProperty( |
| 496 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); | 506 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); |
| 497 %SetCode(GlobalRegExp, RegExpConstructor); | 507 %SetCode(GlobalRegExp, RegExpConstructor); |
| 498 | 508 |
| 499 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ | 509 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ |
| 500 "exec", RegExpExecJS, | 510 "exec", RegExpExecJS, |
| 501 "test", RegExpTest, | 511 "test", RegExpTest, |
| 502 "toString", RegExpToString, | 512 "toString", RegExpToString, |
| 503 "compile", RegExpCompileJS, | 513 "compile", RegExpCompileJS, |
| 504 matchSymbol, RegExpMatch, | 514 matchSymbol, RegExpMatch, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 // Exports | 573 // Exports |
| 564 | 574 |
| 565 utils.Export(function(to) { | 575 utils.Export(function(to) { |
| 566 to.RegExpExec = DoRegExpExec; | 576 to.RegExpExec = DoRegExpExec; |
| 567 to.RegExpExecNoTests = RegExpExecNoTests; | 577 to.RegExpExecNoTests = RegExpExecNoTests; |
| 568 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 578 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
| 569 to.RegExpTest = RegExpTest; | 579 to.RegExpTest = RegExpTest; |
| 570 }); | 580 }); |
| 571 | 581 |
| 572 }) | 582 }) |
| OLD | NEW |