OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 case 'm': | 64 case 'm': |
65 multiline = true; | 65 multiline = true; |
66 break; | 66 break; |
67 default: | 67 default: |
68 // Ignore flags that have no meaning to be consistent with | 68 // Ignore flags that have no meaning to be consistent with |
69 // JSC. | 69 // JSC. |
70 break; | 70 break; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 if (isConstructorCall) { | 74 if (!isConstructorCall) { |
75 // ECMA-262, section 15.10.7.1. | |
76 %SetProperty(object, 'source', pattern, | |
77 DONT_DELETE | READ_ONLY | DONT_ENUM); | |
78 | |
79 // ECMA-262, section 15.10.7.2. | |
80 %SetProperty(object, 'global', global, DONT_DELETE | READ_ONLY | DONT_ENUM); | |
81 | |
82 // ECMA-262, section 15.10.7.3. | |
83 %SetProperty(object, 'ignoreCase', ignoreCase, | |
84 DONT_DELETE | READ_ONLY | DONT_ENUM); | |
85 | |
86 // ECMA-262, section 15.10.7.4. | |
87 %SetProperty(object, 'multiline', multiline, | |
88 DONT_DELETE | READ_ONLY | DONT_ENUM); | |
89 | |
90 // ECMA-262, section 15.10.7.5. | |
91 %SetProperty(object, 'lastIndex', 0, DONT_DELETE | DONT_ENUM); | |
92 } else { // RegExp is being recompiled via RegExp.prototype.compile. | |
93 %IgnoreAttributesAndSetProperty(object, 'source', pattern); | |
94 %IgnoreAttributesAndSetProperty(object, 'global', global); | |
95 %IgnoreAttributesAndSetProperty(object, 'ignoreCase', ignoreCase); | |
96 %IgnoreAttributesAndSetProperty(object, 'multiline', multiline); | |
97 %IgnoreAttributesAndSetProperty(object, 'lastIndex', 0); | |
98 regExpCache.type = 'none'; | 75 regExpCache.type = 'none'; |
99 } | 76 } |
| 77 %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline); |
100 | 78 |
101 // Call internal function to compile the pattern. | 79 // Call internal function to compile the pattern. |
102 %RegExpCompile(object, pattern, flags); | 80 %RegExpCompile(object, pattern, flags); |
103 } | 81 } |
104 | 82 |
105 | 83 |
106 function RegExpConstructor(pattern, flags) { | 84 function RegExpConstructor(pattern, flags) { |
107 if (%_IsConstructCall()) { | 85 if (%_IsConstructCall()) { |
108 DoConstructRegExp(this, pattern, flags, true); | 86 DoConstructRegExp(this, pattern, flags, true); |
109 } else { | 87 } else { |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 497 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
520 | 498 |
521 for (var i = 1; i < 10; ++i) { | 499 for (var i = 1; i < 10; ++i) { |
522 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 500 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
523 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 501 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
524 } | 502 } |
525 } | 503 } |
526 | 504 |
527 | 505 |
528 SetupRegExp(); | 506 SetupRegExp(); |
OLD | NEW |