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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 var RegExpSetInput = function(string) { | 409 var RegExpSetInput = function(string) { |
410 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); | 410 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); |
411 }; | 411 }; |
412 | 412 |
413 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); | 413 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); |
414 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, | 414 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, |
415 RegExpSetInput, DONT_DELETE); | 415 RegExpSetInput, DONT_DELETE); |
416 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, | 416 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, |
417 RegExpSetInput, DONT_ENUM | DONT_DELETE); | 417 RegExpSetInput, DONT_ENUM | DONT_DELETE); |
418 | 418 |
419 // The properties multiline and $* are aliases for each other. When this | |
420 // value is set in SpiderMonkey, the value it is set to is coerced to a | |
421 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey | |
422 // the value of the expression 'RegExp.multiline = null' (for instance) is the | |
423 // boolean false (i.e., the value after coercion), while in V8 it is the value | |
424 // null (i.e., the value before coercion). | |
425 | |
426 // Getter and setter for multiline. | |
427 var multiline = false; | |
428 var RegExpGetMultiline = function() { return multiline; }; | |
429 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; | |
430 | |
431 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'multiline', RegExpGetMultiline, | |
432 RegExpSetMultiline, DONT_DELETE); | |
433 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$*', RegExpGetMultiline, | |
434 RegExpSetMultiline, | |
435 DONT_ENUM | DONT_DELETE); | |
436 | |
437 | |
438 var NoOpSetter = function(ignored) {}; | 419 var NoOpSetter = function(ignored) {}; |
439 | 420 |
440 | 421 |
441 // Static properties set by a successful match. | 422 // Static properties set by a successful match. |
442 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, | 423 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, |
443 NoOpSetter, DONT_DELETE); | 424 NoOpSetter, DONT_DELETE); |
444 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, | 425 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, |
445 NoOpSetter, DONT_ENUM | DONT_DELETE); | 426 NoOpSetter, DONT_ENUM | DONT_DELETE); |
446 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, | 427 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, |
447 NoOpSetter, DONT_DELETE); | 428 NoOpSetter, DONT_DELETE); |
(...skipping 21 matching lines...) Expand all Loading... |
469 // Exports | 450 // Exports |
470 | 451 |
471 utils.Export(function(to) { | 452 utils.Export(function(to) { |
472 to.RegExpExec = DoRegExpExec; | 453 to.RegExpExec = DoRegExpExec; |
473 to.RegExpExecNoTests = RegExpExecNoTests; | 454 to.RegExpExecNoTests = RegExpExecNoTests; |
474 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 455 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
475 to.RegExpTest = RegExpTest; | 456 to.RegExpTest = RegExpTest; |
476 }); | 457 }); |
477 | 458 |
478 }) | 459 }) |
OLD | NEW |