| 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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 // value is set the value it is set to is coerced to a string. | 1159 // value is set the value it is set to is coerced to a string. |
| 1160 // Getter and setter for the input. | 1160 // Getter and setter for the input. |
| 1161 var RegExpGetInput = function() { | 1161 var RegExpGetInput = function() { |
| 1162 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); | 1162 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); |
| 1163 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; | 1163 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
| 1164 }; | 1164 }; |
| 1165 var RegExpSetInput = function(string) { | 1165 var RegExpSetInput = function(string) { |
| 1166 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); | 1166 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); |
| 1167 }; | 1167 }; |
| 1168 | 1168 |
| 1169 // TODO(jgruber): All of these getters and setters were intended to be installed |
| 1170 // with various attributes (e.g. DONT_ENUM | DONT_DELETE), but |
| 1171 // InstallGetterSetter had a bug which ignored the passed attributes and |
| 1172 // simply installed as DONT_ENUM instead. We might want to change back |
| 1173 // to the intended attributes at some point. |
| 1174 |
| 1169 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); | 1175 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); |
| 1170 utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput, | 1176 utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput, |
| 1171 DONT_DELETE); | 1177 DONT_ENUM); |
| 1172 utils.InstallGetterSetter(GlobalRegExp, '$_', RegExpGetInput, RegExpSetInput, | 1178 utils.InstallGetterSetter(GlobalRegExp, '$_', RegExpGetInput, RegExpSetInput, |
| 1173 DONT_ENUM | DONT_DELETE); | 1179 DONT_ENUM); |
| 1174 | 1180 |
| 1175 | 1181 |
| 1176 var NoOpSetter = function(ignored) {}; | 1182 var NoOpSetter = function(ignored) {}; |
| 1177 | 1183 |
| 1178 | 1184 |
| 1179 // Static properties set by a successful match. | 1185 // Static properties set by a successful match. |
| 1180 utils.InstallGetterSetter(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, | 1186 utils.InstallGetterSetter(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, |
| 1181 NoOpSetter, DONT_DELETE); | 1187 NoOpSetter, DONT_ENUM); |
| 1182 utils.InstallGetterSetter(GlobalRegExp, '$&', RegExpGetLastMatch, NoOpSetter, | 1188 utils.InstallGetterSetter(GlobalRegExp, '$&', RegExpGetLastMatch, NoOpSetter, |
| 1183 DONT_ENUM | DONT_DELETE); | 1189 DONT_ENUM); |
| 1184 utils.InstallGetterSetter(GlobalRegExp, 'lastParen', RegExpGetLastParen, | 1190 utils.InstallGetterSetter(GlobalRegExp, 'lastParen', RegExpGetLastParen, |
| 1185 NoOpSetter, DONT_DELETE); | 1191 NoOpSetter, DONT_ENUM); |
| 1186 utils.InstallGetterSetter(GlobalRegExp, '$+', RegExpGetLastParen, NoOpSetter, | 1192 utils.InstallGetterSetter(GlobalRegExp, '$+', RegExpGetLastParen, NoOpSetter, |
| 1187 DONT_ENUM | DONT_DELETE); | 1193 DONT_ENUM); |
| 1188 utils.InstallGetterSetter(GlobalRegExp, 'leftContext', RegExpGetLeftContext, | 1194 utils.InstallGetterSetter(GlobalRegExp, 'leftContext', RegExpGetLeftContext, |
| 1189 NoOpSetter, DONT_DELETE); | 1195 NoOpSetter, DONT_ENUM); |
| 1190 utils.InstallGetterSetter(GlobalRegExp, '$`', RegExpGetLeftContext, NoOpSetter, | 1196 utils.InstallGetterSetter(GlobalRegExp, '$`', RegExpGetLeftContext, NoOpSetter, |
| 1191 DONT_ENUM | DONT_DELETE); | 1197 DONT_ENUM); |
| 1192 utils.InstallGetterSetter(GlobalRegExp, 'rightContext', RegExpGetRightContext, | 1198 utils.InstallGetterSetter(GlobalRegExp, 'rightContext', RegExpGetRightContext, |
| 1193 NoOpSetter, DONT_DELETE); | 1199 NoOpSetter, DONT_ENUM); |
| 1194 utils.InstallGetterSetter(GlobalRegExp, "$'", RegExpGetRightContext, NoOpSetter, | 1200 utils.InstallGetterSetter(GlobalRegExp, "$'", RegExpGetRightContext, NoOpSetter, |
| 1195 DONT_ENUM | DONT_DELETE); | 1201 DONT_ENUM); |
| 1196 | 1202 |
| 1197 for (var i = 1; i < 10; ++i) { | 1203 for (var i = 1; i < 10; ++i) { |
| 1198 utils.InstallGetterSetter(GlobalRegExp, '$' + i, RegExpMakeCaptureGetter(i), | 1204 utils.InstallGetterSetter(GlobalRegExp, '$' + i, RegExpMakeCaptureGetter(i), |
| 1199 NoOpSetter, DONT_DELETE); | 1205 NoOpSetter, DONT_ENUM); |
| 1200 } | 1206 } |
| 1201 %ToFastProperties(GlobalRegExp); | 1207 %ToFastProperties(GlobalRegExp); |
| 1202 | 1208 |
| 1203 // ------------------------------------------------------------------- | 1209 // ------------------------------------------------------------------- |
| 1204 // Internal | 1210 // Internal |
| 1205 | 1211 |
| 1206 var InternalRegExpMatchInfo = { | 1212 var InternalRegExpMatchInfo = { |
| 1207 REGEXP_NUMBER_OF_CAPTURES: 2, | 1213 REGEXP_NUMBER_OF_CAPTURES: 2, |
| 1208 REGEXP_LAST_SUBJECT: "", | 1214 REGEXP_LAST_SUBJECT: "", |
| 1209 REGEXP_LAST_INPUT: UNDEFINED, | 1215 REGEXP_LAST_INPUT: UNDEFINED, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1231 to.InternalRegExpMatch = InternalRegExpMatch; | 1237 to.InternalRegExpMatch = InternalRegExpMatch; |
| 1232 to.InternalRegExpReplace = InternalRegExpReplace; | 1238 to.InternalRegExpReplace = InternalRegExpReplace; |
| 1233 to.IsRegExp = IsRegExp; | 1239 to.IsRegExp = IsRegExp; |
| 1234 to.RegExpExec = DoRegExpExec; | 1240 to.RegExpExec = DoRegExpExec; |
| 1235 to.RegExpInitialize = RegExpInitialize; | 1241 to.RegExpInitialize = RegExpInitialize; |
| 1236 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 1242 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
| 1237 to.RegExpTest = RegExpTest; | 1243 to.RegExpTest = RegExpTest; |
| 1238 }); | 1244 }); |
| 1239 | 1245 |
| 1240 }) | 1246 }) |
| OLD | NEW |