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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 const String& lib_url = String::Handle(String::New("dart:core")); | 2055 const String& lib_url = String::Handle(String::New("dart:core")); |
2055 const String& class_name = String::Handle(String::New("ArgumentError")); | 2056 const String& class_name = String::Handle(String::New("ArgumentError")); |
2056 const Library& lib = | 2057 const Library& lib = |
2057 Library::Handle(isolate, Library::LookupLibrary(lib_url)); | 2058 Library::Handle(isolate, Library::LookupLibrary(lib_url)); |
2058 if (lib.IsNull()) { | 2059 if (lib.IsNull()) { |
2059 const String& message = String::Handle( | 2060 const String& message = String::Handle( |
2060 String::NewFormatted("%s: library '%s' not found.", | 2061 String::NewFormatted("%s: library '%s' not found.", |
2061 CURRENT_FUNC, lib_url.ToCString())); | 2062 CURRENT_FUNC, lib_url.ToCString())); |
2062 return ApiError::New(message); | 2063 return ApiError::New(message); |
2063 } | 2064 } |
2064 const Class& cls = Class::Handle(isolate, | 2065 const Class& cls = Class::Handle( |
2065 lib.LookupClassAllowPrivate(class_name)); | 2066 isolate, lib.LookupClassAllowPrivate(class_name, NULL)); |
2066 if (cls.IsNull()) { | 2067 ASSERT(!cls.IsNull()); |
2067 const String& message = String::Handle( | |
2068 String::NewFormatted("%s: class '%s' not found in library '%s'.", | |
2069 CURRENT_FUNC, class_name.ToCString(), | |
2070 lib_url.ToCString())); | |
2071 return ApiError::New(message); | |
2072 } | |
2073 Object& result = Object::Handle(isolate); | 2068 Object& result = Object::Handle(isolate); |
2074 String& dot_name = String::Handle(String::New(".")); | 2069 String& dot_name = String::Handle(String::New(".")); |
2075 String& constr_name = String::Handle(String::Concat(class_name, dot_name)); | 2070 String& constr_name = String::Handle(String::Concat(class_name, dot_name)); |
2076 result = ResolveConstructor(CURRENT_FUNC, cls, class_name, constr_name, 1); | 2071 result = ResolveConstructor(CURRENT_FUNC, cls, class_name, constr_name, 1); |
2077 if (result.IsError()) return result.raw(); | 2072 if (result.IsError()) return result.raw(); |
2078 ASSERT(result.IsFunction()); | 2073 ASSERT(result.IsFunction()); |
2079 Function& constructor = Function::Handle(isolate); | 2074 Function& constructor = Function::Handle(isolate); |
2080 constructor ^= result.raw(); | 2075 constructor ^= result.raw(); |
2081 if (!constructor.IsConstructor()) { | 2076 if (!constructor.IsConstructor()) { |
2082 const String& message = String::Handle( | 2077 const String& message = String::Handle( |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 return Dart_TypedData_kInvalid; | 2406 return Dart_TypedData_kInvalid; |
2412 } | 2407 } |
2413 | 2408 |
2414 | 2409 |
2415 static RawObject* GetByteDataConstructor(Isolate* isolate, | 2410 static RawObject* GetByteDataConstructor(Isolate* isolate, |
2416 const String& constructor_name, | 2411 const String& constructor_name, |
2417 intptr_t num_args) { | 2412 intptr_t num_args) { |
2418 const Library& lib = | 2413 const Library& lib = |
2419 Library::Handle(isolate->object_store()->typed_data_library()); | 2414 Library::Handle(isolate->object_store()->typed_data_library()); |
2420 ASSERT(!lib.IsNull()); | 2415 ASSERT(!lib.IsNull()); |
2421 const Class& cls = | 2416 const Class& cls = Class::Handle( |
2422 Class::Handle(isolate, lib.LookupClassAllowPrivate(Symbols::ByteData())); | 2417 isolate, lib.LookupClassAllowPrivate(Symbols::ByteData(), NULL)); |
2423 ASSERT(!cls.IsNull()); | 2418 ASSERT(!cls.IsNull()); |
2424 return ResolveConstructor(CURRENT_FUNC, | 2419 return ResolveConstructor(CURRENT_FUNC, |
2425 cls, | 2420 cls, |
2426 Symbols::ByteData(), | 2421 Symbols::ByteData(), |
2427 constructor_name, | 2422 constructor_name, |
2428 num_args); | 2423 num_args); |
2429 } | 2424 } |
2430 | 2425 |
2431 | 2426 |
2432 static Dart_Handle NewByteData(Isolate* isolate, intptr_t length) { | 2427 static Dart_Handle NewByteData(Isolate* isolate, intptr_t length) { |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3001 } else if (obj.IsLibrary()) { | 2996 } else if (obj.IsLibrary()) { |
3002 // Check whether class finalization is needed. | 2997 // Check whether class finalization is needed. |
3003 const Library& lib = Library::Cast(obj); | 2998 const Library& lib = Library::Cast(obj); |
3004 | 2999 |
3005 // Finalize all classes if needed. | 3000 // Finalize all classes if needed. |
3006 Dart_Handle state = Api::CheckIsolateState(isolate); | 3001 Dart_Handle state = Api::CheckIsolateState(isolate); |
3007 if (::Dart_IsError(state)) { | 3002 if (::Dart_IsError(state)) { |
3008 return state; | 3003 return state; |
3009 } | 3004 } |
3010 | 3005 |
| 3006 String& ambiguity_error_msg = String::Handle(isolate); |
3011 Function& function = Function::Handle(isolate); | 3007 Function& function = Function::Handle(isolate); |
3012 function = lib.LookupFunctionAllowPrivate(function_name); | 3008 function = lib.LookupFunctionAllowPrivate(function_name, |
| 3009 &ambiguity_error_msg); |
3013 if (function.IsNull()) { | 3010 if (function.IsNull()) { |
| 3011 if (!ambiguity_error_msg.IsNull()) { |
| 3012 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); |
| 3013 } |
3014 return Api::NewError("%s: did not find top-level function '%s'.", | 3014 return Api::NewError("%s: did not find top-level function '%s'.", |
3015 CURRENT_FUNC, | 3015 CURRENT_FUNC, |
3016 function_name.ToCString()); | 3016 function_name.ToCString()); |
3017 } | 3017 } |
3018 // LookupFunctionAllowPrivate does not check argument arity, so we | 3018 // LookupFunctionAllowPrivate does not check argument arity, so we |
3019 // do it here. | 3019 // do it here. |
3020 String& error_message = String::Handle(); | 3020 String& error_message = String::Handle(); |
3021 if (!function.AreValidArgumentCounts(number_of_arguments, | 3021 if (!function.AreValidArgumentCounts(number_of_arguments, |
3022 0, | 3022 0, |
3023 &error_message)) { | 3023 &error_message)) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3162 getter_name, | 3162 getter_name, |
3163 args, | 3163 args, |
3164 args_descriptor)); | 3164 args_descriptor)); |
3165 } | 3165 } |
3166 return Api::NewHandle(isolate, DartEntry::InvokeFunction(getter, args)); | 3166 return Api::NewHandle(isolate, DartEntry::InvokeFunction(getter, args)); |
3167 | 3167 |
3168 } else if (obj.IsLibrary()) { | 3168 } else if (obj.IsLibrary()) { |
3169 // To access a top-level we may need to use the Field or the | 3169 // To access a top-level we may need to use the Field or the |
3170 // getter Function. The getter function may either be in the | 3170 // getter Function. The getter function may either be in the |
3171 // library or in the field's owner class, depending. | 3171 // library or in the field's owner class, depending. |
| 3172 String& ambiguity_error_msg = String::Handle(isolate); |
3172 const Library& lib = Library::Cast(obj); | 3173 const Library& lib = Library::Cast(obj); |
3173 field = lib.LookupFieldAllowPrivate(field_name); | 3174 field = lib.LookupFieldAllowPrivate(field_name, &ambiguity_error_msg); |
3174 if (field.IsNull()) { | 3175 if (field.IsNull() && ambiguity_error_msg.IsNull()) { |
3175 // No field found. Check for a getter in the lib. | 3176 // No field found and no ambiguity error. Check for a getter in the lib. |
3176 const String& getter_name = | 3177 const String& getter_name = |
3177 String::Handle(isolate, Field::GetterName(field_name)); | 3178 String::Handle(isolate, Field::GetterName(field_name)); |
3178 getter = lib.LookupFunctionAllowPrivate(getter_name); | 3179 getter = lib.LookupFunctionAllowPrivate(getter_name, |
3179 } else if (FieldIsUninitialized(isolate, field)) { | 3180 &ambiguity_error_msg); |
| 3181 } else if (!field.IsNull() && FieldIsUninitialized(isolate, field)) { |
3180 // A field was found. Check for a getter in the field's owner classs. | 3182 // A field was found. Check for a getter in the field's owner classs. |
3181 const Class& cls = Class::Handle(isolate, field.owner()); | 3183 const Class& cls = Class::Handle(isolate, field.owner()); |
3182 const String& getter_name = | 3184 const String& getter_name = |
3183 String::Handle(isolate, Field::GetterName(field_name)); | 3185 String::Handle(isolate, Field::GetterName(field_name)); |
3184 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); | 3186 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); |
3185 } | 3187 } |
3186 | 3188 |
3187 if (!getter.IsNull()) { | 3189 if (!getter.IsNull()) { |
3188 // Invoke the getter and return the result. | 3190 // Invoke the getter and return the result. |
3189 return Api::NewHandle( | 3191 return Api::NewHandle( |
3190 isolate, DartEntry::InvokeFunction(getter, Object::empty_array())); | 3192 isolate, DartEntry::InvokeFunction(getter, Object::empty_array())); |
3191 } else if (!field.IsNull()) { | 3193 } |
| 3194 if (!field.IsNull()) { |
3192 return Api::NewHandle(isolate, field.value()); | 3195 return Api::NewHandle(isolate, field.value()); |
3193 } else { | |
3194 return Api::NewError("%s: did not find top-level variable '%s'.", | |
3195 CURRENT_FUNC, field_name.ToCString()); | |
3196 } | 3196 } |
| 3197 if (!ambiguity_error_msg.IsNull()) { |
| 3198 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); |
| 3199 } |
| 3200 return Api::NewError("%s: did not find top-level variable '%s'.", |
| 3201 CURRENT_FUNC, field_name.ToCString()); |
3197 | 3202 |
3198 } else if (obj.IsError()) { | 3203 } else if (obj.IsError()) { |
3199 return container; | 3204 return container; |
3200 } else { | 3205 } else { |
3201 return Api::NewError( | 3206 return Api::NewError( |
3202 "%s expects argument 'container' to be an object, type, or library.", | 3207 "%s expects argument 'container' to be an object, type, or library.", |
3203 CURRENT_FUNC); | 3208 CURRENT_FUNC); |
3204 } | 3209 } |
3205 } | 3210 } |
3206 | 3211 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 setter_name, | 3319 setter_name, |
3315 args, | 3320 args, |
3316 args_descriptor)); | 3321 args_descriptor)); |
3317 } | 3322 } |
3318 return Api::NewHandle(isolate, DartEntry::InvokeFunction(setter, args)); | 3323 return Api::NewHandle(isolate, DartEntry::InvokeFunction(setter, args)); |
3319 | 3324 |
3320 } else if (obj.IsLibrary()) { | 3325 } else if (obj.IsLibrary()) { |
3321 // To access a top-level we may need to use the Field or the | 3326 // To access a top-level we may need to use the Field or the |
3322 // setter Function. The setter function may either be in the | 3327 // setter Function. The setter function may either be in the |
3323 // library or in the field's owner class, depending. | 3328 // library or in the field's owner class, depending. |
| 3329 String& ambiguity_error_msg = String::Handle(isolate); |
3324 const Library& lib = Library::Cast(obj); | 3330 const Library& lib = Library::Cast(obj); |
3325 field = lib.LookupFieldAllowPrivate(field_name); | 3331 field = lib.LookupFieldAllowPrivate(field_name, &ambiguity_error_msg); |
3326 if (field.IsNull()) { | 3332 if (field.IsNull() && ambiguity_error_msg.IsNull()) { |
3327 const String& setter_name = | 3333 const String& setter_name = |
3328 String::Handle(isolate, Field::SetterName(field_name)); | 3334 String::Handle(isolate, Field::SetterName(field_name)); |
3329 setter ^= lib.LookupFunctionAllowPrivate(setter_name); | 3335 setter ^= lib.LookupFunctionAllowPrivate(setter_name, |
| 3336 &ambiguity_error_msg); |
3330 } | 3337 } |
3331 | 3338 |
3332 if (!setter.IsNull()) { | 3339 if (!setter.IsNull()) { |
3333 // Invoke the setter and return the result. | 3340 // Invoke the setter and return the result. |
3334 const int kNumArgs = 1; | 3341 const int kNumArgs = 1; |
3335 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); | 3342 const Array& args = Array::Handle(isolate, Array::New(kNumArgs)); |
3336 args.SetAt(0, value_instance); | 3343 args.SetAt(0, value_instance); |
3337 const Object& result = | 3344 const Object& result = |
3338 Object::Handle(isolate, DartEntry::InvokeFunction(setter, args)); | 3345 Object::Handle(isolate, DartEntry::InvokeFunction(setter, args)); |
3339 if (result.IsError()) { | 3346 if (result.IsError()) { |
3340 return Api::NewHandle(isolate, result.raw()); | 3347 return Api::NewHandle(isolate, result.raw()); |
3341 } else { | |
3342 return Api::Success(); | |
3343 } | 3348 } |
3344 } else if (!field.IsNull()) { | 3349 return Api::Success(); |
| 3350 } |
| 3351 if (!field.IsNull()) { |
3345 if (field.is_final()) { | 3352 if (field.is_final()) { |
3346 return Api::NewError("%s: cannot set final top-level variable '%s'.", | 3353 return Api::NewError("%s: cannot set final top-level variable '%s'.", |
3347 CURRENT_FUNC, field_name.ToCString()); | 3354 CURRENT_FUNC, field_name.ToCString()); |
3348 } else { | |
3349 field.set_value(value_instance); | |
3350 return Api::Success(); | |
3351 } | 3355 } |
3352 } else { | 3356 field.set_value(value_instance); |
3353 return Api::NewError("%s: did not find top-level variable '%s'.", | 3357 return Api::Success(); |
3354 CURRENT_FUNC, field_name.ToCString()); | |
3355 } | 3358 } |
| 3359 if (!ambiguity_error_msg.IsNull()) { |
| 3360 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); |
| 3361 } |
| 3362 return Api::NewError("%s: did not find top-level variable '%s'.", |
| 3363 CURRENT_FUNC, field_name.ToCString()); |
3356 | 3364 |
3357 } else if (obj.IsError()) { | 3365 } else if (obj.IsError()) { |
3358 return container; | 3366 return container; |
3359 } else { | |
3360 return Api::NewError( | |
3361 "%s expects argument 'container' to be an object, type, or library.", | |
3362 CURRENT_FUNC); | |
3363 } | 3367 } |
| 3368 return Api::NewError( |
| 3369 "%s expects argument 'container' to be an object, type, or library.", |
| 3370 CURRENT_FUNC); |
3364 } | 3371 } |
3365 | 3372 |
3366 | 3373 |
3367 // --- Exceptions ---- | 3374 // --- Exceptions ---- |
3368 | 3375 |
3369 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { | 3376 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { |
3370 Isolate* isolate = Isolate::Current(); | 3377 Isolate* isolate = Isolate::Current(); |
3371 CHECK_ISOLATE(isolate); | 3378 CHECK_ISOLATE(isolate); |
3372 CHECK_CALLBACK_STATE(isolate); | 3379 CHECK_CALLBACK_STATE(isolate); |
3373 { | 3380 { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 Isolate* isolate = Isolate::Current(); | 3707 Isolate* isolate = Isolate::Current(); |
3701 DARTSCOPE(isolate); | 3708 DARTSCOPE(isolate); |
3702 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | 3709 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
3703 if (lib.IsNull()) { | 3710 if (lib.IsNull()) { |
3704 RETURN_TYPE_ERROR(isolate, library, Library); | 3711 RETURN_TYPE_ERROR(isolate, library, Library); |
3705 } | 3712 } |
3706 const String& cls_name = Api::UnwrapStringHandle(isolate, class_name); | 3713 const String& cls_name = Api::UnwrapStringHandle(isolate, class_name); |
3707 if (cls_name.IsNull()) { | 3714 if (cls_name.IsNull()) { |
3708 RETURN_TYPE_ERROR(isolate, class_name, String); | 3715 RETURN_TYPE_ERROR(isolate, class_name, String); |
3709 } | 3716 } |
3710 const Class& cls = | 3717 String& ambiguity_error_msg = String::Handle(isolate); |
3711 Class::Handle(isolate, lib.LookupClassAllowPrivate(cls_name)); | 3718 const Class& cls = Class::Handle( |
| 3719 isolate, lib.LookupClassAllowPrivate(cls_name, &ambiguity_error_msg)); |
3712 if (cls.IsNull()) { | 3720 if (cls.IsNull()) { |
| 3721 if (!ambiguity_error_msg.IsNull()) { |
| 3722 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); |
| 3723 } |
3713 // TODO(turnidge): Return null or error in this case? | 3724 // TODO(turnidge): Return null or error in this case? |
3714 const String& lib_name = String::Handle(isolate, lib.name()); | 3725 const String& lib_name = String::Handle(isolate, lib.name()); |
3715 return Api::NewError("Class '%s' not found in library '%s'.", | 3726 return Api::NewError("Class '%s' not found in library '%s'.", |
3716 cls_name.ToCString(), lib_name.ToCString()); | 3727 cls_name.ToCString(), lib_name.ToCString()); |
3717 } | 3728 } |
3718 return Api::NewHandle(isolate, cls.raw()); | 3729 return Api::NewHandle(isolate, cls.raw()); |
3719 } | 3730 } |
3720 | 3731 |
3721 | 3732 |
3722 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, | 3733 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, |
(...skipping 10 matching lines...) Expand all Loading... |
3733 } | 3744 } |
3734 const String& name_str = Api::UnwrapStringHandle(isolate, class_name); | 3745 const String& name_str = Api::UnwrapStringHandle(isolate, class_name); |
3735 if (name_str.IsNull()) { | 3746 if (name_str.IsNull()) { |
3736 RETURN_TYPE_ERROR(isolate, class_name, String); | 3747 RETURN_TYPE_ERROR(isolate, class_name, String); |
3737 } | 3748 } |
3738 // Ensure all classes are finalized. | 3749 // Ensure all classes are finalized. |
3739 Dart_Handle state = Api::CheckIsolateState(isolate); | 3750 Dart_Handle state = Api::CheckIsolateState(isolate); |
3740 if (::Dart_IsError(state)) { | 3751 if (::Dart_IsError(state)) { |
3741 return state; | 3752 return state; |
3742 } | 3753 } |
| 3754 String& ambiguity_error_msg = String::Handle(isolate); |
3743 const Class& cls = | 3755 const Class& cls = |
3744 Class::Handle(isolate, lib.LookupClassAllowPrivate(name_str)); | 3756 Class::Handle(isolate, lib.LookupClassAllowPrivate(name_str, |
| 3757 &ambiguity_error_msg)); |
3745 if (cls.IsNull()) { | 3758 if (cls.IsNull()) { |
| 3759 if (!ambiguity_error_msg.IsNull()) { |
| 3760 return Api::NewError("%s.", ambiguity_error_msg.ToCString()); |
| 3761 } |
3746 const String& lib_name = String::Handle(isolate, lib.name()); | 3762 const String& lib_name = String::Handle(isolate, lib.name()); |
3747 return Api::NewError("Type '%s' not found in library '%s'.", | 3763 return Api::NewError("Type '%s' not found in library '%s'.", |
3748 name_str.ToCString(), lib_name.ToCString()); | 3764 name_str.ToCString(), lib_name.ToCString()); |
3749 } | 3765 } |
3750 if (cls.NumTypeArguments() == 0) { | 3766 if (cls.NumTypeArguments() == 0) { |
3751 if (number_of_type_arguments != 0) { | 3767 if (number_of_type_arguments != 0) { |
3752 return Api::NewError("Invalid number of type arguments specified, " | 3768 return Api::NewError("Invalid number of type arguments specified, " |
3753 "got %"Pd" expected 0", number_of_type_arguments); | 3769 "got %"Pd" expected 0", number_of_type_arguments); |
3754 } | 3770 } |
3755 return Api::NewHandle(isolate, Type::NewNonParameterizedType(cls)); | 3771 return Api::NewHandle(isolate, Type::NewNonParameterizedType(cls)); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 } | 4034 } |
4019 { | 4035 { |
4020 NoGCScope no_gc; | 4036 NoGCScope no_gc; |
4021 RawObject* raw_obj = obj.raw(); | 4037 RawObject* raw_obj = obj.raw(); |
4022 isolate->heap()->SetPeer(raw_obj, peer); | 4038 isolate->heap()->SetPeer(raw_obj, peer); |
4023 } | 4039 } |
4024 return Api::Success(); | 4040 return Api::Success(); |
4025 } | 4041 } |
4026 | 4042 |
4027 } // namespace dart | 4043 } // namespace dart |
OLD | NEW |