Chromium Code Reviews| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 } else { | 50 } else { |
| 51 return func; | 51 return func; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) { | 56 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) { |
| 57 if (obj.IsInstance()) { | 57 if (obj.IsInstance()) { |
| 58 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 58 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 59 const Class& list_class = | 59 const Class& list_class = |
| 60 Class::Handle(core_lib.LookupClass(Symbols::List())); | 60 Class::Handle(core_lib.LookupClass(Symbols::List(), NULL)); |
| 61 ASSERT(!list_class.IsNull()); | 61 ASSERT(!list_class.IsNull()); |
| 62 const Instance& instance = Instance::Cast(obj); | 62 const Instance& instance = Instance::Cast(obj); |
| 63 const Class& obj_class = Class::Handle(isolate, obj.clazz()); | 63 const Class& obj_class = Class::Handle(isolate, obj.clazz()); |
| 64 Error& malformed_type_error = Error::Handle(isolate); | 64 Error& malformed_type_error = Error::Handle(isolate); |
| 65 if (obj_class.IsSubtypeOf(TypeArguments::Handle(isolate), | 65 if (obj_class.IsSubtypeOf(TypeArguments::Handle(isolate), |
| 66 list_class, | 66 list_class, |
| 67 TypeArguments::Handle(isolate), | 67 TypeArguments::Handle(isolate), |
| 68 &malformed_type_error)) { | 68 &malformed_type_error)) { |
| 69 ASSERT(malformed_type_error.IsNull()); // Type is a raw List. | 69 ASSERT(malformed_type_error.IsNull()); // Type is a raw List. |
| 70 return instance.raw(); | 70 return instance.raw(); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 const String& function_name = | 1043 const String& function_name = |
| 1044 String::Handle(isolate_lib.PrivateName(Symbols::_get_or_create())); | 1044 String::Handle(isolate_lib.PrivateName(Symbols::_get_or_create())); |
| 1045 const int kNumArguments = 1; | 1045 const int kNumArguments = 1; |
| 1046 const Function& function = Function::Handle( | 1046 const Function& function = Function::Handle( |
| 1047 isolate, | 1047 isolate, |
| 1048 Resolver::ResolveStatic(isolate_lib, | 1048 Resolver::ResolveStatic(isolate_lib, |
| 1049 class_name, | 1049 class_name, |
| 1050 function_name, | 1050 function_name, |
| 1051 kNumArguments, | 1051 kNumArguments, |
| 1052 Object::empty_array(), | 1052 Object::empty_array(), |
| 1053 Resolver::kIsQualified)); | 1053 Resolver::kIsQualified, |
| 1054 NULL)); // No ambiguity error expected. | |
| 1054 ASSERT(!function.IsNull()); | 1055 ASSERT(!function.IsNull()); |
| 1055 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 1056 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
| 1056 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id))); | 1057 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id))); |
| 1057 return Api::NewHandle(isolate, DartEntry::InvokeFunction(function, args)); | 1058 return Api::NewHandle(isolate, DartEntry::InvokeFunction(function, args)); |
| 1058 } | 1059 } |
| 1059 | 1060 |
| 1060 | 1061 |
| 1061 DART_EXPORT Dart_Port Dart_GetMainPortId() { | 1062 DART_EXPORT Dart_Port Dart_GetMainPortId() { |
| 1062 Isolate* isolate = Isolate::Current(); | 1063 Isolate* isolate = Isolate::Current(); |
| 1063 CHECK_ISOLATE(isolate); | 1064 CHECK_ISOLATE(isolate); |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2040 const String& lib_url = String::Handle(String::New("dart:core")); | 2041 const String& lib_url = String::Handle(String::New("dart:core")); |
| 2041 const String& class_name = String::Handle(String::New("ArgumentError")); | 2042 const String& class_name = String::Handle(String::New("ArgumentError")); |
| 2042 const Library& lib = | 2043 const Library& lib = |
| 2043 Library::Handle(isolate, Library::LookupLibrary(lib_url)); | 2044 Library::Handle(isolate, Library::LookupLibrary(lib_url)); |
| 2044 if (lib.IsNull()) { | 2045 if (lib.IsNull()) { |
| 2045 const String& message = String::Handle( | 2046 const String& message = String::Handle( |
| 2046 String::NewFormatted("%s: library '%s' not found.", | 2047 String::NewFormatted("%s: library '%s' not found.", |
| 2047 CURRENT_FUNC, lib_url.ToCString())); | 2048 CURRENT_FUNC, lib_url.ToCString())); |
| 2048 return ApiError::New(message); | 2049 return ApiError::New(message); |
| 2049 } | 2050 } |
| 2050 const Class& cls = Class::Handle(isolate, | 2051 const Class& cls = Class::Handle( |
| 2051 lib.LookupClassAllowPrivate(class_name)); | 2052 isolate, lib.LookupClassAllowPrivate(class_name, NULL)); |
|
siva
2013/07/22 22:21:46
As discussed this should probably just ASSERT(!cls
regis
2013/07/22 23:51:27
Done.
| |
| 2052 if (cls.IsNull()) { | 2053 if (cls.IsNull()) { |
| 2053 const String& message = String::Handle( | 2054 const String& message = String::Handle( |
| 2054 String::NewFormatted("%s: class '%s' not found in library '%s'.", | 2055 String::NewFormatted("%s: class '%s' not found in library '%s'.", |
| 2055 CURRENT_FUNC, class_name.ToCString(), | 2056 CURRENT_FUNC, class_name.ToCString(), |
| 2056 lib_url.ToCString())); | 2057 lib_url.ToCString())); |
| 2057 return ApiError::New(message); | 2058 return ApiError::New(message); |
| 2058 } | 2059 } |
| 2059 Object& result = Object::Handle(isolate); | 2060 Object& result = Object::Handle(isolate); |
| 2060 String& dot_name = String::Handle(String::New(".")); | 2061 String& dot_name = String::Handle(String::New(".")); |
| 2061 String& constr_name = String::Handle(String::Concat(class_name, dot_name)); | 2062 String& constr_name = String::Handle(String::Concat(class_name, dot_name)); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2397 return Dart_TypedData_kInvalid; | 2398 return Dart_TypedData_kInvalid; |
| 2398 } | 2399 } |
| 2399 | 2400 |
| 2400 | 2401 |
| 2401 static RawObject* GetByteDataConstructor(Isolate* isolate, | 2402 static RawObject* GetByteDataConstructor(Isolate* isolate, |
| 2402 const String& constructor_name, | 2403 const String& constructor_name, |
| 2403 intptr_t num_args) { | 2404 intptr_t num_args) { |
| 2404 const Library& lib = | 2405 const Library& lib = |
| 2405 Library::Handle(isolate->object_store()->typed_data_library()); | 2406 Library::Handle(isolate->object_store()->typed_data_library()); |
| 2406 ASSERT(!lib.IsNull()); | 2407 ASSERT(!lib.IsNull()); |
| 2407 const Class& cls = | 2408 const Class& cls = Class::Handle( |
| 2408 Class::Handle(isolate, lib.LookupClassAllowPrivate(Symbols::ByteData())); | 2409 isolate, lib.LookupClassAllowPrivate(Symbols::ByteData(), NULL)); |
| 2409 ASSERT(!cls.IsNull()); | 2410 ASSERT(!cls.IsNull()); |
| 2410 return ResolveConstructor(CURRENT_FUNC, | 2411 return ResolveConstructor(CURRENT_FUNC, |
| 2411 cls, | 2412 cls, |
| 2412 Symbols::ByteData(), | 2413 Symbols::ByteData(), |
| 2413 constructor_name, | 2414 constructor_name, |
| 2414 num_args); | 2415 num_args); |
| 2415 } | 2416 } |
| 2416 | 2417 |
| 2417 | 2418 |
| 2418 static Dart_Handle NewByteData(Isolate* isolate, intptr_t length) { | 2419 static Dart_Handle NewByteData(Isolate* isolate, intptr_t length) { |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2987 } else if (obj.IsLibrary()) { | 2988 } else if (obj.IsLibrary()) { |
| 2988 // Check whether class finalization is needed. | 2989 // Check whether class finalization is needed. |
| 2989 const Library& lib = Library::Cast(obj); | 2990 const Library& lib = Library::Cast(obj); |
| 2990 | 2991 |
| 2991 // Finalize all classes if needed. | 2992 // Finalize all classes if needed. |
| 2992 Dart_Handle state = Api::CheckIsolateState(isolate); | 2993 Dart_Handle state = Api::CheckIsolateState(isolate); |
| 2993 if (::Dart_IsError(state)) { | 2994 if (::Dart_IsError(state)) { |
| 2994 return state; | 2995 return state; |
| 2995 } | 2996 } |
| 2996 | 2997 |
| 2998 String& ambiguity_error_msg = String::Handle(isolate); | |
| 2997 Function& function = Function::Handle(isolate); | 2999 Function& function = Function::Handle(isolate); |
| 2998 function = lib.LookupFunctionAllowPrivate(function_name); | 3000 function = lib.LookupFunctionAllowPrivate(function_name, |
| 3001 &ambiguity_error_msg); | |
| 2999 if (function.IsNull()) { | 3002 if (function.IsNull()) { |
| 3003 if (!ambiguity_error_msg.IsNull()) { | |
| 3004 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); | |
| 3005 } | |
| 3000 return Api::NewError("%s: did not find top-level function '%s'.", | 3006 return Api::NewError("%s: did not find top-level function '%s'.", |
| 3001 CURRENT_FUNC, | 3007 CURRENT_FUNC, |
| 3002 function_name.ToCString()); | 3008 function_name.ToCString()); |
| 3003 } | 3009 } |
| 3004 // LookupFunctionAllowPrivate does not check argument arity, so we | 3010 // LookupFunctionAllowPrivate does not check argument arity, so we |
| 3005 // do it here. | 3011 // do it here. |
| 3006 String& error_message = String::Handle(); | 3012 String& error_message = String::Handle(); |
| 3007 if (!function.AreValidArgumentCounts(number_of_arguments, | 3013 if (!function.AreValidArgumentCounts(number_of_arguments, |
| 3008 0, | 3014 0, |
| 3009 &error_message)) { | 3015 &error_message)) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3148 getter_name, | 3154 getter_name, |
| 3149 args, | 3155 args, |
| 3150 args_descriptor)); | 3156 args_descriptor)); |
| 3151 } | 3157 } |
| 3152 return Api::NewHandle(isolate, DartEntry::InvokeFunction(getter, args)); | 3158 return Api::NewHandle(isolate, DartEntry::InvokeFunction(getter, args)); |
| 3153 | 3159 |
| 3154 } else if (obj.IsLibrary()) { | 3160 } else if (obj.IsLibrary()) { |
| 3155 // To access a top-level we may need to use the Field or the | 3161 // To access a top-level we may need to use the Field or the |
| 3156 // getter Function. The getter function may either be in the | 3162 // getter Function. The getter function may either be in the |
| 3157 // library or in the field's owner class, depending. | 3163 // library or in the field's owner class, depending. |
| 3164 String& ambiguity_error_msg = String::Handle(isolate); | |
| 3158 const Library& lib = Library::Cast(obj); | 3165 const Library& lib = Library::Cast(obj); |
| 3159 field = lib.LookupFieldAllowPrivate(field_name); | 3166 field = lib.LookupFieldAllowPrivate(field_name, &ambiguity_error_msg); |
| 3160 if (field.IsNull()) { | 3167 if (field.IsNull() && ambiguity_error_msg.IsNull()) { |
| 3161 // No field found. Check for a getter in the lib. | 3168 // No field found and no ambiguity error. Check for a getter in the lib. |
| 3162 const String& getter_name = | 3169 const String& getter_name = |
| 3163 String::Handle(isolate, Field::GetterName(field_name)); | 3170 String::Handle(isolate, Field::GetterName(field_name)); |
| 3164 getter = lib.LookupFunctionAllowPrivate(getter_name); | 3171 getter = lib.LookupFunctionAllowPrivate(getter_name, |
| 3165 } else if (FieldIsUninitialized(isolate, field)) { | 3172 &ambiguity_error_msg); |
| 3173 } else if (!field.IsNull() && FieldIsUninitialized(isolate, field)) { | |
| 3166 // A field was found. Check for a getter in the field's owner classs. | 3174 // A field was found. Check for a getter in the field's owner classs. |
| 3167 const Class& cls = Class::Handle(isolate, field.owner()); | 3175 const Class& cls = Class::Handle(isolate, field.owner()); |
| 3168 const String& getter_name = | 3176 const String& getter_name = |
| 3169 String::Handle(isolate, Field::GetterName(field_name)); | 3177 String::Handle(isolate, Field::GetterName(field_name)); |
| 3170 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 3178 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
| 3171 } | 3179 } |
| 3172 | 3180 |
| 3173 if (!getter.IsNull()) { | 3181 if (!getter.IsNull()) { |
| 3174 // Invoke the getter and return the result. | 3182 // Invoke the getter and return the result. |
| 3175 return Api::NewHandle( | 3183 return Api::NewHandle( |
| 3176 isolate, DartEntry::InvokeFunction(getter, Object::empty_array())); | 3184 isolate, DartEntry::InvokeFunction(getter, Object::empty_array())); |
| 3177 } else if (!field.IsNull()) { | 3185 } |
| 3186 if (!field.IsNull()) { | |
| 3178 return Api::NewHandle(isolate, field.value()); | 3187 return Api::NewHandle(isolate, field.value()); |
| 3179 } else { | |
| 3180 return Api::NewError("%s: did not find top-level variable '%s'.", | |
| 3181 CURRENT_FUNC, field_name.ToCString()); | |
| 3182 } | 3188 } |
| 3189 if (!ambiguity_error_msg.IsNull()) { | |
| 3190 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); | |
| 3191 } | |
| 3192 return Api::NewError("%s: did not find top-level variable '%s'.", | |
| 3193 CURRENT_FUNC, field_name.ToCString()); | |
| 3183 | 3194 |
| 3184 } else if (obj.IsError()) { | 3195 } else if (obj.IsError()) { |
| 3185 return container; | 3196 return container; |
| 3186 } else { | 3197 } else { |
| 3187 return Api::NewError( | 3198 return Api::NewError( |
| 3188 "%s expects argument 'container' to be an object, type, or library.", | 3199 "%s expects argument 'container' to be an object, type, or library.", |
| 3189 CURRENT_FUNC); | 3200 CURRENT_FUNC); |
| 3190 } | 3201 } |
| 3191 } | 3202 } |
| 3192 | 3203 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3300 setter_name, | 3311 setter_name, |
| 3301 args, | 3312 args, |
| 3302 args_descriptor)); | 3313 args_descriptor)); |
| 3303 } | 3314 } |
| 3304 return Api::NewHandle(isolate, DartEntry::InvokeFunction(setter, args)); | 3315 return Api::NewHandle(isolate, DartEntry::InvokeFunction(setter, args)); |
| 3305 | 3316 |
| 3306 } else if (obj.IsLibrary()) { | 3317 } else if (obj.IsLibrary()) { |
| 3307 // To access a top-level we may need to use the Field or the | 3318 // To access a top-level we may need to use the Field or the |
| 3308 // setter Function. The setter function may either be in the | 3319 // setter Function. The setter function may either be in the |
| 3309 // library or in the field's owner class, depending. | 3320 // library or in the field's owner class, depending. |
| 3321 String& ambiguity_error_msg = String::Handle(isolate); | |
| 3310 const Library& lib = Library::Cast(obj); | 3322 const Library& lib = Library::Cast(obj); |
| 3311 field = lib.LookupFieldAllowPrivate(field_name); | 3323 field = lib.LookupFieldAllowPrivate(field_name, &ambiguity_error_msg); |
| 3312 if (field.IsNull()) { | 3324 if (field.IsNull() && ambiguity_error_msg.IsNull()) { |
| 3313 const String& setter_name = | 3325 const String& setter_name = |
| 3314 String::Handle(isolate, Field::SetterName(field_name)); | 3326 String::Handle(isolate, Field::SetterName(field_name)); |
| 3315 setter ^= lib.LookupFunctionAllowPrivate(setter_name); | 3327 setter ^= lib.LookupFunctionAllowPrivate(setter_name, |
| 3328 &ambiguity_error_msg); | |
| 3316 } | 3329 } |
| 3317 | 3330 |
| 3318 if (!setter.IsNull()) { | 3331 if (!setter.IsNull()) { |
| 3319 // Invoke the setter and return the result. | 3332 // Invoke the setter and return the result. |
| 3320 const int kNumArgs = 1; | 3333 const int kNumArgs = 1; |
| 3321 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); | 3334 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); |
| 3322 args.SetAt(0, value_instance); | 3335 args.SetAt(0, value_instance); |
| 3323 const Object& result = | 3336 const Object& result = |
| 3324 Object::Handle(isolate, DartEntry::InvokeFunction(setter, args)); | 3337 Object::Handle(isolate, DartEntry::InvokeFunction(setter, args)); |
| 3325 if (result.IsError()) { | 3338 if (result.IsError()) { |
| 3326 return Api::NewHandle(isolate, result.raw()); | 3339 return Api::NewHandle(isolate, result.raw()); |
| 3327 } else { | |
| 3328 return Api::Success(); | |
| 3329 } | 3340 } |
| 3330 } else if (!field.IsNull()) { | 3341 return Api::Success(); |
| 3342 } | |
| 3343 if (!field.IsNull()) { | |
| 3331 if (field.is_final()) { | 3344 if (field.is_final()) { |
| 3332 return Api::NewError("%s: cannot set final top-level variable '%s'.", | 3345 return Api::NewError("%s: cannot set final top-level variable '%s'.", |
| 3333 CURRENT_FUNC, field_name.ToCString()); | 3346 CURRENT_FUNC, field_name.ToCString()); |
| 3334 } else { | |
| 3335 field.set_value(value_instance); | |
| 3336 return Api::Success(); | |
| 3337 } | 3347 } |
| 3338 } else { | 3348 field.set_value(value_instance); |
| 3339 return Api::NewError("%s: did not find top-level variable '%s'.", | 3349 return Api::Success(); |
| 3340 CURRENT_FUNC, field_name.ToCString()); | |
| 3341 } | 3350 } |
| 3351 if (!ambiguity_error_msg.IsNull()) { | |
| 3352 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); | |
| 3353 } | |
| 3354 return Api::NewError("%s: did not find top-level variable '%s'.", | |
| 3355 CURRENT_FUNC, field_name.ToCString()); | |
| 3342 | 3356 |
| 3343 } else if (obj.IsError()) { | 3357 } else if (obj.IsError()) { |
| 3344 return container; | 3358 return container; |
| 3345 } else { | |
| 3346 return Api::NewError( | |
| 3347 "%s expects argument 'container' to be an object, type, or library.", | |
| 3348 CURRENT_FUNC); | |
| 3349 } | 3359 } |
| 3360 return Api::NewError( | |
| 3361 "%s expects argument 'container' to be an object, type, or library.", | |
| 3362 CURRENT_FUNC); | |
| 3350 } | 3363 } |
| 3351 | 3364 |
| 3352 | 3365 |
| 3353 // --- Exceptions ---- | 3366 // --- Exceptions ---- |
| 3354 | 3367 |
| 3355 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { | 3368 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { |
| 3356 Isolate* isolate = Isolate::Current(); | 3369 Isolate* isolate = Isolate::Current(); |
| 3357 CHECK_ISOLATE(isolate); | 3370 CHECK_ISOLATE(isolate); |
| 3358 CHECK_CALLBACK_STATE(isolate); | 3371 CHECK_CALLBACK_STATE(isolate); |
| 3359 { | 3372 { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3686 Isolate* isolate = Isolate::Current(); | 3699 Isolate* isolate = Isolate::Current(); |
| 3687 DARTSCOPE(isolate); | 3700 DARTSCOPE(isolate); |
| 3688 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | 3701 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
| 3689 if (lib.IsNull()) { | 3702 if (lib.IsNull()) { |
| 3690 RETURN_TYPE_ERROR(isolate, library, Library); | 3703 RETURN_TYPE_ERROR(isolate, library, Library); |
| 3691 } | 3704 } |
| 3692 const String& cls_name = Api::UnwrapStringHandle(isolate, class_name); | 3705 const String& cls_name = Api::UnwrapStringHandle(isolate, class_name); |
| 3693 if (cls_name.IsNull()) { | 3706 if (cls_name.IsNull()) { |
| 3694 RETURN_TYPE_ERROR(isolate, class_name, String); | 3707 RETURN_TYPE_ERROR(isolate, class_name, String); |
| 3695 } | 3708 } |
| 3696 const Class& cls = | 3709 String& ambiguity_error_msg = String::Handle(isolate); |
| 3697 Class::Handle(isolate, lib.LookupClassAllowPrivate(cls_name)); | 3710 const Class& cls = Class::Handle( |
| 3711 isolate, lib.LookupClassAllowPrivate(cls_name, &ambiguity_error_msg)); | |
| 3698 if (cls.IsNull()) { | 3712 if (cls.IsNull()) { |
| 3713 if (!ambiguity_error_msg.IsNull()) { | |
| 3714 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); | |
| 3715 } | |
| 3699 // TODO(turnidge): Return null or error in this case? | 3716 // TODO(turnidge): Return null or error in this case? |
| 3700 const String& lib_name = String::Handle(isolate, lib.name()); | 3717 const String& lib_name = String::Handle(isolate, lib.name()); |
| 3701 return Api::NewError("Class '%s' not found in library '%s'.", | 3718 return Api::NewError("Class '%s' not found in library '%s'.", |
| 3702 cls_name.ToCString(), lib_name.ToCString()); | 3719 cls_name.ToCString(), lib_name.ToCString()); |
| 3703 } | 3720 } |
| 3704 return Api::NewHandle(isolate, cls.raw()); | 3721 return Api::NewHandle(isolate, cls.raw()); |
| 3705 } | 3722 } |
| 3706 | 3723 |
| 3707 | 3724 |
| 3708 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, | 3725 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3719 } | 3736 } |
| 3720 const String& name_str = Api::UnwrapStringHandle(isolate, class_name); | 3737 const String& name_str = Api::UnwrapStringHandle(isolate, class_name); |
| 3721 if (name_str.IsNull()) { | 3738 if (name_str.IsNull()) { |
| 3722 RETURN_TYPE_ERROR(isolate, class_name, String); | 3739 RETURN_TYPE_ERROR(isolate, class_name, String); |
| 3723 } | 3740 } |
| 3724 // Ensure all classes are finalized. | 3741 // Ensure all classes are finalized. |
| 3725 Dart_Handle state = Api::CheckIsolateState(isolate); | 3742 Dart_Handle state = Api::CheckIsolateState(isolate); |
| 3726 if (::Dart_IsError(state)) { | 3743 if (::Dart_IsError(state)) { |
| 3727 return state; | 3744 return state; |
| 3728 } | 3745 } |
| 3746 String& ambiguity_error_msg = String::Handle(isolate); | |
| 3729 const Class& cls = | 3747 const Class& cls = |
| 3730 Class::Handle(isolate, lib.LookupClassAllowPrivate(name_str)); | 3748 Class::Handle(isolate, lib.LookupClassAllowPrivate(name_str, |
| 3749 &ambiguity_error_msg)); | |
| 3731 if (cls.IsNull()) { | 3750 if (cls.IsNull()) { |
| 3751 if (!ambiguity_error_msg.IsNull()) { | |
| 3752 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); | |
| 3753 } | |
| 3732 const String& lib_name = String::Handle(isolate, lib.name()); | 3754 const String& lib_name = String::Handle(isolate, lib.name()); |
| 3733 return Api::NewError("Type '%s' not found in library '%s'.", | 3755 return Api::NewError("Type '%s' not found in library '%s'.", |
| 3734 name_str.ToCString(), lib_name.ToCString()); | 3756 name_str.ToCString(), lib_name.ToCString()); |
| 3735 } | 3757 } |
| 3736 if (cls.NumTypeArguments() == 0) { | 3758 if (cls.NumTypeArguments() == 0) { |
| 3737 if (number_of_type_arguments != 0) { | 3759 if (number_of_type_arguments != 0) { |
| 3738 return Api::NewError("Invalid number of type arguments specified, " | 3760 return Api::NewError("Invalid number of type arguments specified, " |
| 3739 "got %"Pd" expected 0", number_of_type_arguments); | 3761 "got %"Pd" expected 0", number_of_type_arguments); |
| 3740 } | 3762 } |
| 3741 return Api::NewHandle(isolate, Type::NewNonParameterizedType(cls)); | 3763 return Api::NewHandle(isolate, Type::NewNonParameterizedType(cls)); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4004 } | 4026 } |
| 4005 { | 4027 { |
| 4006 NoGCScope no_gc; | 4028 NoGCScope no_gc; |
| 4007 RawObject* raw_obj = obj.raw(); | 4029 RawObject* raw_obj = obj.raw(); |
| 4008 isolate->heap()->SetPeer(raw_obj, peer); | 4030 isolate->heap()->SetPeer(raw_obj, peer); |
| 4009 } | 4031 } |
| 4010 return Api::Success(); | 4032 return Api::Success(); |
| 4011 } | 4033 } |
| 4012 | 4034 |
| 4013 } // namespace dart | 4035 } // namespace dart |
| OLD | NEW |