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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 isolate_(receiver_map->GetIsolate()) {} | 56 isolate_(receiver_map->GetIsolate()) {} |
57 | 57 |
58 explicit PrototypeIterator(Handle<Map> receiver_map) | 58 explicit PrototypeIterator(Handle<Map> receiver_map) |
59 : did_jump_to_prototype_chain_(true), | 59 : did_jump_to_prototype_chain_(true), |
60 object_(NULL), | 60 object_(NULL), |
61 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), | 61 handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())), |
62 isolate_(receiver_map->GetIsolate()) {} | 62 isolate_(receiver_map->GetIsolate()) {} |
63 | 63 |
64 ~PrototypeIterator() {} | 64 ~PrototypeIterator() {} |
65 | 65 |
| 66 const bool HasAccess() { |
| 67 // We can only perform access check in the handlified version of the |
| 68 // PrototypeIterator. |
| 69 DCHECK(!handle_.is_null()); |
| 70 if (handle_->IsAccessCheckNeeded()) { |
| 71 return isolate_->MayAccess(handle(isolate_->context()), |
| 72 Handle<JSObject>::cast(handle_)); |
| 73 } |
| 74 return true; |
| 75 } |
| 76 |
66 template <typename T = Object> | 77 template <typename T = Object> |
67 T* GetCurrent() const { | 78 T* GetCurrent() const { |
68 DCHECK(handle_.is_null()); | 79 DCHECK(handle_.is_null()); |
69 return T::cast(object_); | 80 return T::cast(object_); |
70 } | 81 } |
71 | 82 |
72 template <typename T = Object> | 83 template <typename T = Object> |
73 static Handle<T> GetCurrent(const PrototypeIterator& iterator) { | 84 static Handle<T> GetCurrent(const PrototypeIterator& iterator) { |
74 DCHECK(!iterator.handle_.is_null()); | 85 DCHECK(!iterator.handle_.is_null()); |
| 86 DCHECK(iterator.object_ == NULL); |
75 return Handle<T>::cast(iterator.handle_); | 87 return Handle<T>::cast(iterator.handle_); |
76 } | 88 } |
77 | 89 |
78 void Advance() { | 90 void Advance() { |
79 if (handle_.is_null() && object_->IsJSProxy()) { | 91 if (handle_.is_null() && object_->IsJSProxy()) { |
80 did_jump_to_prototype_chain_ = true; | 92 did_jump_to_prototype_chain_ = true; |
81 object_ = isolate_->heap()->null_value(); | 93 object_ = isolate_->heap()->null_value(); |
82 return; | 94 return; |
83 } else if (!handle_.is_null() && handle_->IsJSProxy()) { | 95 } else if (!handle_.is_null() && handle_->IsJSProxy()) { |
84 did_jump_to_prototype_chain_ = true; | 96 did_jump_to_prototype_chain_ = true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 164 |
153 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); | 165 DISALLOW_COPY_AND_ASSIGN(PrototypeIterator); |
154 }; | 166 }; |
155 | 167 |
156 | 168 |
157 } // namespace internal | 169 } // namespace internal |
158 | 170 |
159 } // namespace v8 | 171 } // namespace v8 |
160 | 172 |
161 #endif // V8_PROTOTYPE_H_ | 173 #endif // V8_PROTOTYPE_H_ |
OLD | NEW |