| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_PROTOTYPE_H_ | 5 #ifndef V8_PROTOTYPE_H_ |
| 6 #define V8_PROTOTYPE_H_ | 6 #define V8_PROTOTYPE_H_ |
| 7 | 7 |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 object_(receiver_map->prototype()), | 53 object_(receiver_map->prototype()), |
| 54 isolate_(receiver_map->GetIsolate()) {} | 54 isolate_(receiver_map->GetIsolate()) {} |
| 55 explicit PrototypeIterator(Handle<Map> receiver_map) | 55 explicit PrototypeIterator(Handle<Map> receiver_map) |
| 56 : did_jump_to_prototype_chain_(true), | 56 : did_jump_to_prototype_chain_(true), |
| 57 object_(NULL), | 57 object_(NULL), |
| 58 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), | 58 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), |
| 59 isolate_(receiver_map->GetIsolate()) {} | 59 isolate_(receiver_map->GetIsolate()) {} |
| 60 ~PrototypeIterator() {} | 60 ~PrototypeIterator() {} |
| 61 | 61 |
| 62 Object* GetCurrent() const { | 62 Object* GetCurrent() const { |
| 63 ASSERT(handle_.is_null()); | 63 DCHECK(handle_.is_null()); |
| 64 return object_; | 64 return object_; |
| 65 } | 65 } |
| 66 static Handle<Object> GetCurrent(const PrototypeIterator& iterator) { | 66 static Handle<Object> GetCurrent(const PrototypeIterator& iterator) { |
| 67 ASSERT(!iterator.handle_.is_null()); | 67 DCHECK(!iterator.handle_.is_null()); |
| 68 return iterator.handle_; | 68 return iterator.handle_; |
| 69 } | 69 } |
| 70 void Advance() { | 70 void Advance() { |
| 71 if (handle_.is_null() && object_->IsJSProxy()) { | 71 if (handle_.is_null() && object_->IsJSProxy()) { |
| 72 did_jump_to_prototype_chain_ = true; | 72 did_jump_to_prototype_chain_ = true; |
| 73 object_ = isolate_->heap()->null_value(); | 73 object_ = isolate_->heap()->null_value(); |
| 74 return; | 74 return; |
| 75 } else if (!handle_.is_null() && handle_->IsJSProxy()) { | 75 } else if (!handle_.is_null() && handle_->IsJSProxy()) { |
| 76 did_jump_to_prototype_chain_ = true; | 76 did_jump_to_prototype_chain_ = true; |
| 77 handle_ = handle(isolate_->heap()->null_value(), isolate_); | 77 handle_ = handle(isolate_->heap()->null_value(), isolate_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 where_to_end == END_AT_NON_HIDDEN && | 103 where_to_end == END_AT_NON_HIDDEN && |
| 104 !HeapObject::cast(object_)->map()->is_hidden_prototype()); | 104 !HeapObject::cast(object_)->map()->is_hidden_prototype()); |
| 105 } else { | 105 } else { |
| 106 return handle_->IsNull() || | 106 return handle_->IsNull() || |
| 107 (did_jump_to_prototype_chain_ && | 107 (did_jump_to_prototype_chain_ && |
| 108 where_to_end == END_AT_NON_HIDDEN && | 108 where_to_end == END_AT_NON_HIDDEN && |
| 109 !Handle<HeapObject>::cast(handle_)->map()->is_hidden_prototype()); | 109 !Handle<HeapObject>::cast(handle_)->map()->is_hidden_prototype()); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 bool IsAtEnd(Object* final_object) { | 112 bool IsAtEnd(Object* final_object) { |
| 113 ASSERT(handle_.is_null()); | 113 DCHECK(handle_.is_null()); |
| 114 return object_->IsNull() || object_ == final_object; | 114 return object_->IsNull() || object_ == final_object; |
| 115 } | 115 } |
| 116 bool IsAtEnd(Handle<Object> final_object) { | 116 bool IsAtEnd(Handle<Object> final_object) { |
| 117 ASSERT(!handle_.is_null()); | 117 DCHECK(!handle_.is_null()); |
| 118 return handle_->IsNull() || *handle_ == *final_object; | 118 return handle_->IsNull() || *handle_ == *final_object; |
| 119 } | 119 } |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 bool did_jump_to_prototype_chain_; | 122 bool did_jump_to_prototype_chain_; |
| 123 Object* object_; | 123 Object* object_; |
| 124 Handle<Object> handle_; | 124 Handle<Object> handle_; |
| 125 Isolate* isolate_; | 125 Isolate* isolate_; |
| 126 | 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); | 127 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 | 130 |
| 131 } // namespace internal | 131 } // namespace internal |
| 132 | 132 |
| 133 } // namespace v8 | 133 } // namespace v8 |
| 134 | 134 |
| 135 #endif // V8_PROTOTYPE_H_ | 135 #endif // V8_PROTOTYPE_H_ |
| OLD | NEW |