| 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 |
| 11 | 11 |
| 12 var ArrayIndexOf; | 12 var ArrayIndexOf; |
| 13 var ArrayJoin; | 13 var ArrayJoin; |
| 14 var GlobalRegExp = global.RegExp; | 14 var GlobalRegExp = global.RegExp; |
| 15 var GlobalString = global.String; | 15 var GlobalString = global.String; |
| 16 var InternalArray = utils.InternalArray; | 16 var InternalArray = utils.InternalArray; |
| 17 var InternalPackedArray = utils.InternalPackedArray; | 17 var InternalPackedArray = utils.InternalPackedArray; |
| 18 var IsRegExp; | 18 var IsRegExp; |
| 19 var MakeRangeError; | 19 var MakeRangeError; |
| 20 var MakeTypeError; | 20 var MakeTypeError; |
| 21 var MaxSimple; | 21 var MaxSimple; |
| 22 var MinSimple; | 22 var MinSimple; |
| 23 var matchSymbol = utils.ImportNow("match_symbol"); | 23 var matchSymbol = utils.ImportNow("match_symbol"); |
| 24 var RegExpExecNoTests; | |
| 25 var replaceSymbol = utils.ImportNow("replace_symbol"); | 24 var replaceSymbol = utils.ImportNow("replace_symbol"); |
| 26 var searchSymbol = utils.ImportNow("search_symbol"); | 25 var searchSymbol = utils.ImportNow("search_symbol"); |
| 27 var splitSymbol = utils.ImportNow("split_symbol"); | 26 var splitSymbol = utils.ImportNow("split_symbol"); |
| 28 | 27 |
| 29 utils.Import(function(from) { | 28 utils.Import(function(from) { |
| 30 ArrayIndexOf = from.ArrayIndexOf; | 29 ArrayIndexOf = from.ArrayIndexOf; |
| 31 ArrayJoin = from.ArrayJoin; | 30 ArrayJoin = from.ArrayJoin; |
| 32 IsRegExp = from.IsRegExp; | 31 IsRegExp = from.IsRegExp; |
| 33 MakeRangeError = from.MakeRangeError; | 32 MakeRangeError = from.MakeRangeError; |
| 34 MakeTypeError = from.MakeTypeError; | 33 MakeTypeError = from.MakeTypeError; |
| 35 MaxSimple = from.MaxSimple; | 34 MaxSimple = from.MaxSimple; |
| 36 MinSimple = from.MinSimple; | 35 MinSimple = from.MinSimple; |
| 37 RegExpExecNoTests = from.RegExpExecNoTests; | |
| 38 }); | 36 }); |
| 39 | 37 |
| 40 //------------------------------------------------------------------- | 38 //------------------------------------------------------------------- |
| 41 | 39 |
| 42 // ECMA-262 section 15.5.4.2 | 40 // ECMA-262 section 15.5.4.2 |
| 43 function StringToString() { | 41 function StringToString() { |
| 44 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { | 42 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
| 45 throw MakeTypeError(kNotGeneric, 'String.prototype.toString'); | 43 throw MakeTypeError(kNotGeneric, 'String.prototype.toString'); |
| 46 } | 44 } |
| 47 return %_ValueOf(this); | 45 return %_ValueOf(this); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 var matcher = pattern[matchSymbol]; | 154 var matcher = pattern[matchSymbol]; |
| 157 if (!IS_UNDEFINED(matcher)) { | 155 if (!IS_UNDEFINED(matcher)) { |
| 158 return %_Call(matcher, pattern, this); | 156 return %_Call(matcher, pattern, this); |
| 159 } | 157 } |
| 160 } | 158 } |
| 161 | 159 |
| 162 var subject = TO_STRING(this); | 160 var subject = TO_STRING(this); |
| 163 | 161 |
| 164 // Non-regexp argument. | 162 // Non-regexp argument. |
| 165 var regexp = new GlobalRegExp(pattern); | 163 var regexp = new GlobalRegExp(pattern); |
| 166 return RegExpExecNoTests(regexp, subject, 0); | 164 return regexp[matchSymbol](subject); |
| 167 } | 165 } |
| 168 | 166 |
| 169 | 167 |
| 170 // ECMA-262 v6, section 21.1.3.12 | 168 // ECMA-262 v6, section 21.1.3.12 |
| 171 // | 169 // |
| 172 // For now we do nothing, as proper normalization requires big tables. | 170 // For now we do nothing, as proper normalization requires big tables. |
| 173 // If Intl is enabled, then i18n.js will override it and provide the the | 171 // If Intl is enabled, then i18n.js will override it and provide the the |
| 174 // proper functionality. | 172 // proper functionality. |
| 175 function StringNormalize(formArg) { // length == 0 | 173 function StringNormalize(formArg) { // length == 0 |
| 176 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 174 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 to.StringLastIndexOf = StringLastIndexOf; | 921 to.StringLastIndexOf = StringLastIndexOf; |
| 924 to.StringMatch = StringMatchJS; | 922 to.StringMatch = StringMatchJS; |
| 925 to.StringReplace = StringReplace; | 923 to.StringReplace = StringReplace; |
| 926 to.StringSlice = StringSlice; | 924 to.StringSlice = StringSlice; |
| 927 to.StringSplit = StringSplitJS; | 925 to.StringSplit = StringSplitJS; |
| 928 to.StringSubstr = StringSubstr; | 926 to.StringSubstr = StringSubstr; |
| 929 to.StringSubstring = StringSubstring; | 927 to.StringSubstring = StringSubstring; |
| 930 }); | 928 }); |
| 931 | 929 |
| 932 }) | 930 }) |
| OLD | NEW |