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

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: rename a var Created 7 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 | Annotate | Revision Log
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 5893 matching lines...) Expand 10 before | Expand all | Expand 10 after
5904 ASSERT(!curr->HasNamedInterceptor()); 5904 ASSERT(!curr->HasNamedInterceptor());
5905 ASSERT(!curr->HasIndexedInterceptor()); 5905 ASSERT(!curr->HasIndexedInterceptor());
5906 ASSERT(!curr->IsAccessCheckNeeded()); 5906 ASSERT(!curr->IsAccessCheckNeeded());
5907 if (curr->NumberOfEnumElements() > 0) return false; 5907 if (curr->NumberOfEnumElements() > 0) return false;
5908 if (curr != this && enum_length != 0) return false; 5908 if (curr != this && enum_length != 0) return false;
5909 } 5909 }
5910 return true; 5910 return true;
5911 } 5911 }
5912 5912
5913 5913
5914 static bool FilterKey(Object* key, PropertyAttributes filter) {
5915 if (key->IsSymbol()) {
rossberg 2013/12/18 16:50:12 I would prefer to turn this inside out and do the
arv (Not doing code reviews) 2013/12/18 18:07:12 Done. However, these filters are not mutually exc
5916 if (filter & SYMBOLIC) return true;
5917 if ((filter & PRIVATE_SYMBOL) && Symbol::cast(key)->is_private()) {
5918 return true;
5919 }
5920 } else {
5921 if (filter & STRING) return true;
5922 }
5923 return false;
5924 }
5925
5926
5914 int Map::NumberOfDescribedProperties(DescriptorFlag which, 5927 int Map::NumberOfDescribedProperties(DescriptorFlag which,
5915 PropertyAttributes filter) { 5928 PropertyAttributes filter) {
5916 int result = 0; 5929 int result = 0;
5917 DescriptorArray* descs = instance_descriptors(); 5930 DescriptorArray* descs = instance_descriptors();
5918 int limit = which == ALL_DESCRIPTORS 5931 int limit = which == ALL_DESCRIPTORS
5919 ? descs->number_of_descriptors() 5932 ? descs->number_of_descriptors()
5920 : NumberOfOwnDescriptors(); 5933 : NumberOfOwnDescriptors();
5921 for (int i = 0; i < limit; i++) { 5934 for (int i = 0; i < limit; i++) {
5922 if ((descs->GetDetails(i).attributes() & filter) == 0 && 5935 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
5923 ((filter & SYMBOLIC) == 0 || !descs->GetKey(i)->IsSymbol())) { 5936 !FilterKey(descs->GetKey(i), filter)) {
5924 result++; 5937 result++;
5925 } 5938 }
5926 } 5939 }
5927 return result; 5940 return result;
5928 } 5941 }
5929 5942
5930 5943
5931 int Map::NextFreePropertyIndex() { 5944 int Map::NextFreePropertyIndex() {
5932 int max_index = -1; 5945 int max_index = -1;
5933 int number_of_own_descriptors = NumberOfOwnDescriptors(); 5946 int number_of_own_descriptors = NumberOfOwnDescriptors();
(...skipping 7610 matching lines...) Expand 10 before | Expand all | Expand 10 after
13544 // purpose of this function is to provide reflection information for the object 13557 // purpose of this function is to provide reflection information for the object
13545 // mirrors. 13558 // mirrors.
13546 void JSObject::GetLocalPropertyNames( 13559 void JSObject::GetLocalPropertyNames(
13547 FixedArray* storage, int index, PropertyAttributes filter) { 13560 FixedArray* storage, int index, PropertyAttributes filter) {
13548 ASSERT(storage->length() >= (NumberOfLocalProperties(filter) - index)); 13561 ASSERT(storage->length() >= (NumberOfLocalProperties(filter) - index));
13549 if (HasFastProperties()) { 13562 if (HasFastProperties()) {
13550 int real_size = map()->NumberOfOwnDescriptors(); 13563 int real_size = map()->NumberOfOwnDescriptors();
13551 DescriptorArray* descs = map()->instance_descriptors(); 13564 DescriptorArray* descs = map()->instance_descriptors();
13552 for (int i = 0; i < real_size; i++) { 13565 for (int i = 0; i < real_size; i++) {
13553 if ((descs->GetDetails(i).attributes() & filter) == 0 && 13566 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
13554 ((filter & SYMBOLIC) == 0 || !descs->GetKey(i)->IsSymbol())) { 13567 !FilterKey(descs->GetKey(i), filter)) {
13555 storage->set(index++, descs->GetKey(i)); 13568 storage->set(index++, descs->GetKey(i));
13556 } 13569 }
13557 } 13570 }
13558 } else { 13571 } else {
13559 property_dictionary()->CopyKeysTo(storage, 13572 property_dictionary()->CopyKeysTo(storage,
13560 index, 13573 index,
13561 filter, 13574 filter,
13562 NameDictionary::UNSORTED); 13575 NameDictionary::UNSORTED);
13563 } 13576 }
13564 } 13577 }
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
15646 15659
15647 15660
15648 template<typename Shape, typename Key> 15661 template<typename Shape, typename Key>
15649 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( 15662 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes(
15650 PropertyAttributes filter) { 15663 PropertyAttributes filter) {
15651 int capacity = HashTable<Shape, Key>::Capacity(); 15664 int capacity = HashTable<Shape, Key>::Capacity();
15652 int result = 0; 15665 int result = 0;
15653 for (int i = 0; i < capacity; i++) { 15666 for (int i = 0; i < capacity; i++) {
15654 Object* k = HashTable<Shape, Key>::KeyAt(i); 15667 Object* k = HashTable<Shape, Key>::KeyAt(i);
15655 if (HashTable<Shape, Key>::IsKey(k) && 15668 if (HashTable<Shape, Key>::IsKey(k) &&
15656 ((filter & SYMBOLIC) == 0 || !k->IsSymbol())) { 15669 !FilterKey(k, filter)) {
15657 PropertyDetails details = DetailsAt(i); 15670 PropertyDetails details = DetailsAt(i);
15658 if (details.IsDeleted()) continue; 15671 if (details.IsDeleted()) continue;
15659 PropertyAttributes attr = details.attributes(); 15672 PropertyAttributes attr = details.attributes();
15660 if ((attr & filter) == 0) result++; 15673 if ((attr & filter) == 0) result++;
15661 } 15674 }
15662 } 15675 }
15663 return result; 15676 return result;
15664 } 15677 }
15665 15678
15666 15679
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
16651 #define ERROR_MESSAGES_TEXTS(C, T) T, 16664 #define ERROR_MESSAGES_TEXTS(C, T) T,
16652 static const char* error_messages_[] = { 16665 static const char* error_messages_[] = {
16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16666 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16654 }; 16667 };
16655 #undef ERROR_MESSAGES_TEXTS 16668 #undef ERROR_MESSAGES_TEXTS
16656 return error_messages_[reason]; 16669 return error_messages_[reason];
16657 } 16670 }
16658 16671
16659 16672
16660 } } // namespace v8::internal 16673 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/property-details.h » ('j') | src/v8natives.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698