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 'use strict'; | 7 'use strict'; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var ExpandReplacement; | 14 var ExpandReplacement; |
15 var GlobalArray = global.Array; | 15 var GlobalArray = global.Array; |
16 var GlobalObject = global.Object; | 16 var GlobalObject = global.Object; |
17 var GlobalRegExp = global.RegExp; | 17 var GlobalRegExp = global.RegExp; |
18 var GlobalRegExpPrototype; | 18 var GlobalRegExpPrototype; |
19 var InternalArray = utils.InternalArray; | 19 var InternalArray = utils.InternalArray; |
20 var InternalPackedArray = utils.InternalPackedArray; | 20 var InternalPackedArray = utils.InternalPackedArray; |
21 var MakeTypeError; | 21 var MakeTypeError; |
22 var MaxSimple; | 22 var MaxSimple; |
23 var MinSimple; | 23 var MinSimple; |
24 var matchSymbol = utils.ImportNow("match_symbol"); | 24 var matchSymbol = utils.ImportNow("match_symbol"); |
25 var replaceSymbol = utils.ImportNow("replace_symbol"); | 25 var replaceSymbol = utils.ImportNow("replace_symbol"); |
26 var searchSymbol = utils.ImportNow("search_symbol"); | 26 var searchSymbol = utils.ImportNow("search_symbol"); |
27 var speciesSymbol = utils.ImportNow("species_symbol"); | |
27 var splitSymbol = utils.ImportNow("split_symbol"); | 28 var splitSymbol = utils.ImportNow("split_symbol"); |
28 var SpeciesConstructor; | 29 var SpeciesConstructor; |
29 | 30 |
30 utils.Import(function(from) { | 31 utils.Import(function(from) { |
31 ExpandReplacement = from.ExpandReplacement; | 32 ExpandReplacement = from.ExpandReplacement; |
32 MakeTypeError = from.MakeTypeError; | 33 MakeTypeError = from.MakeTypeError; |
33 MaxSimple = from.MaxSimple; | 34 MaxSimple = from.MaxSimple; |
34 MinSimple = from.MinSimple; | 35 MinSimple = from.MinSimple; |
35 SpeciesConstructor = from.SpeciesConstructor; | 36 SpeciesConstructor = from.SpeciesConstructor; |
36 }); | 37 }); |
(...skipping 1090 matching lines...) Loading... | |
1127 if (this === GlobalRegExpPrototype) { | 1128 if (this === GlobalRegExpPrototype) { |
1128 %IncrementUseCounter(kRegExpPrototypeStickyGetter); | 1129 %IncrementUseCounter(kRegExpPrototypeStickyGetter); |
1129 return UNDEFINED; | 1130 return UNDEFINED; |
1130 } | 1131 } |
1131 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky"); | 1132 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky"); |
1132 } | 1133 } |
1133 return TO_BOOLEAN(REGEXP_STICKY(this)); | 1134 return TO_BOOLEAN(REGEXP_STICKY(this)); |
1134 } | 1135 } |
1135 %SetForceInlineFlag(RegExpGetSticky); | 1136 %SetForceInlineFlag(RegExpGetSticky); |
1136 | 1137 |
1138 | |
1139 // ES6 21.2.5.15. | |
1140 function RegExpGetUnicode() { | |
1141 if (!IS_REGEXP(this)) { | |
1142 // TODO(littledan): Remove this RegExp compat workaround | |
1143 if (this === GlobalRegExpPrototype) { | |
1144 %IncrementUseCounter(kRegExpPrototypeUnicodeGetter); | |
1145 return UNDEFINED; | |
1146 } | |
1147 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode"); | |
1148 } | |
1149 return TO_BOOLEAN(REGEXP_UNICODE(this)); | |
1150 } | |
1151 %SetForceInlineFlag(RegExpGetUnicode); | |
1152 | |
1153 | |
1154 function RegExpSpecies() { | |
1155 return this; | |
1156 } | |
1157 | |
1158 | |
1137 // ------------------------------------------------------------------- | 1159 // ------------------------------------------------------------------- |
1138 | 1160 |
1139 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); | 1161 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); |
1140 GlobalRegExpPrototype = new GlobalObject(); | 1162 GlobalRegExpPrototype = new GlobalObject(); |
1141 %FunctionSetPrototype(GlobalRegExp, GlobalRegExpPrototype); | 1163 %FunctionSetPrototype(GlobalRegExp, GlobalRegExpPrototype); |
1142 %AddNamedProperty( | 1164 %AddNamedProperty( |
1143 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); | 1165 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); |
1144 %SetCode(GlobalRegExp, RegExpConstructor); | 1166 %SetCode(GlobalRegExp, RegExpConstructor); |
1145 | 1167 |
1168 utils.InstallGetter(GlobalRegExp, speciesSymbol, RegExpSpecies); | |
1169 | |
1146 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ | 1170 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ |
1147 "exec", RegExpExecJS, | 1171 "exec", RegExpSubclassExecJS, |
1148 "test", RegExpTest, | 1172 "test", RegExpSubclassTest, |
1149 "toString", RegExpToString, | 1173 "toString", RegExpToString, |
1150 "compile", RegExpCompileJS, | 1174 "compile", RegExpCompileJS, |
1151 matchSymbol, RegExpMatch, | 1175 matchSymbol, RegExpSubclassMatch, |
1152 replaceSymbol, RegExpReplace, | 1176 replaceSymbol, RegExpSubclassReplace, |
1153 searchSymbol, RegExpSearch, | 1177 searchSymbol, RegExpSubclassSearch, |
Dan Ehrenberg
2016/06/23 23:53:52
RegExpMatch and RegExpSearch are now dead code.
adamk
2016/06/24 00:08:27
Oops, meant to clean those up but failed. Removed.
| |
1154 splitSymbol, RegExpSplit, | 1178 splitSymbol, RegExpSubclassSplit, |
1155 ]); | 1179 ]); |
1156 | 1180 |
1157 utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags); | 1181 utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags); |
1158 utils.InstallGetter(GlobalRegExp.prototype, 'global', RegExpGetGlobal); | 1182 utils.InstallGetter(GlobalRegExp.prototype, 'global', RegExpGetGlobal); |
1159 utils.InstallGetter(GlobalRegExp.prototype, 'ignoreCase', RegExpGetIgnoreCase); | 1183 utils.InstallGetter(GlobalRegExp.prototype, 'ignoreCase', RegExpGetIgnoreCase); |
1160 utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline); | 1184 utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline); |
1161 utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource); | 1185 utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource); |
1162 utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky); | 1186 utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky); |
1187 utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode); | |
1163 | 1188 |
1164 // The properties `input` and `$_` are aliases for each other. When this | 1189 // The properties `input` and `$_` are aliases for each other. When this |
1165 // value is set the value it is set to is coerced to a string. | 1190 // value is set the value it is set to is coerced to a string. |
1166 // Getter and setter for the input. | 1191 // Getter and setter for the input. |
1167 var RegExpGetInput = function() { | 1192 var RegExpGetInput = function() { |
1168 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); | 1193 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); |
1169 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; | 1194 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
1170 }; | 1195 }; |
1171 var RegExpSetInput = function(string) { | 1196 var RegExpSetInput = function(string) { |
1172 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); | 1197 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); |
(...skipping 54 matching lines...) Loading... | |
1227 // ------------------------------------------------------------------- | 1252 // ------------------------------------------------------------------- |
1228 // Exports | 1253 // Exports |
1229 | 1254 |
1230 utils.Export(function(to) { | 1255 utils.Export(function(to) { |
1231 to.InternalRegExpMatch = InternalRegExpMatch; | 1256 to.InternalRegExpMatch = InternalRegExpMatch; |
1232 to.InternalRegExpReplace = InternalRegExpReplace; | 1257 to.InternalRegExpReplace = InternalRegExpReplace; |
1233 to.IsRegExp = IsRegExp; | 1258 to.IsRegExp = IsRegExp; |
1234 to.RegExpExec = DoRegExpExec; | 1259 to.RegExpExec = DoRegExpExec; |
1235 to.RegExpInitialize = RegExpInitialize; | 1260 to.RegExpInitialize = RegExpInitialize; |
1236 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 1261 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
1237 to.RegExpSubclassExecJS = RegExpSubclassExecJS; | |
1238 to.RegExpSubclassMatch = RegExpSubclassMatch; | |
1239 to.RegExpSubclassReplace = RegExpSubclassReplace; | |
1240 to.RegExpSubclassSearch = RegExpSubclassSearch; | |
1241 to.RegExpSubclassSplit = RegExpSubclassSplit; | |
1242 to.RegExpSubclassTest = RegExpSubclassTest; | |
1243 to.RegExpTest = RegExpTest; | 1262 to.RegExpTest = RegExpTest; |
1244 }); | 1263 }); |
1245 | 1264 |
1246 }) | 1265 }) |
OLD | NEW |