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 | |
389 var NoOpSetter = function(ignored) {}; | 370 var NoOpSetter = function(ignored) {}; |
390 | 371 |
391 | 372 |
392 // Static properties set by a successful match. | 373 // Static properties set by a successful match. |
393 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, | 374 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, |
394 NoOpSetter, DONT_DELETE); | 375 NoOpSetter, DONT_DELETE); |
395 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, | 376 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, |
396 NoOpSetter, DONT_ENUM | DONT_DELETE); | 377 NoOpSetter, DONT_ENUM | DONT_DELETE); |
397 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, | 378 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, |
398 NoOpSetter, DONT_DELETE); | 379 NoOpSetter, DONT_DELETE); |
(...skipping 21 matching lines...) Expand all Loading... |
420 // Exports | 401 // Exports |
421 | 402 |
422 utils.Export(function(to) { | 403 utils.Export(function(to) { |
423 to.RegExpExec = DoRegExpExec; | 404 to.RegExpExec = DoRegExpExec; |
424 to.RegExpExecNoTests = RegExpExecNoTests; | 405 to.RegExpExecNoTests = RegExpExecNoTests; |
425 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 406 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
426 to.RegExpTest = RegExpTest; | 407 to.RegExpTest = RegExpTest; |
427 }); | 408 }); |
428 | 409 |
429 }) | 410 }) |
OLD | NEW |