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 MathMax; | 18 var MathMax; |
19 var MathMin; | 19 var MathMin; |
20 var RegExpExec; | 20 var RegExpExec; |
21 var RegExpExecNoTests; | 21 var RegExpExecNoTests; |
22 var RegExpLastMatchInfo; | 22 var RegExpLastMatchInfo; |
| 23 var SymbolToString; |
23 var ToNumber; | 24 var ToNumber; |
24 var ToString; | 25 var ToString; |
25 | 26 |
26 utils.Import(function(from) { | 27 utils.Import(function(from) { |
27 ArrayIndexOf = from.ArrayIndexOf; | 28 ArrayIndexOf = from.ArrayIndexOf; |
28 ArrayJoin = from.ArrayJoin; | 29 ArrayJoin = from.ArrayJoin; |
29 MathMax = from.MathMax; | 30 MathMax = from.MathMax; |
30 MathMin = from.MathMin; | 31 MathMin = from.MathMin; |
31 RegExpExec = from.RegExpExec; | 32 RegExpExec = from.RegExpExec; |
32 RegExpExecNoTests = from.RegExpExecNoTests; | 33 RegExpExecNoTests = from.RegExpExecNoTests; |
33 RegExpLastMatchInfo = from.RegExpLastMatchInfo; | 34 RegExpLastMatchInfo = from.RegExpLastMatchInfo; |
| 35 SymbolToString = from.SymbolToString; |
34 ToNumber = from.ToNumber; | 36 ToNumber = from.ToNumber; |
35 ToString = from.ToString; | 37 ToString = from.ToString; |
36 }); | 38 }); |
37 | 39 |
38 //------------------------------------------------------------------- | 40 //------------------------------------------------------------------- |
39 | 41 |
40 function StringConstructor(x) { | 42 function StringConstructor(x) { |
41 if (%_ArgumentsLength() == 0) x = ''; | 43 if (%_ArgumentsLength() == 0) x = ''; |
42 if (%_IsConstructCall()) { | 44 if (%_IsConstructCall()) { |
43 %_SetValueOf(this, TO_STRING_INLINE(x)); | 45 %_SetValueOf(this, TO_STRING_INLINE(x)); |
44 } else { | 46 } else { |
45 return IS_SYMBOL(x) ? | 47 return IS_SYMBOL(x) ? |
46 %_CallFunction(x, $symbolToString) : TO_STRING_INLINE(x); | 48 %_CallFunction(x, SymbolToString) : TO_STRING_INLINE(x); |
47 } | 49 } |
48 } | 50 } |
49 | 51 |
50 | 52 |
51 // ECMA-262 section 15.5.4.2 | 53 // ECMA-262 section 15.5.4.2 |
52 function StringToString() { | 54 function StringToString() { |
53 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { | 55 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
54 throw MakeTypeError(kNotGeneric, 'String.prototype.toString'); | 56 throw MakeTypeError(kNotGeneric, 'String.prototype.toString'); |
55 } | 57 } |
56 return %_ValueOf(this); | 58 return %_ValueOf(this); |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 to.StringLastIndexOf = StringLastIndexOfJS; | 1206 to.StringLastIndexOf = StringLastIndexOfJS; |
1205 to.StringMatch = StringMatchJS; | 1207 to.StringMatch = StringMatchJS; |
1206 to.StringReplace = StringReplace; | 1208 to.StringReplace = StringReplace; |
1207 to.StringSlice = StringSlice; | 1209 to.StringSlice = StringSlice; |
1208 to.StringSplit = StringSplitJS; | 1210 to.StringSplit = StringSplitJS; |
1209 to.StringSubstr = StringSubstr; | 1211 to.StringSubstr = StringSubstr; |
1210 to.StringSubstring = StringSubstring; | 1212 to.StringSubstring = StringSubstring; |
1211 }); | 1213 }); |
1212 | 1214 |
1213 }) | 1215 }) |
OLD | NEW |