Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index b715e8923ff26184b43d2f5f432e9e5a3cf778d3..73cf49350df8e73bd7f58959b84c0487b9210103 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -1038,6 +1038,77 @@ function ToNameArray(obj, trap, includeSymbols) { |
| } |
| +function GetSymbolsInArray(propertyKeys) { |
|
rossberg
2013/12/10 10:39:53
Nit: perhaps call this FilterPublicSymbols?
arv (Not doing code reviews)
2013/12/11 00:16:26
Done.
|
| + var symbols = new InternalArray(); |
| + var j = 0; |
| + for (var i = 0; i < propertyKeys.length; i++) { |
| + if (IS_SYMBOL(propertyKeys[i]) && !%SymbolIsPrivate(propertyKeys[i])) { |
|
rossberg
2013/12/10 10:39:53
It might make sense to introduce an IS_PRIVATE mac
arv (Not doing code reviews)
2013/12/11 00:16:26
Done.
|
| + symbols[j++] = propertyKeys[i]; |
| + } |
| + } |
| + return symbols; |
| +} |
| + |
| + |
| +// ES6 19.1.2.8 |
| +function ObjectGetOwnPropertySymbols(obj) { |
| + if (!IS_SPEC_OBJECT(obj)) { |
| + throw MakeTypeError("called_on_non_object", |
| + ["Object.getOwnPropertySymbols"]); |
| + } |
| + |
| + // FIXME: Proxies use a shared trap for String and Symbol keys. |
|
rossberg
2013/12/10 10:39:53
Please use TODO(arv); same below
arv (Not doing code reviews)
2013/12/11 00:16:26
Done.
|
| + |
| + var nameArrays = new InternalArray(); |
| + |
| + // Find all the indexed properties. |
| + |
| + // Get names for indexed interceptor properties. |
| + var interceptorInfo = %GetInterceptorInfo(obj); |
| + |
| + // Find all the named properties. |
| + |
| + // Get the local property symbols. |
| + // FIXME: Have the runtime do the filtering. |
|
rossberg
2013/12/10 10:39:53
Yeah, I would very much prefer to have this implem
|
| + nameArrays.push(GetSymbolsInArray(%GetLocalPropertyNames(obj, true))); |
| + |
| + // Get names for named interceptor properties if any. |
| + if ((interceptorInfo & 2) != 0) { |
| + // FIXME: Have the runtime do the filtering. |
| + var namedInterceptorNames = %GetNamedInterceptorPropertyNames(obj); |
| + if (!IS_UNDEFINED(namedInterceptorNames)) { |
| + nameArrays.push(GetSymbolsInArray(namedInterceptorSymbols)); |
| + } |
| + } |
| + |
| + var propertySymbols = |
| + %Apply(InternalArray.prototype.concat, |
| + nameArrays[0], nameArrays, 1, nameArrays.length - 1); |
| + |
| + // Property names are expected to be unique, |
| + // but interceptors can interfere with that assumption. |
| + if (interceptorInfo != 0) { |
| + var propertySet = { __proto__: null }; |
| + var j = 0; |
| + for (var i = 0; i < propertySymbols.length; ++i) { |
| + var symbol = propertySymbols[i]; |
| + if (!IS_SYMBOL(symbol) || %SymbolIsPrivate(symbol)) continue; |
| + |
| + // We need to check for the exact property value since for intrinsic |
| + // properties like toString if(propertySet["toString"]) will always |
| + // succeed. |
| + if (propertySet[symbol] === true) { |
|
rossberg
2013/12/10 10:39:53
Could combine this with the previous if.
arv (Not doing code reviews)
2013/12/11 00:16:26
I also don't think this comment is correct. proper
|
| + continue; |
| + } |
| + propertySet[symbol] = true; |
| + propertySymbols[j++] = symbol; |
| + } |
| + propertySymbols.length = j; |
| + } |
| + |
| + return propertySymbols; |
| +} |
| + |
| // ES5 section 15.2.3.4. |
| function ObjectGetOwnPropertyNames(obj) { |
| if (!IS_SPEC_OBJECT(obj)) { |
| @@ -1420,6 +1491,7 @@ function SetUpObject() { |
| "getPrototypeOf", ObjectGetPrototypeOf, |
| "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
| "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
| + // getOwnPropertySymbols is added in symbol.js |
|
rossberg
2013/12/10 10:39:53
Good to have that comment here. While you're at it
arv (Not doing code reviews)
2013/12/11 00:16:26
Done.
|
| "is", ObjectIs, |
| "isExtensible", ObjectIsExtensible, |
| "isFrozen", ObjectIsFrozen, |