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

Side by Side Diff: src/objects.cc

Issue 108083005: ES6: Add Object.getOwnPropertySymbols (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment and formatting based on code review Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « src/mirror-debugger.js ('k') | src/property-details.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5906 matching lines...) Expand 10 before | Expand all | Expand 10 after
5917 ASSERT(!curr->HasNamedInterceptor()); 5917 ASSERT(!curr->HasNamedInterceptor());
5918 ASSERT(!curr->HasIndexedInterceptor()); 5918 ASSERT(!curr->HasIndexedInterceptor());
5919 ASSERT(!curr->IsAccessCheckNeeded()); 5919 ASSERT(!curr->IsAccessCheckNeeded());
5920 if (curr->NumberOfEnumElements() > 0) return false; 5920 if (curr->NumberOfEnumElements() > 0) return false;
5921 if (curr != this && enum_length != 0) return false; 5921 if (curr != this && enum_length != 0) return false;
5922 } 5922 }
5923 return true; 5923 return true;
5924 } 5924 }
5925 5925
5926 5926
5927 static bool FilterKey(Object* key, PropertyAttributes filter) {
5928 if ((filter & SYMBOLIC) && key->IsSymbol()) {
5929 return true;
5930 }
5931
5932 if ((filter & PRIVATE_SYMBOL) &&
5933 key->IsSymbol() && Symbol::cast(key)->is_private()) {
5934 return true;
5935 }
5936
5937 if ((filter & STRING) && !key->IsSymbol()) {
5938 return true;
5939 }
5940
5941 return false;
5942 }
5943
5944
5927 int Map::NumberOfDescribedProperties(DescriptorFlag which, 5945 int Map::NumberOfDescribedProperties(DescriptorFlag which,
5928 PropertyAttributes filter) { 5946 PropertyAttributes filter) {
5929 int result = 0; 5947 int result = 0;
5930 DescriptorArray* descs = instance_descriptors(); 5948 DescriptorArray* descs = instance_descriptors();
5931 int limit = which == ALL_DESCRIPTORS 5949 int limit = which == ALL_DESCRIPTORS
5932 ? descs->number_of_descriptors() 5950 ? descs->number_of_descriptors()
5933 : NumberOfOwnDescriptors(); 5951 : NumberOfOwnDescriptors();
5934 for (int i = 0; i < limit; i++) { 5952 for (int i = 0; i < limit; i++) {
5935 if ((descs->GetDetails(i).attributes() & filter) == 0 && 5953 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
5936 ((filter & SYMBOLIC) == 0 || !descs->GetKey(i)->IsSymbol())) { 5954 !FilterKey(descs->GetKey(i), filter)) {
5937 result++; 5955 result++;
5938 } 5956 }
5939 } 5957 }
5940 return result; 5958 return result;
5941 } 5959 }
5942 5960
5943 5961
5944 int Map::NextFreePropertyIndex() { 5962 int Map::NextFreePropertyIndex() {
5945 int max_index = -1; 5963 int max_index = -1;
5946 int number_of_own_descriptors = NumberOfOwnDescriptors(); 5964 int number_of_own_descriptors = NumberOfOwnDescriptors();
(...skipping 7578 matching lines...) Expand 10 before | Expand all | Expand 10 after
13525 // purpose of this function is to provide reflection information for the object 13543 // purpose of this function is to provide reflection information for the object
13526 // mirrors. 13544 // mirrors.
13527 void JSObject::GetLocalPropertyNames( 13545 void JSObject::GetLocalPropertyNames(
13528 FixedArray* storage, int index, PropertyAttributes filter) { 13546 FixedArray* storage, int index, PropertyAttributes filter) {
13529 ASSERT(storage->length() >= (NumberOfLocalProperties(filter) - index)); 13547 ASSERT(storage->length() >= (NumberOfLocalProperties(filter) - index));
13530 if (HasFastProperties()) { 13548 if (HasFastProperties()) {
13531 int real_size = map()->NumberOfOwnDescriptors(); 13549 int real_size = map()->NumberOfOwnDescriptors();
13532 DescriptorArray* descs = map()->instance_descriptors(); 13550 DescriptorArray* descs = map()->instance_descriptors();
13533 for (int i = 0; i < real_size; i++) { 13551 for (int i = 0; i < real_size; i++) {
13534 if ((descs->GetDetails(i).attributes() & filter) == 0 && 13552 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
13535 ((filter & SYMBOLIC) == 0 || !descs->GetKey(i)->IsSymbol())) { 13553 !FilterKey(descs->GetKey(i), filter)) {
13536 storage->set(index++, descs->GetKey(i)); 13554 storage->set(index++, descs->GetKey(i));
13537 } 13555 }
13538 } 13556 }
13539 } else { 13557 } else {
13540 property_dictionary()->CopyKeysTo(storage, 13558 property_dictionary()->CopyKeysTo(storage,
13541 index, 13559 index,
13542 filter, 13560 filter,
13543 NameDictionary::UNSORTED); 13561 NameDictionary::UNSORTED);
13544 } 13562 }
13545 } 13563 }
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
15627 15645
15628 15646
15629 template<typename Shape, typename Key> 15647 template<typename Shape, typename Key>
15630 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( 15648 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes(
15631 PropertyAttributes filter) { 15649 PropertyAttributes filter) {
15632 int capacity = HashTable<Shape, Key>::Capacity(); 15650 int capacity = HashTable<Shape, Key>::Capacity();
15633 int result = 0; 15651 int result = 0;
15634 for (int i = 0; i < capacity; i++) { 15652 for (int i = 0; i < capacity; i++) {
15635 Object* k = HashTable<Shape, Key>::KeyAt(i); 15653 Object* k = HashTable<Shape, Key>::KeyAt(i);
15636 if (HashTable<Shape, Key>::IsKey(k) && 15654 if (HashTable<Shape, Key>::IsKey(k) &&
15637 ((filter & SYMBOLIC) == 0 || !k->IsSymbol())) { 15655 !FilterKey(k, filter)) {
15638 PropertyDetails details = DetailsAt(i); 15656 PropertyDetails details = DetailsAt(i);
15639 if (details.IsDeleted()) continue; 15657 if (details.IsDeleted()) continue;
15640 PropertyAttributes attr = details.attributes(); 15658 PropertyAttributes attr = details.attributes();
15641 if ((attr & filter) == 0) result++; 15659 if ((attr & filter) == 0) result++;
15642 } 15660 }
15643 } 15661 }
15644 return result; 15662 return result;
15645 } 15663 }
15646 15664
15647 15665
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
16632 #define ERROR_MESSAGES_TEXTS(C, T) T, 16650 #define ERROR_MESSAGES_TEXTS(C, T) T,
16633 static const char* error_messages_[] = { 16651 static const char* error_messages_[] = {
16634 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16652 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16635 }; 16653 };
16636 #undef ERROR_MESSAGES_TEXTS 16654 #undef ERROR_MESSAGES_TEXTS
16637 return error_messages_[reason]; 16655 return error_messages_[reason];
16638 } 16656 }
16639 16657
16640 16658
16641 } } // namespace v8::internal 16659 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698