| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 static C* FindInstanceOf(Isolate* isolate, Object* obj) { | 60 static C* FindInstanceOf(Isolate* isolate, Object* obj) { |
| 61 for (PrototypeIterator iter(isolate, obj, | 61 for (PrototypeIterator iter(isolate, obj, |
| 62 PrototypeIterator::START_AT_RECEIVER); | 62 PrototypeIterator::START_AT_RECEIVER); |
| 63 !iter.IsAtEnd(); iter.Advance()) { | 63 !iter.IsAtEnd(); iter.Advance()) { |
| 64 if (Is<C>(iter.GetCurrent())) return C::cast(iter.GetCurrent()); | 64 if (Is<C>(iter.GetCurrent())) return C::cast(iter.GetCurrent()); |
| 65 } | 65 } |
| 66 return NULL; | 66 return NULL; |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 static V8_INLINE bool CheckForName(Handle<String> name, | 70 static V8_INLINE bool CheckForName(Handle<Name> name, |
| 71 Handle<String> property_name, | 71 Handle<String> property_name, |
| 72 int offset, | 72 int offset, |
| 73 int* object_offset) { | 73 int* object_offset) { |
| 74 if (String::Equals(name, property_name)) { | 74 if (Name::Equals(name, property_name)) { |
| 75 *object_offset = offset; | 75 *object_offset = offset; |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 // Returns true for properties that are accessors to object fields. | 82 // Returns true for properties that are accessors to object fields. |
| 83 // If true, *object_offset contains offset of object field. | 83 // If true, *object_offset contains offset of object field. |
| 84 template <class T> | 84 template <class T> |
| 85 bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, | 85 bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type, |
| 86 Handle<String> name, | 86 Handle<Name> name, |
| 87 int* object_offset) { | 87 int* object_offset) { |
| 88 Isolate* isolate = name->GetIsolate(); | 88 Isolate* isolate = name->GetIsolate(); |
| 89 | 89 |
| 90 if (type->Is(T::String())) { | 90 if (type->Is(T::String())) { |
| 91 return CheckForName(name, isolate->factory()->length_string(), | 91 return CheckForName(name, isolate->factory()->length_string(), |
| 92 String::kLengthOffset, object_offset); | 92 String::kLengthOffset, object_offset); |
| 93 } | 93 } |
| 94 | 94 |
| 95 if (!type->IsClass()) return false; | 95 if (!type->IsClass()) return false; |
| 96 Handle<Map> map = type->AsClass()->Map(); | 96 Handle<Map> map = type->AsClass()->Map(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 119 CheckForName(name, isolate->factory()->byte_offset_string(), | 119 CheckForName(name, isolate->factory()->byte_offset_string(), |
| 120 JSDataView::kByteOffsetOffset, object_offset); | 120 JSDataView::kByteOffsetOffset, object_offset); |
| 121 default: | 121 default: |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 template | 127 template |
| 128 bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type, | 128 bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type, |
| 129 Handle<String> name, | 129 Handle<Name> name, |
| 130 int* object_offset); | 130 int* object_offset); |
| 131 | 131 |
| 132 | 132 |
| 133 template | 133 template |
| 134 bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type, | 134 bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type, |
| 135 Handle<String> name, | 135 Handle<Name> name, |
| 136 int* object_offset); | 136 int* object_offset); |
| 137 | 137 |
| 138 | 138 |
| 139 bool SetPropertyOnInstanceIfInherited( | 139 bool SetPropertyOnInstanceIfInherited( |
| 140 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, | 140 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, |
| 141 v8::Local<v8::String> name, Handle<Object> value) { | 141 v8::Local<v8::String> name, Handle<Object> value) { |
| 142 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); | 142 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); |
| 143 Handle<Object> receiver = Utils::OpenHandle(*info.This()); | 143 Handle<Object> receiver = Utils::OpenHandle(*info.This()); |
| 144 if (*holder == *receiver) return false; | 144 if (*holder == *receiver) return false; |
| 145 if (receiver->IsJSObject()) { | 145 if (receiver->IsJSObject()) { |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 info->set_data(Smi::FromInt(index)); | 1354 info->set_data(Smi::FromInt(index)); |
| 1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 1357 info->set_getter(*getter); | 1357 info->set_getter(*getter); |
| 1358 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1358 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 1359 return info; | 1359 return info; |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 | 1362 |
| 1363 } } // namespace v8::internal | 1363 } } // namespace v8::internal |
| OLD | NEW |