| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 // Expects following symbols to be set in the bootstrapper during genesis: | 5 // Expects following symbols to be set in the bootstrapper during genesis: |
| 6 // - symbolHasInstance | 6 // - symbolHasInstance |
| 7 // - symbolIsConcatSpreadable | 7 // - symbolIsConcatSpreadable |
| 8 // - symbolIsRegExp | 8 // - symbolIsRegExp |
| 9 // - symbolIterator | 9 // - symbolIterator |
| 10 // - symbolToStringTag | 10 // - symbolToStringTag |
| 11 // - symbolUnscopables | 11 // - symbolUnscopables |
| 12 | 12 |
| 13 var $symbolToString; | 13 var $symbolToString; |
| 14 | 14 |
| 15 (function(global, utils) { | 15 (function(global, utils) { |
| 16 | 16 |
| 17 "use strict"; | 17 "use strict"; |
| 18 | 18 |
| 19 %CheckIsBootstrapping(); | 19 %CheckIsBootstrapping(); |
| 20 | 20 |
| 21 // ------------------------------------------------------------------- | 21 // ------------------------------------------------------------------- |
| 22 // Imports | 22 // Imports |
| 23 | 23 |
| 24 var GlobalObject = global.Object; | 24 var GlobalObject = global.Object; |
| 25 var GlobalSymbol = global.Symbol; | 25 var GlobalSymbol = global.Symbol; |
| 26 | |
| 27 var ObjectGetOwnPropertyKeys; | 26 var ObjectGetOwnPropertyKeys; |
| 27 var ToString; |
| 28 | 28 |
| 29 utils.Import(function(from) { | 29 utils.Import(function(from) { |
| 30 ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys; | 30 ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys; |
| 31 ToString = from.ToString; |
| 31 }); | 32 }); |
| 32 | 33 |
| 33 // ------------------------------------------------------------------- | 34 // ------------------------------------------------------------------- |
| 34 | 35 |
| 35 function SymbolConstructor(x) { | 36 function SymbolConstructor(x) { |
| 36 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); | 37 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); |
| 37 // NOTE: Passing in a Symbol value will throw on ToString(). | 38 // NOTE: Passing in a Symbol value will throw on ToString(). |
| 38 return %CreateSymbol(IS_UNDEFINED(x) ? x : $toString(x)); | 39 return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 | 42 |
| 42 function SymbolToString() { | 43 function SymbolToString() { |
| 43 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { | 44 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { |
| 44 throw MakeTypeError(kIncompatibleMethodReceiver, | 45 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 45 "Symbol.prototype.toString", this); | 46 "Symbol.prototype.toString", this); |
| 46 } | 47 } |
| 47 var description = %SymbolDescription(%_ValueOf(this)); | 48 var description = %SymbolDescription(%_ValueOf(this)); |
| 48 return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")"; | 49 return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")"; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 "valueOf", SymbolValueOf | 118 "valueOf", SymbolValueOf |
| 118 ]); | 119 ]); |
| 119 | 120 |
| 120 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ | 121 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ |
| 121 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols | 122 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols |
| 122 ]); | 123 ]); |
| 123 | 124 |
| 124 $symbolToString = SymbolToString; | 125 $symbolToString = SymbolToString; |
| 125 | 126 |
| 126 }) | 127 }) |
| OLD | NEW |