| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 return Api::Success(); | 1526 return Api::Success(); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 | 1529 |
| 1530 DART_EXPORT Dart_Handle Dart_HandleMessage() { | 1530 DART_EXPORT Dart_Handle Dart_HandleMessage() { |
| 1531 Thread* T = Thread::Current(); | 1531 Thread* T = Thread::Current(); |
| 1532 Isolate* I = T->isolate(); | 1532 Isolate* I = T->isolate(); |
| 1533 CHECK_API_SCOPE(T); | 1533 CHECK_API_SCOPE(T); |
| 1534 CHECK_CALLBACK_STATE(T); | 1534 CHECK_CALLBACK_STATE(T); |
| 1535 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { | 1535 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { |
| 1536 Dart_Handle error = Api::NewHandle(T, | 1536 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
| 1537 I->object_store()->sticky_error()); | |
| 1538 I->object_store()->clear_sticky_error(); | 1537 I->object_store()->clear_sticky_error(); |
| 1539 return error; | 1538 return error; |
| 1540 } | 1539 } |
| 1541 return Api::Success(); | 1540 return Api::Success(); |
| 1542 } | 1541 } |
| 1543 | 1542 |
| 1544 | 1543 |
| 1545 DART_EXPORT bool Dart_HandleServiceMessages() { | 1544 DART_EXPORT bool Dart_HandleServiceMessages() { |
| 1546 Thread* T = Thread::Current(); | 1545 Thread* T = Thread::Current(); |
| 1547 Isolate* I = T->isolate(); | 1546 Isolate* I = T->isolate(); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 const uint8_t* latin1_array, | 2216 const uint8_t* latin1_array, |
| 2218 intptr_t length, | 2217 intptr_t length, |
| 2219 void* peer, | 2218 void* peer, |
| 2220 Dart_PeerFinalizer cback) { | 2219 Dart_PeerFinalizer cback) { |
| 2221 DARTSCOPE(Thread::Current()); | 2220 DARTSCOPE(Thread::Current()); |
| 2222 if (latin1_array == NULL && length != 0) { | 2221 if (latin1_array == NULL && length != 0) { |
| 2223 RETURN_NULL_ERROR(latin1_array); | 2222 RETURN_NULL_ERROR(latin1_array); |
| 2224 } | 2223 } |
| 2225 CHECK_LENGTH(length, String::kMaxElements); | 2224 CHECK_LENGTH(length, String::kMaxElements); |
| 2226 CHECK_CALLBACK_STATE(T); | 2225 CHECK_CALLBACK_STATE(T); |
| 2227 return Api::NewHandle(T, | 2226 return Api::NewHandle(T, String::NewExternal(latin1_array, |
| 2228 String::NewExternal(latin1_array, | 2227 length, |
| 2229 length, | 2228 peer, |
| 2230 peer, | 2229 cback, |
| 2231 cback, | 2230 SpaceForExternal(T, length))); |
| 2232 SpaceForExternal(T, length))); | |
| 2233 } | 2231 } |
| 2234 | 2232 |
| 2235 | 2233 |
| 2236 DART_EXPORT Dart_Handle Dart_NewExternalUTF16String(const uint16_t* utf16_array, | 2234 DART_EXPORT Dart_Handle Dart_NewExternalUTF16String(const uint16_t* utf16_array, |
| 2237 intptr_t length, | 2235 intptr_t length, |
| 2238 void* peer, | 2236 void* peer, |
| 2239 Dart_PeerFinalizer cback) { | 2237 Dart_PeerFinalizer cback) { |
| 2240 DARTSCOPE(Thread::Current()); | 2238 DARTSCOPE(Thread::Current()); |
| 2241 if (utf16_array == NULL && length != 0) { | 2239 if (utf16_array == NULL && length != 0) { |
| 2242 RETURN_NULL_ERROR(utf16_array); | 2240 RETURN_NULL_ERROR(utf16_array); |
| 2243 } | 2241 } |
| 2244 CHECK_LENGTH(length, String::kMaxElements); | 2242 CHECK_LENGTH(length, String::kMaxElements); |
| 2245 CHECK_CALLBACK_STATE(T); | 2243 CHECK_CALLBACK_STATE(T); |
| 2246 intptr_t bytes = length * sizeof(*utf16_array); | 2244 intptr_t bytes = length * sizeof(*utf16_array); |
| 2247 return Api::NewHandle(T, | 2245 return Api::NewHandle(T, String::NewExternal(utf16_array, |
| 2248 String::NewExternal(utf16_array, | 2246 length, |
| 2249 length, | 2247 peer, |
| 2250 peer, | 2248 cback, |
| 2251 cback, | 2249 SpaceForExternal(T, bytes))); |
| 2252 SpaceForExternal(T, bytes))); | |
| 2253 } | 2250 } |
| 2254 | 2251 |
| 2255 | 2252 |
| 2256 DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, | 2253 DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, |
| 2257 const char** cstr) { | 2254 const char** cstr) { |
| 2258 DARTSCOPE(Thread::Current()); | 2255 DARTSCOPE(Thread::Current()); |
| 2259 if (cstr == NULL) { | 2256 if (cstr == NULL) { |
| 2260 RETURN_NULL_ERROR(cstr); | 2257 RETURN_NULL_ERROR(cstr); |
| 2261 } | 2258 } |
| 2262 const String& str_obj = Api::UnwrapStringHandle(Z, object); | 2259 const String& str_obj = Api::UnwrapStringHandle(Z, object); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 Resolver::ResolveDynamic(instance, | 2593 Resolver::ResolveDynamic(instance, |
| 2597 Symbols::AssignIndexToken(), | 2594 Symbols::AssignIndexToken(), |
| 2598 args_desc)); | 2595 args_desc)); |
| 2599 if (!function.IsNull()) { | 2596 if (!function.IsNull()) { |
| 2600 const Array& args = Array::Handle(Array::New(kNumArgs)); | 2597 const Array& args = Array::Handle(Array::New(kNumArgs)); |
| 2601 args.SetAt(0, instance); | 2598 args.SetAt(0, instance); |
| 2602 Instance& index = Instance::Handle(Z); | 2599 Instance& index = Instance::Handle(Z); |
| 2603 for (intptr_t i = 0; i < length; ++i) { | 2600 for (intptr_t i = 0; i < length; ++i) { |
| 2604 index = Integer::New(i); | 2601 index = Integer::New(i); |
| 2605 args.SetAt(1, index); | 2602 args.SetAt(1, index); |
| 2606 Dart_Handle value = Api::NewHandle(T, | 2603 Dart_Handle value = Api::NewHandle( |
| 2607 DartEntry::InvokeFunction(function, args)); | 2604 T, DartEntry::InvokeFunction(function, args)); |
| 2608 if (::Dart_IsError(value)) | 2605 if (::Dart_IsError(value)) |
| 2609 return value; | 2606 return value; |
| 2610 result[i] = value; | 2607 result[i] = value; |
| 2611 } | 2608 } |
| 2612 return Api::Success(); | 2609 return Api::Success(); |
| 2613 } | 2610 } |
| 2614 } | 2611 } |
| 2615 return Api::NewError("Object does not implement the 'List' interface"); | 2612 return Api::NewError("Object does not implement the 'List' interface"); |
| 2616 } | 2613 } |
| 2617 } | 2614 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2746 } | 2743 } |
| 2747 | 2744 |
| 2748 // TODO(sgjesse): value should always be smaller then 0xff. Add error handling. | 2745 // TODO(sgjesse): value should always be smaller then 0xff. Add error handling. |
| 2749 #define GET_LIST_ELEMENT_AS_BYTES(type, obj, native_array, offset, length) \ | 2746 #define GET_LIST_ELEMENT_AS_BYTES(type, obj, native_array, offset, length) \ |
| 2750 const type& array = type::Cast(obj); \ | 2747 const type& array = type::Cast(obj); \ |
| 2751 if (Utils::RangeCheck(offset, length, array.Length())) { \ | 2748 if (Utils::RangeCheck(offset, length, array.Length())) { \ |
| 2752 Object& element = Object::Handle(Z); \ | 2749 Object& element = Object::Handle(Z); \ |
| 2753 for (int i = 0; i < length; i++) { \ | 2750 for (int i = 0; i < length; i++) { \ |
| 2754 element = array.At(offset + i); \ | 2751 element = array.At(offset + i); \ |
| 2755 if (!element.IsInteger()) { \ | 2752 if (!element.IsInteger()) { \ |
| 2756 return Api::NewHandle(T, \ | 2753 return Api::NewHandle( \ |
| 2757 ThrowArgumentError("List contains non-int elements")); \ | 2754 T, ThrowArgumentError("List contains non-int elements")); \ |
| 2758 \ | 2755 \ |
| 2759 } \ | 2756 } \ |
| 2760 const Integer& integer = Integer::Cast(element); \ | 2757 const Integer& integer = Integer::Cast(element); \ |
| 2761 native_array[i] = static_cast<uint8_t>(integer.AsInt64Value() & 0xff); \ | 2758 native_array[i] = static_cast<uint8_t>(integer.AsInt64Value() & 0xff); \ |
| 2762 ASSERT(integer.AsInt64Value() <= 0xff); \ | 2759 ASSERT(integer.AsInt64Value() <= 0xff); \ |
| 2763 } \ | 2760 } \ |
| 2764 return Api::Success(); \ | 2761 return Api::Success(); \ |
| 2765 } \ | 2762 } \ |
| 2766 return Api::NewError("Invalid length passed in to access array elements"); \ | 2763 return Api::NewError("Invalid length passed in to access array elements"); \ |
| 2767 | 2764 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2962 DART_EXPORT Dart_Handle Dart_MapGetAt(Dart_Handle map, Dart_Handle key) { | 2959 DART_EXPORT Dart_Handle Dart_MapGetAt(Dart_Handle map, Dart_Handle key) { |
| 2963 DARTSCOPE(Thread::Current()); | 2960 DARTSCOPE(Thread::Current()); |
| 2964 CHECK_CALLBACK_STATE(T); | 2961 CHECK_CALLBACK_STATE(T); |
| 2965 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(map)); | 2962 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(map)); |
| 2966 const Instance& instance = Instance::Handle(Z, GetMapInstance(Z, obj)); | 2963 const Instance& instance = Instance::Handle(Z, GetMapInstance(Z, obj)); |
| 2967 if (!instance.IsNull()) { | 2964 if (!instance.IsNull()) { |
| 2968 const Object& key_obj = Object::Handle(Api::UnwrapHandle(key)); | 2965 const Object& key_obj = Object::Handle(Api::UnwrapHandle(key)); |
| 2969 if (!(key_obj.IsInstance() || key_obj.IsNull())) { | 2966 if (!(key_obj.IsInstance() || key_obj.IsNull())) { |
| 2970 return Api::NewError("Key is not an instance"); | 2967 return Api::NewError("Key is not an instance"); |
| 2971 } | 2968 } |
| 2972 return Api::NewHandle(T, | 2969 return Api::NewHandle( |
| 2973 Send1Arg(instance, Symbols::IndexToken(), Instance::Cast(key_obj))); | 2970 T, Send1Arg(instance, Symbols::IndexToken(), Instance::Cast(key_obj))); |
| 2974 } | 2971 } |
| 2975 return Api::NewError("Object does not implement the 'Map' interface"); | 2972 return Api::NewError("Object does not implement the 'Map' interface"); |
| 2976 } | 2973 } |
| 2977 | 2974 |
| 2978 | 2975 |
| 2979 DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key) { | 2976 DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key) { |
| 2980 DARTSCOPE(Thread::Current()); | 2977 DARTSCOPE(Thread::Current()); |
| 2981 CHECK_CALLBACK_STATE(T); | 2978 CHECK_CALLBACK_STATE(T); |
| 2982 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(map)); | 2979 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(map)); |
| 2983 const Instance& instance = Instance::Handle(Z, GetMapInstance(Z, obj)); | 2980 const Instance& instance = Instance::Handle(Z, GetMapInstance(Z, obj)); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3269 intptr_t length) { | 3266 intptr_t length) { |
| 3270 DARTSCOPE(Thread::Current()); | 3267 DARTSCOPE(Thread::Current()); |
| 3271 if (data == NULL && length != 0) { | 3268 if (data == NULL && length != 0) { |
| 3272 RETURN_NULL_ERROR(data); | 3269 RETURN_NULL_ERROR(data); |
| 3273 } | 3270 } |
| 3274 CHECK_CALLBACK_STATE(T); | 3271 CHECK_CALLBACK_STATE(T); |
| 3275 switch (type) { | 3272 switch (type) { |
| 3276 case Dart_TypedData_kByteData: | 3273 case Dart_TypedData_kByteData: |
| 3277 return NewExternalByteData(T, data, length); | 3274 return NewExternalByteData(T, data, length); |
| 3278 case Dart_TypedData_kInt8: | 3275 case Dart_TypedData_kInt8: |
| 3279 return NewExternalTypedData(T, | 3276 return NewExternalTypedData( |
| 3280 kExternalTypedDataInt8ArrayCid, data, length); | 3277 T, kExternalTypedDataInt8ArrayCid, data, length); |
| 3281 case Dart_TypedData_kUint8: | 3278 case Dart_TypedData_kUint8: |
| 3282 return NewExternalTypedData(T, | 3279 return NewExternalTypedData( |
| 3283 kExternalTypedDataUint8ArrayCid, data, length); | 3280 T, kExternalTypedDataUint8ArrayCid, data, length); |
| 3284 case Dart_TypedData_kUint8Clamped: | 3281 case Dart_TypedData_kUint8Clamped: |
| 3285 return NewExternalTypedData(T, | 3282 return NewExternalTypedData( |
| 3286 kExternalTypedDataUint8ClampedArrayCid, data, length); | 3283 T, kExternalTypedDataUint8ClampedArrayCid, data, length); |
| 3287 case Dart_TypedData_kInt16: | 3284 case Dart_TypedData_kInt16: |
| 3288 return NewExternalTypedData(T, | 3285 return NewExternalTypedData( |
| 3289 kExternalTypedDataInt16ArrayCid, data, length); | 3286 T, kExternalTypedDataInt16ArrayCid, data, length); |
| 3290 case Dart_TypedData_kUint16: | 3287 case Dart_TypedData_kUint16: |
| 3291 return NewExternalTypedData(T, | 3288 return NewExternalTypedData( |
| 3292 kExternalTypedDataUint16ArrayCid, data, length); | 3289 T, kExternalTypedDataUint16ArrayCid, data, length); |
| 3293 case Dart_TypedData_kInt32: | 3290 case Dart_TypedData_kInt32: |
| 3294 return NewExternalTypedData(T, | 3291 return NewExternalTypedData( |
| 3295 kExternalTypedDataInt32ArrayCid, data, length); | 3292 T, kExternalTypedDataInt32ArrayCid, data, length); |
| 3296 case Dart_TypedData_kUint32: | 3293 case Dart_TypedData_kUint32: |
| 3297 return NewExternalTypedData(T, | 3294 return NewExternalTypedData( |
| 3298 kExternalTypedDataUint32ArrayCid, data, length); | 3295 T, kExternalTypedDataUint32ArrayCid, data, length); |
| 3299 case Dart_TypedData_kInt64: | 3296 case Dart_TypedData_kInt64: |
| 3300 return NewExternalTypedData(T, | 3297 return NewExternalTypedData( |
| 3301 kExternalTypedDataInt64ArrayCid, data, length); | 3298 T, kExternalTypedDataInt64ArrayCid, data, length); |
| 3302 case Dart_TypedData_kUint64: | 3299 case Dart_TypedData_kUint64: |
| 3303 return NewExternalTypedData(T, | 3300 return NewExternalTypedData( |
| 3304 kExternalTypedDataUint64ArrayCid, data, length); | 3301 T, kExternalTypedDataUint64ArrayCid, data, length); |
| 3305 case Dart_TypedData_kFloat32: | 3302 case Dart_TypedData_kFloat32: |
| 3306 return NewExternalTypedData(T, | 3303 return NewExternalTypedData( |
| 3307 kExternalTypedDataFloat32ArrayCid, data, length); | 3304 T, kExternalTypedDataFloat32ArrayCid, data, length); |
| 3308 case Dart_TypedData_kFloat64: | 3305 case Dart_TypedData_kFloat64: |
| 3309 return NewExternalTypedData(T, | 3306 return NewExternalTypedData( |
| 3310 kExternalTypedDataFloat64ArrayCid, data, length); | 3307 T, kExternalTypedDataFloat64ArrayCid, data, length); |
| 3311 case Dart_TypedData_kFloat32x4: | 3308 case Dart_TypedData_kFloat32x4: |
| 3312 return NewExternalTypedData(T, | 3309 return NewExternalTypedData( |
| 3313 kExternalTypedDataFloat32x4ArrayCid, data, length); | 3310 T, kExternalTypedDataFloat32x4ArrayCid, data, length); |
| 3314 default: | 3311 default: |
| 3315 return Api::NewError("%s expects argument 'type' to be of" | 3312 return Api::NewError("%s expects argument 'type' to be of" |
| 3316 " 'external TypedData'", CURRENT_FUNC); | 3313 " 'external TypedData'", CURRENT_FUNC); |
| 3317 } | 3314 } |
| 3318 UNREACHABLE(); | 3315 UNREACHABLE(); |
| 3319 return Api::Null(); | 3316 return Api::Null(); |
| 3320 } | 3317 } |
| 3321 | 3318 |
| 3322 | 3319 |
| 3323 static RawObject* GetByteBufferConstructor(Thread* thread, | 3320 static RawObject* GetByteBufferConstructor(Thread* thread, |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 // Constructors get the uninitialized object and a constructor phase. | 3896 // Constructors get the uninitialized object and a constructor phase. |
| 3900 if (!type_arguments.IsNull()) { | 3897 if (!type_arguments.IsNull()) { |
| 3901 // The type arguments will be null if the class has no type | 3898 // The type arguments will be null if the class has no type |
| 3902 // parameters, in which case the following call would fail | 3899 // parameters, in which case the following call would fail |
| 3903 // because there is no slot reserved in the object for the | 3900 // because there is no slot reserved in the object for the |
| 3904 // type vector. | 3901 // type vector. |
| 3905 instance.SetTypeArguments(type_arguments); | 3902 instance.SetTypeArguments(type_arguments); |
| 3906 } | 3903 } |
| 3907 Dart_Handle result; | 3904 Dart_Handle result; |
| 3908 Array& args = Array::Handle(Z); | 3905 Array& args = Array::Handle(Z); |
| 3909 result = SetupArguments(T, | 3906 result = SetupArguments( |
| 3910 number_of_arguments, arguments, extra_args, &args); | 3907 T, number_of_arguments, arguments, extra_args, &args); |
| 3911 if (!::Dart_IsError(result)) { | 3908 if (!::Dart_IsError(result)) { |
| 3912 args.SetAt(0, instance); | 3909 args.SetAt(0, instance); |
| 3913 args.SetAt(1, Smi::Handle(Z, Smi::New(Function::kCtorPhaseAll))); | 3910 args.SetAt(1, Smi::Handle(Z, Smi::New(Function::kCtorPhaseAll))); |
| 3914 const Object& retval = Object::Handle(Z, | 3911 const Object& retval = Object::Handle(Z, |
| 3915 DartEntry::InvokeFunction(constructor, args)); | 3912 DartEntry::InvokeFunction(constructor, args)); |
| 3916 if (retval.IsError()) { | 3913 if (retval.IsError()) { |
| 3917 result = Api::NewHandle(T, retval.raw()); | 3914 result = Api::NewHandle(T, retval.raw()); |
| 3918 } else { | 3915 } else { |
| 3919 result = Api::NewHandle(T, instance.raw()); | 3916 result = Api::NewHandle(T, instance.raw()); |
| 3920 } | 3917 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4112 | 4109 |
| 4113 field = cls.LookupStaticField(field_name); | 4110 field = cls.LookupStaticField(field_name); |
| 4114 if (field.IsNull() || field.IsUninitialized()) { | 4111 if (field.IsNull() || field.IsUninitialized()) { |
| 4115 const String& getter_name = | 4112 const String& getter_name = |
| 4116 String::Handle(Z, Field::GetterName(field_name)); | 4113 String::Handle(Z, Field::GetterName(field_name)); |
| 4117 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 4114 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
| 4118 } | 4115 } |
| 4119 | 4116 |
| 4120 if (!getter.IsNull()) { | 4117 if (!getter.IsNull()) { |
| 4121 // Invoke the getter and return the result. | 4118 // Invoke the getter and return the result. |
| 4122 return Api::NewHandle(T, | 4119 return Api::NewHandle( |
| 4123 DartEntry::InvokeFunction(getter, Object::empty_array())); | 4120 T, DartEntry::InvokeFunction(getter, Object::empty_array())); |
| 4124 } else if (!field.IsNull()) { | 4121 } else if (!field.IsNull()) { |
| 4125 return Api::NewHandle(T, field.StaticValue()); | 4122 return Api::NewHandle(T, field.StaticValue()); |
| 4126 } else { | 4123 } else { |
| 4127 return Api::NewError("%s: did not find static field '%s'.", | 4124 return Api::NewError("%s: did not find static field '%s'.", |
| 4128 CURRENT_FUNC, field_name.ToCString()); | 4125 CURRENT_FUNC, field_name.ToCString()); |
| 4129 } | 4126 } |
| 4130 | 4127 |
| 4131 } else if (obj.IsInstance()) { | 4128 } else if (obj.IsInstance()) { |
| 4132 // Every instance field has a getter Function. Try to find the | 4129 // Every instance field has a getter Function. Try to find the |
| 4133 // getter in any superclass and use that function to access the | 4130 // getter in any superclass and use that function to access the |
| 4134 // field. | 4131 // field. |
| 4135 const Instance& instance = Instance::Cast(obj); | 4132 const Instance& instance = Instance::Cast(obj); |
| 4136 Class& cls = Class::Handle(Z, instance.clazz()); | 4133 Class& cls = Class::Handle(Z, instance.clazz()); |
| 4137 String& getter_name = String::Handle(Z, Field::GetterName(field_name)); | 4134 String& getter_name = String::Handle(Z, Field::GetterName(field_name)); |
| 4138 while (!cls.IsNull()) { | 4135 while (!cls.IsNull()) { |
| 4139 getter = cls.LookupDynamicFunctionAllowPrivate(getter_name); | 4136 getter = cls.LookupDynamicFunctionAllowPrivate(getter_name); |
| 4140 if (!getter.IsNull()) { | 4137 if (!getter.IsNull()) { |
| 4141 break; | 4138 break; |
| 4142 } | 4139 } |
| 4143 cls = cls.SuperClass(); | 4140 cls = cls.SuperClass(); |
| 4144 } | 4141 } |
| 4145 | 4142 |
| 4146 // Invoke the getter and return the result. | 4143 // Invoke the getter and return the result. |
| 4147 const int kNumArgs = 1; | 4144 const int kNumArgs = 1; |
| 4148 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); | 4145 const Array& args = Array::Handle(Z, Array::New(kNumArgs)); |
| 4149 args.SetAt(0, instance); | 4146 args.SetAt(0, instance); |
| 4150 if (getter.IsNull()) { | 4147 if (getter.IsNull()) { |
| 4151 const Array& args_descriptor = | 4148 const Array& args_descriptor = |
| 4152 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); | 4149 Array::Handle(Z, ArgumentsDescriptor::New(args.Length())); |
| 4153 return Api::NewHandle(T, | 4150 return Api::NewHandle(T, DartEntry::InvokeNoSuchMethod(instance, |
| 4154 DartEntry::InvokeNoSuchMethod(instance, | 4151 getter_name, |
| 4155 getter_name, | 4152 args, |
| 4156 args, | 4153 args_descriptor)); |
| 4157 args_descriptor)); | |
| 4158 } | 4154 } |
| 4159 return Api::NewHandle(T, DartEntry::InvokeFunction(getter, args)); | 4155 return Api::NewHandle(T, DartEntry::InvokeFunction(getter, args)); |
| 4160 | 4156 |
| 4161 } else if (obj.IsLibrary()) { | 4157 } else if (obj.IsLibrary()) { |
| 4162 // To access a top-level we may need to use the Field or the | 4158 // To access a top-level we may need to use the Field or the |
| 4163 // getter Function. The getter function may either be in the | 4159 // getter Function. The getter function may either be in the |
| 4164 // library or in the field's owner class, depending. | 4160 // library or in the field's owner class, depending. |
| 4165 const Library& lib = Library::Cast(obj); | 4161 const Library& lib = Library::Cast(obj); |
| 4166 // Check that the library is loaded. | 4162 // Check that the library is loaded. |
| 4167 if (!lib.Loaded()) { | 4163 if (!lib.Loaded()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4178 } else if (!field.IsNull() && field.IsUninitialized()) { | 4174 } else if (!field.IsNull() && field.IsUninitialized()) { |
| 4179 // A field was found. Check for a getter in the field's owner classs. | 4175 // A field was found. Check for a getter in the field's owner classs. |
| 4180 const Class& cls = Class::Handle(Z, field.owner()); | 4176 const Class& cls = Class::Handle(Z, field.owner()); |
| 4181 const String& getter_name = String::Handle(Z, | 4177 const String& getter_name = String::Handle(Z, |
| 4182 Field::GetterName(field_name)); | 4178 Field::GetterName(field_name)); |
| 4183 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 4179 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
| 4184 } | 4180 } |
| 4185 | 4181 |
| 4186 if (!getter.IsNull()) { | 4182 if (!getter.IsNull()) { |
| 4187 // Invoke the getter and return the result. | 4183 // Invoke the getter and return the result. |
| 4188 return Api::NewHandle(T, | 4184 return Api::NewHandle( |
| 4189 DartEntry::InvokeFunction(getter, Object::empty_array())); | 4185 T, DartEntry::InvokeFunction(getter, Object::empty_array())); |
| 4190 } | 4186 } |
| 4191 if (!field.IsNull()) { | 4187 if (!field.IsNull()) { |
| 4192 return Api::NewHandle(T, field.StaticValue()); | 4188 return Api::NewHandle(T, field.StaticValue()); |
| 4193 } | 4189 } |
| 4194 return Api::NewError("%s: did not find top-level variable '%s'.", | 4190 return Api::NewError("%s: did not find top-level variable '%s'.", |
| 4195 CURRENT_FUNC, field_name.ToCString()); | 4191 CURRENT_FUNC, field_name.ToCString()); |
| 4196 | 4192 |
| 4197 } else if (obj.IsError()) { | 4193 } else if (obj.IsError()) { |
| 4198 return container; | 4194 return container; |
| 4199 } else { | 4195 } else { |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5922 ApiReallocate); | 5918 ApiReallocate); |
| 5923 writer.WriteFullSnapshot(); | 5919 writer.WriteFullSnapshot(); |
| 5924 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 5920 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 5925 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 5921 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 5926 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 5922 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 5927 | 5923 |
| 5928 return Api::Success(); | 5924 return Api::Success(); |
| 5929 } | 5925 } |
| 5930 | 5926 |
| 5931 } // namespace dart | 5927 } // namespace dart |
| OLD | NEW |