| 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() { | 15 (function() { |
| 16 | 16 |
| 17 "use strict"; | 17 "use strict"; |
| 18 | 18 |
| 19 %CheckIsBootstrapping(); | 19 %CheckIsBootstrapping(); |
| 20 | 20 |
| 21 var GlobalObject = global.Object; | 21 var GlobalObject = global.Object; |
| 22 var GlobalSymbol = global.Symbol; | 22 var GlobalSymbol = global.Symbol; |
| 23 | 23 |
| 24 // ------------------------------------------------------------------- | 24 // ------------------------------------------------------------------- |
| 25 | 25 |
| 26 function SymbolConstructor(x) { | 26 function SymbolConstructor(x) { |
| 27 if (%_IsConstructCall()) { | 27 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol"); |
| 28 throw MakeTypeError('not_constructor', ["Symbol"]); | |
| 29 } | |
| 30 // NOTE: Passing in a Symbol value will throw on ToString(). | 28 // NOTE: Passing in a Symbol value will throw on ToString(). |
| 31 return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); | 29 return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x)); |
| 32 } | 30 } |
| 33 | 31 |
| 34 | 32 |
| 35 function SymbolToString() { | 33 function SymbolToString() { |
| 36 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { | 34 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { |
| 37 throw MakeTypeError(kIncompatibleMethodReceiver, | 35 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 38 "Symbol.prototype.toString", this); | 36 "Symbol.prototype.toString", this); |
| 39 } | 37 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 "valueOf", SymbolValueOf | 108 "valueOf", SymbolValueOf |
| 111 ]); | 109 ]); |
| 112 | 110 |
| 113 InstallFunctions(GlobalObject, DONT_ENUM, [ | 111 InstallFunctions(GlobalObject, DONT_ENUM, [ |
| 114 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols | 112 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols |
| 115 ]); | 113 ]); |
| 116 | 114 |
| 117 $symbolToString = SymbolToString; | 115 $symbolToString = SymbolToString; |
| 118 | 116 |
| 119 })(); | 117 })(); |
| OLD | NEW |