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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 var RegExpSetInput = function(string) { | 360 var RegExpSetInput = function(string) { |
361 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); | 361 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); |
362 }; | 362 }; |
363 | 363 |
364 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); | 364 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); |
365 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, | 365 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, |
366 RegExpSetInput, DONT_DELETE); | 366 RegExpSetInput, DONT_DELETE); |
367 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, | 367 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, |
368 RegExpSetInput, DONT_ENUM | DONT_DELETE); | 368 RegExpSetInput, DONT_ENUM | DONT_DELETE); |
369 | 369 |
| 370 // The properties multiline and $* are aliases for each other. When this |
| 371 // value is set in SpiderMonkey, the value it is set to is coerced to a |
| 372 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey |
| 373 // the value of the expression 'RegExp.multiline = null' (for instance) is the |
| 374 // boolean false (i.e., the value after coercion), while in V8 it is the value |
| 375 // null (i.e., the value before coercion). |
| 376 |
| 377 // Getter and setter for multiline. |
| 378 var multiline = false; |
| 379 var RegExpGetMultiline = function() { return multiline; }; |
| 380 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; |
| 381 |
| 382 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'multiline', RegExpGetMultiline, |
| 383 RegExpSetMultiline, DONT_DELETE); |
| 384 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$*', RegExpGetMultiline, |
| 385 RegExpSetMultiline, |
| 386 DONT_ENUM | DONT_DELETE); |
| 387 |
| 388 |
370 var NoOpSetter = function(ignored) {}; | 389 var NoOpSetter = function(ignored) {}; |
371 | 390 |
372 | 391 |
373 // Static properties set by a successful match. | 392 // Static properties set by a successful match. |
374 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, | 393 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, |
375 NoOpSetter, DONT_DELETE); | 394 NoOpSetter, DONT_DELETE); |
376 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, | 395 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, |
377 NoOpSetter, DONT_ENUM | DONT_DELETE); | 396 NoOpSetter, DONT_ENUM | DONT_DELETE); |
378 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, | 397 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, |
379 NoOpSetter, DONT_DELETE); | 398 NoOpSetter, DONT_DELETE); |
(...skipping 21 matching lines...) Expand all Loading... |
401 // Exports | 420 // Exports |
402 | 421 |
403 utils.Export(function(to) { | 422 utils.Export(function(to) { |
404 to.RegExpExec = DoRegExpExec; | 423 to.RegExpExec = DoRegExpExec; |
405 to.RegExpExecNoTests = RegExpExecNoTests; | 424 to.RegExpExecNoTests = RegExpExecNoTests; |
406 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 425 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
407 to.RegExpTest = RegExpTest; | 426 to.RegExpTest = RegExpTest; |
408 }); | 427 }); |
409 | 428 |
410 }) | 429 }) |
OLD | NEW |