Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: src/js/symbol.js

Issue 1498593006: [proxies] Use JSReceiver::GetKeys() for more purposes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GlobalObject = global.Object; 14 var GlobalObject = global.Object;
15 var GlobalSymbol = global.Symbol; 15 var GlobalSymbol = global.Symbol;
16 var hasInstanceSymbol = utils.ImportNow("has_instance_symbol"); 16 var hasInstanceSymbol = utils.ImportNow("has_instance_symbol");
17 var isConcatSpreadableSymbol = 17 var isConcatSpreadableSymbol =
18 utils.ImportNow("is_concat_spreadable_symbol"); 18 utils.ImportNow("is_concat_spreadable_symbol");
19 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 19 var iteratorSymbol = utils.ImportNow("iterator_symbol");
20 var MakeTypeError; 20 var MakeTypeError;
21 var ObjectGetOwnPropertyKeys;
22 var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol"); 21 var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
24 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); 23 var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
25 24
26 utils.Import(function(from) { 25 utils.Import(function(from) {
27 MakeTypeError = from.MakeTypeError; 26 MakeTypeError = from.MakeTypeError;
28 ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
29 }); 27 });
30 28
31 // ------------------------------------------------------------------- 29 // -------------------------------------------------------------------
32 30
33 // 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint ) 31 // 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint )
34 function SymbolToPrimitive(hint) { 32 function SymbolToPrimitive(hint) {
35 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { 33 if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
36 throw MakeTypeError(kIncompatibleMethodReceiver, 34 throw MakeTypeError(kIncompatibleMethodReceiver,
37 "Symbol.prototype [ @@toPrimitive ]", this); 35 "Symbol.prototype [ @@toPrimitive ]", this);
38 } 36 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 function SymbolKeyFor(symbol) { 71 function SymbolKeyFor(symbol) {
74 if (!IS_SYMBOL(symbol)) throw MakeTypeError(kSymbolKeyFor, symbol); 72 if (!IS_SYMBOL(symbol)) throw MakeTypeError(kSymbolKeyFor, symbol);
75 return %SymbolRegistry().keyFor[symbol]; 73 return %SymbolRegistry().keyFor[symbol];
76 } 74 }
77 75
78 76
79 // ES6 19.1.2.8 77 // ES6 19.1.2.8
80 function ObjectGetOwnPropertySymbols(obj) { 78 function ObjectGetOwnPropertySymbols(obj) {
81 obj = TO_OBJECT(obj); 79 obj = TO_OBJECT(obj);
82 80
83 // TODO(arv): Proxies use a shared trap for String and Symbol keys. 81 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_STRINGS);
84
85 return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
86 } 82 }
87 83
88 // ------------------------------------------------------------------- 84 // -------------------------------------------------------------------
89 85
90 %FunctionSetPrototype(GlobalSymbol, new GlobalObject()); 86 %FunctionSetPrototype(GlobalSymbol, new GlobalObject());
91 87
92 utils.InstallConstants(GlobalSymbol, [ 88 utils.InstallConstants(GlobalSymbol, [
93 // TODO(rossberg): expose when implemented. 89 // TODO(rossberg): expose when implemented.
94 // "hasInstance", hasInstanceSymbol, 90 // "hasInstance", hasInstanceSymbol,
95 // "isConcatSpreadable", isConcatSpreadableSymbol, 91 // "isConcatSpreadable", isConcatSpreadableSymbol,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ]); 126 ]);
131 127
132 // ------------------------------------------------------------------- 128 // -------------------------------------------------------------------
133 // Exports 129 // Exports
134 130
135 utils.Export(function(to) { 131 utils.Export(function(to) {
136 to.SymbolToString = SymbolToString; 132 to.SymbolToString = SymbolToString;
137 }) 133 })
138 134
139 }) 135 })
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | src/js/v8natives.js » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698