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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 // TODO(arv): Proxies use a shared trap for String and Symbol keys. | 77 // TODO(arv): Proxies use a shared trap for String and Symbol keys. |
78 | 78 |
79 return ObjectGetOwnPropertyKeys(obj, true); | 79 return ObjectGetOwnPropertyKeys(obj, true); |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 //------------------------------------------------------------------- | 83 //------------------------------------------------------------------- |
84 | 84 |
85 var symbolCreate = InternalSymbol("Symbol.create"); | |
86 var symbolHasInstance = InternalSymbol("Symbol.hasInstance"); | 85 var symbolHasInstance = InternalSymbol("Symbol.hasInstance"); |
87 var symbolIsConcatSpreadable = InternalSymbol("Symbol.isConcatSpreadable"); | 86 var symbolIsConcatSpreadable = InternalSymbol("Symbol.isConcatSpreadable"); |
88 var symbolIsRegExp = InternalSymbol("Symbol.isRegExp"); | 87 var symbolIsRegExp = InternalSymbol("Symbol.isRegExp"); |
89 var symbolIterator = InternalSymbol("Symbol.iterator"); | 88 var symbolIterator = InternalSymbol("Symbol.iterator"); |
90 var symbolToStringTag = InternalSymbol("Symbol.toStringTag"); | 89 var symbolToStringTag = InternalSymbol("Symbol.toStringTag"); |
91 var symbolUnscopables = InternalSymbol("Symbol.unscopables"); | 90 var symbolUnscopables = InternalSymbol("Symbol.unscopables"); |
92 | 91 |
93 | 92 |
94 //------------------------------------------------------------------- | 93 //------------------------------------------------------------------- |
95 | 94 |
96 function SetUpSymbol() { | 95 function SetUpSymbol() { |
97 %CheckIsBootstrapping(); | 96 %CheckIsBootstrapping(); |
98 | 97 |
99 %SetCode($Symbol, SymbolConstructor); | 98 %SetCode($Symbol, SymbolConstructor); |
100 %FunctionSetPrototype($Symbol, new $Object()); | 99 %FunctionSetPrototype($Symbol, new $Object()); |
101 | 100 |
102 InstallConstants($Symbol, $Array( | 101 InstallConstants($Symbol, $Array( |
103 "create", symbolCreate, | 102 // TODO(rossberg): expose when implemented. |
104 "hasInstance", symbolHasInstance, | 103 // "hasInstance", symbolHasInstance, |
105 "isConcatSpreadable", symbolIsConcatSpreadable, | 104 // "isConcatSpreadable", symbolIsConcatSpreadable, |
106 "isRegExp", symbolIsRegExp, | 105 // "isRegExp", symbolIsRegExp, |
107 "iterator", symbolIterator, | 106 "iterator", symbolIterator |
108 "toStringTag", symbolToStringTag, | 107 // "toStringTag", symbolToStringTag, |
109 "unscopables", symbolUnscopables | 108 // "unscopables", symbolUnscopables |
110 )); | 109 )); |
111 InstallFunctions($Symbol, DONT_ENUM, $Array( | 110 InstallFunctions($Symbol, DONT_ENUM, $Array( |
112 "for", SymbolFor, | 111 "for", SymbolFor, |
113 "keyFor", SymbolKeyFor | 112 "keyFor", SymbolKeyFor |
114 )); | 113 )); |
115 | 114 |
116 %AddNamedProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); | 115 %AddNamedProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
117 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( | 116 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
118 "toString", SymbolToString, | 117 "toString", SymbolToString, |
119 "valueOf", SymbolValueOf | 118 "valueOf", SymbolValueOf |
120 )); | 119 )); |
121 } | 120 } |
122 | 121 |
123 SetUpSymbol(); | 122 SetUpSymbol(); |
124 | 123 |
125 | 124 |
126 function ExtendObject() { | 125 function ExtendObject() { |
127 %CheckIsBootstrapping(); | 126 %CheckIsBootstrapping(); |
128 | 127 |
129 InstallFunctions($Object, DONT_ENUM, $Array( | 128 InstallFunctions($Object, DONT_ENUM, $Array( |
130 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols | 129 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols |
131 )); | 130 )); |
132 } | 131 } |
133 | 132 |
134 ExtendObject(); | 133 ExtendObject(); |
OLD | NEW |