| 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 // This file relies on the fact that the following declaration has been made | 5 // This file relies on the fact that the following declaration has been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $String = global.String; | 7 // var $String = global.String; |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| 11 function StringConstructor(x) { | 11 function StringConstructor(x) { |
| 12 var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x); | 12 if (%_ArgumentsLength() == 0) x = ''; |
| 13 if (%_IsConstructCall()) { | 13 if (%_IsConstructCall()) { |
| 14 %_SetValueOf(this, value); | 14 %_SetValueOf(this, TO_STRING_INLINE(x)); |
| 15 } else { | 15 } else { |
| 16 return value; | 16 return IS_SYMBOL(x) ? |
| 17 %_CallFunction(x, SymbolToString) : TO_STRING_INLINE(x); |
| 17 } | 18 } |
| 18 } | 19 } |
| 19 | 20 |
| 20 | 21 |
| 21 // ECMA-262 section 15.5.4.2 | 22 // ECMA-262 section 15.5.4.2 |
| 22 function StringToString() { | 23 function StringToString() { |
| 23 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { | 24 if (!IS_STRING(this) && !IS_STRING_WRAPPER(this)) { |
| 24 throw new $TypeError('String.prototype.toString is not generic'); | 25 throw new $TypeError('String.prototype.toString is not generic'); |
| 25 } | 26 } |
| 26 return %_ValueOf(this); | 27 return %_ValueOf(this); |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 "fixed", StringFixed, | 976 "fixed", StringFixed, |
| 976 "italics", StringItalics, | 977 "italics", StringItalics, |
| 977 "small", StringSmall, | 978 "small", StringSmall, |
| 978 "strike", StringStrike, | 979 "strike", StringStrike, |
| 979 "sub", StringSub, | 980 "sub", StringSub, |
| 980 "sup", StringSup | 981 "sup", StringSup |
| 981 )); | 982 )); |
| 982 } | 983 } |
| 983 | 984 |
| 984 SetUpString(); | 985 SetUpString(); |
| OLD | NEW |