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 var $stringCharAt; | 5 var $stringCharAt; |
6 var $stringIndexOf; | 6 var $stringIndexOf; |
7 var $stringSubstring; | 7 var $stringSubstring; |
8 | 8 |
9 (function() { | 9 (function() { |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 // ECMA-262 section 15.5.4.3 | 39 // ECMA-262 section 15.5.4.3 |
40 function StringValueOf() { | 40 function StringValueOf() { |
41 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { | 41 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
42 throw new $TypeError('String.prototype.valueOf is not generic'); | 42 throw new $TypeError('String.prototype.valueOf is not generic'); |
43 } | 43 } |
44 return %_ValueOf(this); | 44 return %_ValueOf(this); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 // ECMA-262, section 15.5.4.4 | 48 // ECMA-262, section 15.5.4.4 |
49 function StringCharAt(pos) { | 49 function StringCharAtJS(pos) { |
50 CHECK_OBJECT_COERCIBLE(this, "String.prototype.charAt"); | 50 CHECK_OBJECT_COERCIBLE(this, "String.prototype.charAt"); |
51 | 51 |
52 var result = %_StringCharAt(this, pos); | 52 var result = %_StringCharAt(this, pos); |
53 if (%_IsSmi(result)) { | 53 if (%_IsSmi(result)) { |
54 result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); | 54 result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); |
55 } | 55 } |
56 return result; | 56 return result; |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 // ECMA-262 section 15.5.4.5 | 60 // ECMA-262 section 15.5.4.5 |
61 function StringCharCodeAt(pos) { | 61 function StringCharCodeAtJS(pos) { |
62 CHECK_OBJECT_COERCIBLE(this, "String.prototype.charCodeAt"); | 62 CHECK_OBJECT_COERCIBLE(this, "String.prototype.charCodeAt"); |
63 | 63 |
64 var result = %_StringCharCodeAt(this, pos); | 64 var result = %_StringCharCodeAt(this, pos); |
65 if (!%_IsSmi(result)) { | 65 if (!%_IsSmi(result)) { |
66 result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); | 66 result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); |
67 } | 67 } |
68 return result; | 68 return result; |
69 } | 69 } |
70 | 70 |
71 | 71 |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 | 943 |
944 // Set up the non-enumerable functions on the String object. | 944 // Set up the non-enumerable functions on the String object. |
945 InstallFunctions(GlobalString, DONT_ENUM, GlobalArray( | 945 InstallFunctions(GlobalString, DONT_ENUM, GlobalArray( |
946 "fromCharCode", StringFromCharCode | 946 "fromCharCode", StringFromCharCode |
947 )); | 947 )); |
948 | 948 |
949 // Set up the non-enumerable functions on the String prototype object. | 949 // Set up the non-enumerable functions on the String prototype object. |
950 InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray( | 950 InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray( |
951 "valueOf", StringValueOf, | 951 "valueOf", StringValueOf, |
952 "toString", StringToString, | 952 "toString", StringToString, |
953 "charAt", StringCharAt, | 953 "charAt", StringCharAtJS, |
954 "charCodeAt", StringCharCodeAt, | 954 "charCodeAt", StringCharCodeAtJS, |
955 "concat", StringConcat, | 955 "concat", StringConcat, |
956 "indexOf", StringIndexOfJS, | 956 "indexOf", StringIndexOfJS, |
957 "lastIndexOf", StringLastIndexOfJS, | 957 "lastIndexOf", StringLastIndexOfJS, |
958 "localeCompare", StringLocaleCompareJS, | 958 "localeCompare", StringLocaleCompareJS, |
959 "match", StringMatchJS, | 959 "match", StringMatchJS, |
960 "normalize", StringNormalizeJS, | 960 "normalize", StringNormalizeJS, |
961 "replace", StringReplace, | 961 "replace", StringReplace, |
962 "search", StringSearch, | 962 "search", StringSearch, |
963 "slice", StringSlice, | 963 "slice", StringSlice, |
964 "split", StringSplitJS, | 964 "split", StringSplitJS, |
(...skipping 14 matching lines...) Expand all Loading... |
979 "blink", StringBlink, | 979 "blink", StringBlink, |
980 "bold", StringBold, | 980 "bold", StringBold, |
981 "fixed", StringFixed, | 981 "fixed", StringFixed, |
982 "italics", StringItalics, | 982 "italics", StringItalics, |
983 "small", StringSmall, | 983 "small", StringSmall, |
984 "strike", StringStrike, | 984 "strike", StringStrike, |
985 "sub", StringSub, | 985 "sub", StringSub, |
986 "sup", StringSup | 986 "sup", StringSup |
987 )); | 987 )); |
988 | 988 |
989 $stringCharAt = StringCharAt; | 989 $stringCharAt = StringCharAtJS; |
990 $stringIndexOf = StringIndexOfJS; | 990 $stringIndexOf = StringIndexOfJS; |
991 $stringSubstring = StringSubstring; | 991 $stringSubstring = StringSubstring; |
992 | 992 |
993 })(); | 993 })(); |
OLD | NEW |