| 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 #include "src/key-accumulator.h" | 5 #include "src/key-accumulator.h" |
| 6 | 6 |
| 7 #include "src/elements.h" | 7 #include "src/elements.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return AddKey(handle(key, isolate_), convert); | 96 return AddKey(handle(key, isolate_), convert); |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 bool KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) { | 100 bool KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) { |
| 101 if (key->IsSymbol()) { | 101 if (key->IsSymbol()) { |
| 102 if (filter_ & SKIP_SYMBOLS) return false; | 102 if (filter_ & SKIP_SYMBOLS) return false; |
| 103 if (Handle<Symbol>::cast(key)->is_private()) return false; | 103 if (Handle<Symbol>::cast(key)->is_private()) return false; |
| 104 return AddSymbolKey(key); | 104 return AddSymbolKey(key); |
| 105 } | 105 } |
| 106 if (filter_ & SKIP_STRINGS) return false; |
| 106 // Make sure we do not add keys to a proxy-level (see AddKeysFromProxy). | 107 // Make sure we do not add keys to a proxy-level (see AddKeysFromProxy). |
| 107 DCHECK_LE(0, level_string_length_); | 108 DCHECK_LE(0, level_string_length_); |
| 108 // In some cases (e.g. proxies) we might get in String-converted ints which | 109 // In some cases (e.g. proxies) we might get in String-converted ints which |
| 109 // should be added to the elements list instead of the properties. For | 110 // should be added to the elements list instead of the properties. For |
| 110 // proxies we have to convert as well but also respect the original order. | 111 // proxies we have to convert as well but also respect the original order. |
| 111 // Therefore we add a converted key to both sides | 112 // Therefore we add a converted key to both sides |
| 112 if (convert == CONVERT_TO_ARRAY_INDEX || convert == PROXY_MAGIC) { | 113 if (convert == CONVERT_TO_ARRAY_INDEX || convert == PROXY_MAGIC) { |
| 113 uint32_t index = 0; | 114 uint32_t index = 0; |
| 114 int prev_length = length_; | 115 int prev_length = length_; |
| 115 int prev_proto = level_string_length_; | 116 int prev_proto = level_string_length_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return keys; | 229 return keys; |
| 229 } | 230 } |
| 230 int store_position = 0; | 231 int store_position = 0; |
| 231 for (int i = 0; i < keys->length(); ++i) { | 232 for (int i = 0; i < keys->length(); ++i) { |
| 232 Handle<Name> key(Name::cast(keys->get(i)), isolate); | 233 Handle<Name> key(Name::cast(keys->get(i)), isolate); |
| 233 if (key->IsSymbol()) { | 234 if (key->IsSymbol()) { |
| 234 if ((filter & SKIP_SYMBOLS) || Handle<Symbol>::cast(key)->is_private()) { | 235 if ((filter & SKIP_SYMBOLS) || Handle<Symbol>::cast(key)->is_private()) { |
| 235 continue; // Skip this key. | 236 continue; // Skip this key. |
| 236 } | 237 } |
| 237 } | 238 } |
| 239 if (filter & SKIP_STRINGS) continue; // Skip this key. |
| 238 if (filter & ONLY_ENUMERABLE) { | 240 if (filter & ONLY_ENUMERABLE) { |
| 239 PropertyDescriptor desc; | 241 PropertyDescriptor desc; |
| 240 bool found = | 242 bool found = |
| 241 JSProxy::GetOwnPropertyDescriptor(isolate, owner, key, &desc); | 243 JSProxy::GetOwnPropertyDescriptor(isolate, owner, key, &desc); |
| 242 if (isolate->has_pending_exception()) return MaybeHandle<FixedArray>(); | 244 if (isolate->has_pending_exception()) return MaybeHandle<FixedArray>(); |
| 243 if (!found || !desc.enumerable()) continue; // Skip this key. | 245 if (!found || !desc.enumerable()) continue; // Skip this key. |
| 244 } | 246 } |
| 245 // Keep this key. | 247 // Keep this key. |
| 246 if (store_position != i) { | 248 if (store_position != i) { |
| 247 keys->set(store_position, *key); | 249 keys->set(store_position, *key); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 level_lengths_.push_back(level_symbol_length_); | 310 level_lengths_.push_back(level_symbol_length_); |
| 309 } | 311 } |
| 310 elements_.push_back(new std::vector<uint32_t>()); | 312 elements_.push_back(new std::vector<uint32_t>()); |
| 311 level_string_length_ = 0; | 313 level_string_length_ = 0; |
| 312 level_symbol_length_ = 0; | 314 level_symbol_length_ = 0; |
| 313 } | 315 } |
| 314 | 316 |
| 315 | 317 |
| 316 } // namespace internal | 318 } // namespace internal |
| 317 } // namespace v8 | 319 } // namespace v8 |
| OLD | NEW |