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 var $regexpExec; | 5 var $regexpExec; |
6 var $regexpExecNoTests; | 6 var $regexpExecNoTests; |
7 var $regexpLastMatchInfo; | 7 var $regexpLastMatchInfo; |
8 var $regexpLastMatchInfoOverride; | 8 var $regexpLastMatchInfoOverride; |
9 var harmony_regexps = false; | 9 var harmony_regexps = false; |
10 var harmony_unicode_regexps = false; | 10 var harmony_unicode_regexps = false; |
(...skipping 30 matching lines...) Expand all Loading... |
41 // function. | 41 // function. |
42 $regexpLastMatchInfoOverride = null; | 42 $regexpLastMatchInfoOverride = null; |
43 | 43 |
44 // ------------------------------------------------------------------- | 44 // ------------------------------------------------------------------- |
45 | 45 |
46 // A recursive descent parser for Patterns according to the grammar of | 46 // A recursive descent parser for Patterns according to the grammar of |
47 // ECMA-262 15.10.1, with deviations noted below. | 47 // ECMA-262 15.10.1, with deviations noted below. |
48 function DoConstructRegExp(object, pattern, flags) { | 48 function DoConstructRegExp(object, pattern, flags) { |
49 // RegExp : Called as constructor; see ECMA-262, section 15.10.4. | 49 // RegExp : Called as constructor; see ECMA-262, section 15.10.4. |
50 if (IS_REGEXP(pattern)) { | 50 if (IS_REGEXP(pattern)) { |
51 if (!IS_UNDEFINED(flags)) { | 51 if (!IS_UNDEFINED(flags)) throw MakeTypeError(kRegExpFlags); |
52 throw MakeTypeError('regexp_flags', []); | |
53 } | |
54 flags = (pattern.global ? 'g' : '') | 52 flags = (pattern.global ? 'g' : '') |
55 + (pattern.ignoreCase ? 'i' : '') | 53 + (pattern.ignoreCase ? 'i' : '') |
56 + (pattern.multiline ? 'm' : ''); | 54 + (pattern.multiline ? 'm' : ''); |
57 if (harmony_unicode_regexps) | 55 if (harmony_unicode_regexps) |
58 flags += (pattern.unicode ? 'u' : ''); | 56 flags += (pattern.unicode ? 'u' : ''); |
59 if (harmony_regexps) | 57 if (harmony_regexps) |
60 flags += (pattern.sticky ? 'y' : ''); | 58 flags += (pattern.sticky ? 'y' : ''); |
61 pattern = pattern.source; | 59 pattern = pattern.source; |
62 } | 60 } |
63 | 61 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, | 440 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, |
443 RegExpMakeCaptureGetter(i), NoOpSetter, | 441 RegExpMakeCaptureGetter(i), NoOpSetter, |
444 DONT_DELETE); | 442 DONT_DELETE); |
445 } | 443 } |
446 %ToFastProperties(GlobalRegExp); | 444 %ToFastProperties(GlobalRegExp); |
447 | 445 |
448 $regexpExecNoTests = RegExpExecNoTests; | 446 $regexpExecNoTests = RegExpExecNoTests; |
449 $regexpExec = DoRegExpExec; | 447 $regexpExec = DoRegExpExec; |
450 | 448 |
451 }) | 449 }) |
OLD | NEW |