Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr(); | 277 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr(); |
| 278 ExternalStringData<uint32_t>* data = raw_string->external_data_; | 278 ExternalStringData<uint32_t>* data = raw_string->external_data_; |
| 279 *peer = data->peer(); | 279 *peer = data->peer(); |
| 280 return true; | 280 return true; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 // When we want to return a handle to a type to the user, we handle | |
| 288 // class-types differently than some other types. | |
| 289 static Dart_Handle TypeToHandle(Isolate* isolate, | |
| 290 const char* function_name, | |
| 291 const AbstractType& type) { | |
| 292 if (type.HasResolvedTypeClass()) { | |
| 293 const Class& cls = Class::Handle(isolate, type.type_class()); | |
| 294 #if defined(DEBUG) | |
| 295 const Library& lib = Library::Handle(cls.library()); | |
| 296 if (lib.IsNull()) { | |
| 297 ASSERT(cls.IsDynamicClass() || cls.IsVoidClass()); | |
| 298 } | |
| 299 #endif | |
| 300 return Api::NewHandle(isolate, cls.raw()); | |
| 301 } else if (type.IsTypeParameter()) { | |
| 302 return Api::NewHandle(isolate, type.raw()); | |
| 303 } else { | |
| 304 return Api::NewError("%s: unexpected type '%s' encountered.", | |
| 305 function_name, type.ToCString()); | |
| 306 } | |
| 307 } | |
| 308 | |
| 309 | |
| 287 // --- Handles --- | 310 // --- Handles --- |
| 288 | 311 |
| 289 | 312 |
| 290 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { | 313 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { |
| 291 return RawObject::IsErrorClassId(Api::ClassId(handle)); | 314 return RawObject::IsErrorClassId(Api::ClassId(handle)); |
| 292 } | 315 } |
| 293 | 316 |
| 294 | 317 |
| 295 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { | 318 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { |
| 296 return Api::ClassId(object) == kApiErrorCid; | 319 return Api::ClassId(object) == kApiErrorCid; |
| (...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2454 Isolate* isolate = Isolate::Current(); | 2477 Isolate* isolate = Isolate::Current(); |
| 2455 DARTSCOPE(isolate); | 2478 DARTSCOPE(isolate); |
| 2456 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | 2479 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); |
| 2457 if (cls.IsNull()) { | 2480 if (cls.IsNull()) { |
| 2458 RETURN_TYPE_ERROR(isolate, clazz, Class); | 2481 RETURN_TYPE_ERROR(isolate, clazz, Class); |
| 2459 } | 2482 } |
| 2460 | 2483 |
| 2461 #if defined(DEBUG) | 2484 #if defined(DEBUG) |
| 2462 const Library& lib = Library::Handle(cls.library()); | 2485 const Library& lib = Library::Handle(cls.library()); |
| 2463 if (lib.IsNull()) { | 2486 if (lib.IsNull()) { |
| 2464 ASSERT(cls.IsDynamicClass() || cls.IsVoidClass()); | 2487 // ASSERT(cls.IsDynamicClass() || cls.IsVoidClass()); |
|
cshapiro
2012/09/12 18:52:07
This should have a TODO for the commented out code
| |
| 2488 if (!cls.IsDynamicClass() && !cls.IsVoidClass()) { | |
| 2489 fprintf(stderr, "NO LIBRARY: %s\n", cls.ToCString()); | |
|
cshapiro
2012/09/12 18:52:07
fprintf? Why not use something in OS instead ?
| |
| 2490 } | |
| 2465 } | 2491 } |
| 2466 #endif | 2492 #endif |
| 2467 | 2493 |
| 2468 return Api::NewHandle(isolate, cls.library()); | 2494 return Api::NewHandle(isolate, cls.library()); |
| 2469 } | 2495 } |
| 2470 | 2496 |
| 2471 | 2497 |
| 2472 DART_EXPORT Dart_Handle Dart_ClassGetDefault(Dart_Handle clazz) { | 2498 DART_EXPORT Dart_Handle Dart_ClassGetDefault(Dart_Handle clazz) { |
| 2473 Isolate* isolate = Isolate::Current(); | 2499 Isolate* isolate = Isolate::Current(); |
| 2474 DARTSCOPE(isolate); | 2500 DARTSCOPE(isolate); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2533 if (interface_type.HasResolvedTypeClass()) { | 2559 if (interface_type.HasResolvedTypeClass()) { |
| 2534 return Api::NewHandle(isolate, interface_type.type_class()); | 2560 return Api::NewHandle(isolate, interface_type.type_class()); |
| 2535 } | 2561 } |
| 2536 const String& type_name = | 2562 const String& type_name = |
| 2537 String::Handle(isolate, interface_type.TypeClassName()); | 2563 String::Handle(isolate, interface_type.TypeClassName()); |
| 2538 return Api::NewError("%s: internal error: found unresolved type class '%s'.", | 2564 return Api::NewError("%s: internal error: found unresolved type class '%s'.", |
| 2539 CURRENT_FUNC, type_name.ToCString()); | 2565 CURRENT_FUNC, type_name.ToCString()); |
| 2540 } | 2566 } |
| 2541 | 2567 |
| 2542 | 2568 |
| 2569 DART_EXPORT bool Dart_ClassIsTypedef(Dart_Handle clazz) { | |
| 2570 Isolate* isolate = Isolate::Current(); | |
| 2571 DARTSCOPE(isolate); | |
| 2572 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 2573 if (cls.IsNull()) { | |
| 2574 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 2575 } | |
| 2576 // For now, the only typedefs are non-canonical signature classes. | |
|
cshapiro
2012/09/12 18:52:07
For now all typedefs are non-canonical signature c
turnidge
2012/09/12 21:39:30
Done.
| |
| 2577 return cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass(); | |
| 2578 } | |
| 2579 | |
| 2580 | |
| 2581 DART_EXPORT Dart_Handle Dart_ClassGetTypedefReferent(Dart_Handle clazz) { | |
| 2582 Isolate* isolate = Isolate::Current(); | |
| 2583 DARTSCOPE(isolate); | |
| 2584 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 2585 if (cls.IsNull()) { | |
| 2586 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 2587 } | |
| 2588 | |
| 2589 if (!cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass()) { | |
| 2590 const String& cls_name = String::Handle(cls.UserVisibleName()); | |
| 2591 return Api::NewError("%s: class '%s' is not a typedef class. " | |
| 2592 "See Dart_ClassIsTypedef.", | |
| 2593 CURRENT_FUNC, cls_name.ToCString()); | |
| 2594 } | |
| 2595 | |
| 2596 const Function& func = Function::Handle(isolate, cls.signature_function()); | |
| 2597 return Api::NewHandle(isolate, func.signature_class()); | |
| 2598 } | |
| 2599 | |
| 2600 | |
| 2601 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle clazz) { | |
| 2602 Isolate* isolate = Isolate::Current(); | |
| 2603 DARTSCOPE(isolate); | |
| 2604 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 2605 if (cls.IsNull()) { | |
| 2606 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 2607 } | |
| 2608 // A class represents a function type when it is a canonical | |
| 2609 // signature class. | |
| 2610 return cls.IsCanonicalSignatureClass(); | |
| 2611 } | |
| 2612 | |
| 2613 | |
| 2614 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle clazz) { | |
| 2615 Isolate* isolate = Isolate::Current(); | |
| 2616 DARTSCOPE(isolate); | |
| 2617 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 2618 if (cls.IsNull()) { | |
| 2619 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 2620 } | |
| 2621 if (!cls.IsCanonicalSignatureClass()) { | |
| 2622 const String& cls_name = String::Handle(cls.UserVisibleName()); | |
| 2623 return Api::NewError("%s: class '%s' is not a function-type class. " | |
| 2624 "See Dart_ClassIsFunctionType.", | |
| 2625 CURRENT_FUNC, cls_name.ToCString()); | |
| 2626 } | |
| 2627 return Api::NewHandle(isolate, cls.signature_function()); | |
| 2628 } | |
| 2629 | |
| 2630 | |
| 2543 // --- Function and Variable Reflection --- | 2631 // --- Function and Variable Reflection --- |
| 2544 | 2632 |
| 2545 | 2633 |
| 2546 // Outside of the vm, we expose setter names with a trailing '='. | 2634 // Outside of the vm, we expose setter names with a trailing '='. |
| 2547 static bool HasExternalSetterSuffix(const String& name) { | 2635 static bool HasExternalSetterSuffix(const String& name) { |
| 2548 return name.CharAt(name.Length() - 1) == '='; | 2636 return name.CharAt(name.Length() - 1) == '='; |
| 2549 } | 2637 } |
| 2550 | 2638 |
| 2551 | 2639 |
| 2552 static RawString* RemoveExternalSetterSuffix(const String& name) { | 2640 static RawString* RemoveExternalSetterSuffix(const String& name) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2810 } | 2898 } |
| 2811 const Function& func = Api::UnwrapFunctionHandle(isolate, function); | 2899 const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
| 2812 if (func.IsNull()) { | 2900 if (func.IsNull()) { |
| 2813 RETURN_TYPE_ERROR(isolate, function, Function); | 2901 RETURN_TYPE_ERROR(isolate, function, Function); |
| 2814 } | 2902 } |
| 2815 *is_setter = (func.kind() == RawFunction::kSetterFunction); | 2903 *is_setter = (func.kind() == RawFunction::kSetterFunction); |
| 2816 return Api::Success(isolate); | 2904 return Api::Success(isolate); |
| 2817 } | 2905 } |
| 2818 | 2906 |
| 2819 | 2907 |
| 2908 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function) { | |
| 2909 Isolate* isolate = Isolate::Current(); | |
| 2910 DARTSCOPE(isolate); | |
| 2911 const Function& func = Api::UnwrapFunctionHandle(isolate, function); | |
| 2912 if (func.IsNull()) { | |
| 2913 RETURN_TYPE_ERROR(isolate, function, Function); | |
| 2914 } | |
| 2915 | |
| 2916 const AbstractType& return_type = | |
| 2917 AbstractType::Handle(isolate, func.result_type()); | |
| 2918 return TypeToHandle(isolate, "Dart_FunctionReturnType", return_type); | |
| 2919 } | |
| 2920 | |
| 2921 | |
| 2820 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( | 2922 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( |
| 2821 Dart_Handle function, | 2923 Dart_Handle function, |
| 2822 int64_t* fixed_param_count, | 2924 int64_t* fixed_param_count, |
| 2823 int64_t* opt_param_count) { | 2925 int64_t* opt_param_count) { |
| 2824 Isolate* isolate = Isolate::Current(); | 2926 Isolate* isolate = Isolate::Current(); |
| 2825 DARTSCOPE(isolate); | 2927 DARTSCOPE(isolate); |
| 2826 if (fixed_param_count == NULL) { | 2928 if (fixed_param_count == NULL) { |
| 2827 RETURN_NULL_ERROR(fixed_param_count); | 2929 RETURN_NULL_ERROR(fixed_param_count); |
| 2828 } | 2930 } |
| 2829 if (opt_param_count == NULL) { | 2931 if (opt_param_count == NULL) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2841 func.NumberOfImplicitParameters()); | 2943 func.NumberOfImplicitParameters()); |
| 2842 *opt_param_count = func.num_optional_parameters(); | 2944 *opt_param_count = func.num_optional_parameters(); |
| 2843 | 2945 |
| 2844 ASSERT(*fixed_param_count >= 0); | 2946 ASSERT(*fixed_param_count >= 0); |
| 2845 ASSERT(*opt_param_count >= 0); | 2947 ASSERT(*opt_param_count >= 0); |
| 2846 | 2948 |
| 2847 return Api::Success(isolate); | 2949 return Api::Success(isolate); |
| 2848 } | 2950 } |
| 2849 | 2951 |
| 2850 | 2952 |
| 2953 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function, | |
| 2954 int parameter_index) { | |
| 2955 Isolate* isolate = Isolate::Current(); | |
| 2956 DARTSCOPE(isolate); | |
| 2957 const Function& func = Api::UnwrapFunctionHandle(isolate, function); | |
| 2958 if (func.IsNull()) { | |
| 2959 RETURN_TYPE_ERROR(isolate, function, Function); | |
| 2960 } | |
| 2961 | |
| 2962 const intptr_t num_implicit_params = func.NumberOfImplicitParameters(); | |
| 2963 const intptr_t num_params = func.NumberOfParameters() - num_implicit_params; | |
| 2964 if (parameter_index < 0 || parameter_index >= num_params) { | |
| 2965 return Api::NewError( | |
| 2966 "%s: argument 'parameter_index' out of range. " | |
| 2967 "Expected 0..%d but saw %d.", | |
| 2968 CURRENT_FUNC, num_params, parameter_index); | |
| 2969 } | |
| 2970 const AbstractType& param_type = | |
| 2971 AbstractType::Handle(isolate, func.ParameterTypeAt( | |
| 2972 num_implicit_params + parameter_index)); | |
| 2973 return TypeToHandle(isolate, "Dart_FunctionParameterType", param_type); | |
| 2974 } | |
| 2975 | |
| 2976 | |
| 2851 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target) { | 2977 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target) { |
| 2852 Isolate* isolate = Isolate::Current(); | 2978 Isolate* isolate = Isolate::Current(); |
| 2853 DARTSCOPE(isolate); | 2979 DARTSCOPE(isolate); |
| 2854 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); | 2980 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); |
| 2855 if (obj.IsError()) { | 2981 if (obj.IsError()) { |
| 2856 return target; | 2982 return target; |
| 2857 } | 2983 } |
| 2858 | 2984 |
| 2859 const GrowableObjectArray& names = | 2985 const GrowableObjectArray& names = |
| 2860 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); | 2986 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2964 RETURN_NULL_ERROR(is_final); | 3090 RETURN_NULL_ERROR(is_final); |
| 2965 } | 3091 } |
| 2966 const Field& var = Api::UnwrapFieldHandle(isolate, variable); | 3092 const Field& var = Api::UnwrapFieldHandle(isolate, variable); |
| 2967 if (var.IsNull()) { | 3093 if (var.IsNull()) { |
| 2968 RETURN_TYPE_ERROR(isolate, variable, Field); | 3094 RETURN_TYPE_ERROR(isolate, variable, Field); |
| 2969 } | 3095 } |
| 2970 *is_final = var.is_final(); | 3096 *is_final = var.is_final(); |
| 2971 return Api::Success(isolate); | 3097 return Api::Success(isolate); |
| 2972 } | 3098 } |
| 2973 | 3099 |
| 3100 | |
| 3101 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle variable) { | |
| 3102 Isolate* isolate = Isolate::Current(); | |
| 3103 DARTSCOPE(isolate); | |
| 3104 const Field& var = Api::UnwrapFieldHandle(isolate, variable); | |
| 3105 if (var.IsNull()) { | |
| 3106 RETURN_TYPE_ERROR(isolate, variable, Field); | |
| 3107 } | |
| 3108 | |
| 3109 const AbstractType& type = AbstractType::Handle(isolate, var.type()); | |
| 3110 return TypeToHandle(isolate, "Dart_VariableType", type); | |
| 3111 } | |
| 3112 | |
| 3113 | |
| 3114 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz) { | |
| 3115 Isolate* isolate = Isolate::Current(); | |
| 3116 DARTSCOPE(isolate); | |
| 3117 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 3118 if (cls.IsNull()) { | |
| 3119 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 3120 } | |
| 3121 | |
| 3122 const intptr_t num_type_params = cls.NumTypeParameters(); | |
| 3123 const TypeArguments& type_params = | |
| 3124 TypeArguments::Handle(cls.type_parameters()); | |
| 3125 | |
| 3126 const GrowableObjectArray& names = | |
| 3127 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); | |
| 3128 TypeParameter& type_param = TypeParameter::Handle(isolate); | |
| 3129 String& name = String::Handle(isolate); | |
| 3130 for (intptr_t i = 0; i < num_type_params; i++) { | |
| 3131 type_param ^= type_params.TypeAt(i); | |
| 3132 name = type_param.name(); | |
| 3133 names.Add(name); | |
| 3134 } | |
| 3135 return Api::NewHandle(isolate, Array::MakeArray(names)); | |
| 3136 } | |
| 3137 | |
| 3138 | |
| 3139 DART_EXPORT Dart_Handle Dart_LookupTypeVariable( | |
| 3140 Dart_Handle clazz, | |
| 3141 Dart_Handle type_variable_name) { | |
| 3142 Isolate* isolate = Isolate::Current(); | |
| 3143 DARTSCOPE(isolate); | |
| 3144 const Class& cls = Api::UnwrapClassHandle(isolate, clazz); | |
| 3145 if (cls.IsNull()) { | |
| 3146 RETURN_TYPE_ERROR(isolate, clazz, Class); | |
| 3147 } | |
| 3148 const String& var_name = Api::UnwrapStringHandle(isolate, type_variable_name); | |
| 3149 if (var_name.IsNull()) { | |
| 3150 RETURN_TYPE_ERROR(isolate, type_variable_name, String); | |
| 3151 } | |
| 3152 | |
| 3153 const intptr_t num_type_params = cls.NumTypeParameters(); | |
| 3154 const TypeArguments& type_params = | |
| 3155 TypeArguments::Handle(cls.type_parameters()); | |
| 3156 | |
| 3157 TypeParameter& type_param = TypeParameter::Handle(isolate); | |
| 3158 String& name = String::Handle(isolate); | |
| 3159 for (intptr_t i = 0; i < num_type_params; i++) { | |
| 3160 type_param ^= type_params.TypeAt(i); | |
| 3161 name = type_param.name(); | |
| 3162 if (name.Equals(var_name)) { | |
| 3163 return Api::NewHandle(isolate, type_param.raw()); | |
| 3164 } | |
| 3165 } | |
| 3166 const String& cls_name = String::Handle(cls.UserVisibleName()); | |
| 3167 return Api::NewError( | |
| 3168 "%s: Could not find type variable named '%s' for class %s.\n", | |
| 3169 var_name.ToCString(), cls_name.ToCString()); | |
| 3170 } | |
| 3171 | |
| 3172 | |
| 3173 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle) { | |
| 3174 return Api::ClassId(handle) == kTypeParameterCid; | |
| 3175 } | |
| 3176 | |
| 3177 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable) { | |
| 3178 Isolate* isolate = Isolate::Current(); | |
| 3179 DARTSCOPE(isolate); | |
| 3180 const TypeParameter& type_var = | |
| 3181 Api::UnwrapTypeParameterHandle(isolate, type_variable); | |
| 3182 if (type_var.IsNull()) { | |
| 3183 RETURN_TYPE_ERROR(isolate, type_variable, TypeParameter); | |
| 3184 } | |
| 3185 return Api::NewHandle(isolate, type_var.name()); | |
| 3186 } | |
| 3187 | |
| 3188 | |
| 3189 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable) { | |
| 3190 Isolate* isolate = Isolate::Current(); | |
| 3191 DARTSCOPE(isolate); | |
| 3192 const TypeParameter& type_var = | |
| 3193 Api::UnwrapTypeParameterHandle(isolate, type_variable); | |
| 3194 if (type_var.IsNull()) { | |
| 3195 RETURN_TYPE_ERROR(isolate, type_variable, TypeParameter); | |
| 3196 } | |
| 3197 const Class& owner = Class::Handle(type_var.parameterized_class()); | |
| 3198 ASSERT(!owner.IsNull() && owner.IsClass()); | |
| 3199 return Api::NewHandle(isolate, owner.raw()); | |
| 3200 } | |
| 3201 | |
| 3202 | |
| 3203 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable) { | |
| 3204 Isolate* isolate = Isolate::Current(); | |
| 3205 DARTSCOPE(isolate); | |
| 3206 const TypeParameter& type_var = | |
| 3207 Api::UnwrapTypeParameterHandle(isolate, type_variable); | |
| 3208 if (type_var.IsNull()) { | |
| 3209 RETURN_TYPE_ERROR(isolate, type_variable, TypeParameter); | |
| 3210 } | |
| 3211 const AbstractType& bound = AbstractType::Handle(type_var.bound()); | |
| 3212 return TypeToHandle(isolate, "Dart_TypeVariableUpperBound", bound); | |
| 3213 } | |
| 3214 | |
| 3215 | |
| 2974 // --- Constructors, Methods, and Fields --- | 3216 // --- Constructors, Methods, and Fields --- |
| 2975 | 3217 |
| 2976 | 3218 |
| 2977 static RawObject* ResolveConstructor(const char* current_func, | 3219 static RawObject* ResolveConstructor(const char* current_func, |
| 2978 const Class& cls, | 3220 const Class& cls, |
| 2979 const String& class_name, | 3221 const String& class_name, |
| 2980 const String& dotted_name, | 3222 const String& dotted_name, |
| 2981 int num_args) { | 3223 int num_args) { |
| 2982 // The constructor must be present in the interface. | 3224 // The constructor must be present in the interface. |
| 2983 String& constr_name = String::Handle(String::Concat(class_name, dotted_name)); | 3225 String& constr_name = String::Handle(String::Concat(class_name, dotted_name)); |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3969 RETURN_TYPE_ERROR(isolate, library, Library); | 4211 RETURN_TYPE_ERROR(isolate, library, Library); |
| 3970 } | 4212 } |
| 3971 | 4213 |
| 3972 const GrowableObjectArray& names = | 4214 const GrowableObjectArray& names = |
| 3973 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); | 4215 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
| 3974 ClassDictionaryIterator it(lib); | 4216 ClassDictionaryIterator it(lib); |
| 3975 Class& cls = Class::Handle(); | 4217 Class& cls = Class::Handle(); |
| 3976 String& name = String::Handle(); | 4218 String& name = String::Handle(); |
| 3977 while (it.HasNext()) { | 4219 while (it.HasNext()) { |
| 3978 cls = it.GetNextClass(); | 4220 cls = it.GetNextClass(); |
| 3979 // For now we suppress the signature classes of closures. | 4221 if (cls.IsSignatureClass()) { |
| 3980 // | 4222 if (!cls.IsCanonicalSignatureClass()) { |
| 3981 // TODO(turnidge): Add this to the unit test. | 4223 // This is a typedef. Add it to the list of class names. |
| 3982 const Function& signature_func = Function::Handle(cls.signature_function()); | 4224 name = cls.UserVisibleName(); |
| 3983 if (signature_func.IsNull()) { | 4225 names.Add(name); |
| 4226 } else { | |
| 4227 // Skip canonical signature classes. These are not named. | |
| 4228 } | |
| 4229 } else { | |
| 3984 name = cls.UserVisibleName(); | 4230 name = cls.UserVisibleName(); |
| 3985 names.Add(name); | 4231 names.Add(name); |
| 3986 } | 4232 } |
| 3987 } | 4233 } |
| 3988 return Api::NewHandle(isolate, Array::MakeArray(names)); | 4234 return Api::NewHandle(isolate, Array::MakeArray(names)); |
| 3989 } | 4235 } |
| 3990 | 4236 |
| 3991 | 4237 |
| 3992 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { | 4238 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| 3993 Isolate* isolate = Isolate::Current(); | 4239 Isolate* isolate = Isolate::Current(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4174 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { | 4420 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { |
| 4175 Dart::set_perf_events_writer(function); | 4421 Dart::set_perf_events_writer(function); |
| 4176 } | 4422 } |
| 4177 | 4423 |
| 4178 | 4424 |
| 4179 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { | 4425 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { |
| 4180 Dart::set_flow_graph_writer(function); | 4426 Dart::set_flow_graph_writer(function); |
| 4181 } | 4427 } |
| 4182 | 4428 |
| 4183 } // namespace dart | 4429 } // namespace dart |
| OLD | NEW |