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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 info->set_name(accessor->name()); | 49 info->set_name(accessor->name()); |
50 info->set_flag(accessor->flag()); | 50 info->set_flag(accessor->flag()); |
51 info->set_expected_receiver_type(accessor->expected_receiver_type()); | 51 info->set_expected_receiver_type(accessor->expected_receiver_type()); |
52 info->set_getter(accessor->getter()); | 52 info->set_getter(accessor->getter()); |
53 info->set_setter(accessor->setter()); | 53 info->set_setter(accessor->setter()); |
54 info->set_data(accessor->data()); | 54 info->set_data(accessor->data()); |
55 return info; | 55 return info; |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 template <class C> | |
60 static C* FindInstanceOf(Isolate* isolate, Object* obj) { | |
61 for (PrototypeIterator iter(isolate, obj, | |
62 PrototypeIterator::START_AT_RECEIVER); | |
63 !iter.IsAtEnd(); iter.Advance()) { | |
64 if (Is<C>(iter.GetCurrent())) return C::cast(iter.GetCurrent()); | |
65 } | |
66 return NULL; | |
67 } | |
68 | |
69 | |
70 static V8_INLINE bool CheckForName(Handle<Name> name, | 59 static V8_INLINE bool CheckForName(Handle<Name> name, |
71 Handle<String> property_name, | 60 Handle<String> property_name, |
72 int offset, | 61 int offset, |
73 int* object_offset) { | 62 int* object_offset) { |
74 if (Name::Equals(name, property_name)) { | 63 if (Name::Equals(name, property_name)) { |
75 *object_offset = offset; | 64 *object_offset = offset; |
76 return true; | 65 return true; |
77 } | 66 } |
78 return false; | 67 return false; |
79 } | 68 } |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 | 898 |
910 if (is_observed && !old_value->SameValue(*value)) { | 899 if (is_observed && !old_value->SameValue(*value)) { |
911 JSObject::EnqueueChangeRecord( | 900 JSObject::EnqueueChangeRecord( |
912 function, "update", isolate->factory()->prototype_string(), old_value); | 901 function, "update", isolate->factory()->prototype_string(), old_value); |
913 } | 902 } |
914 | 903 |
915 return function; | 904 return function; |
916 } | 905 } |
917 | 906 |
918 | 907 |
919 Handle<Object> Accessors::FunctionGetPrototype(Handle<JSFunction> function) { | |
920 return GetFunctionPrototype(function->GetIsolate(), function); | |
921 } | |
922 | |
923 | |
924 Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, | 908 Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, |
925 Handle<Object> prototype) { | 909 Handle<Object> prototype) { |
926 DCHECK(function->should_have_prototype()); | 910 DCHECK(function->should_have_prototype()); |
927 Isolate* isolate = function->GetIsolate(); | 911 Isolate* isolate = function->GetIsolate(); |
928 return SetFunctionPrototype(isolate, function, prototype); | 912 return SetFunctionPrototype(isolate, function, prototype); |
929 } | 913 } |
930 | 914 |
931 | 915 |
932 void Accessors::FunctionPrototypeGetter( | 916 void Accessors::FunctionPrototypeGetter( |
933 v8::Local<v8::Name> name, | 917 v8::Local<v8::Name> name, |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 info->set_data(Smi::FromInt(index)); | 1397 info->set_data(Smi::FromInt(index)); |
1414 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1398 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1415 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1399 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1416 info->set_getter(*getter); | 1400 info->set_getter(*getter); |
1417 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1401 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1418 return info; | 1402 return info; |
1419 } | 1403 } |
1420 | 1404 |
1421 | 1405 |
1422 } } // namespace v8::internal | 1406 } } // namespace v8::internal |
OLD | NEW |