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 #include "include/dart_debugger_api.h" | 6 #include "include/dart_debugger_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. | 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. |
| 10 #include "vm/bootstrap_natives.h" | 10 #include "vm/bootstrap_natives.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 // reflection. | 504 // reflection. |
| 505 return CreateTypedefMirror(intf, intf_name, lib_mirror); | 505 return CreateTypedefMirror(intf, intf_name, lib_mirror); |
| 506 } | 506 } |
| 507 | 507 |
| 508 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); | 508 Dart_Handle cls_name = NewString("_LocalClassMirrorImpl"); |
| 509 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); | 509 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 510 if (Dart_IsError(type)) { | 510 if (Dart_IsError(type)) { |
| 511 return type; | 511 return type; |
| 512 } | 512 } |
| 513 | 513 |
| 514 // TODO(turnidge): Why am I getting Null when I expect Object? | 514 Dart_Handle super_class = Dart_Null(); |
| 515 // TODO(gbracha): this is probably the root of bug 7868 | |
| 516 Dart_Handle super_class = Dart_GetSuperclass(intf); | |
| 517 if (Dart_IsNull(super_class)) { | |
| 518 super_class = Dart_GetClass(CoreLib(), NewString("Object")); | |
| 519 } | |
| 520 // TODO(turnidge): Simplify code, now that default classes have been removed. | 515 // TODO(turnidge): Simplify code, now that default classes have been removed. |
| 521 Dart_Handle default_class = Dart_Null(); | 516 Dart_Handle default_class = Dart_Null(); |
| 522 | 517 |
| 523 Dart_Handle intf_mirror = CreateLazyMirror(intf); | 518 Dart_Handle intf_mirror = CreateLazyMirror(intf); |
| 524 if (Dart_IsError(intf_mirror)) { | 519 if (Dart_IsError(intf_mirror)) { |
| 525 return intf_mirror; | 520 return intf_mirror; |
| 526 } | 521 } |
| 527 Dart_Handle constructor_map = CreateConstructorMap(intf, intf_mirror); | 522 Dart_Handle constructor_map = CreateConstructorMap(intf, intf_mirror); |
| 528 if (Dart_IsError(constructor_map)) { | 523 if (Dart_IsError(constructor_map)) { |
| 529 return constructor_map; | 524 return constructor_map; |
| 530 } | 525 } |
| 531 Dart_Handle type_var_map = CreateTypeVariableMap(intf, intf_mirror); | 526 Dart_Handle type_var_map = CreateTypeVariableMap(intf, intf_mirror); |
| 532 if (Dart_IsError(type_var_map)) { | 527 if (Dart_IsError(type_var_map)) { |
| 533 return type_var_map; | 528 return type_var_map; |
| 534 } | 529 } |
| 535 | 530 |
| 536 Dart_Handle args[] = { | 531 Dart_Handle args[] = { |
| 537 CreateMirrorReference(intf), | 532 CreateMirrorReference(intf), |
| 538 Dart_Null(), // "name" | 533 Dart_Null(), // "name" |
| 539 Dart_NewBoolean(Dart_IsClass(intf)), | 534 Dart_NewBoolean(Dart_IsClass(intf)), |
| 540 lib_mirror, | 535 lib_mirror, |
| 541 CreateLazyMirror(super_class), | 536 super_class, |
| 542 CreateImplementsList(intf), | 537 CreateImplementsList(intf), |
| 543 CreateLazyMirror(default_class), | 538 CreateLazyMirror(default_class), |
| 544 constructor_map, | 539 constructor_map, |
| 545 type_var_map, | 540 type_var_map, |
| 546 }; | 541 }; |
| 547 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 542 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 548 return mirror; | 543 return mirror; |
| 549 } | 544 } |
| 550 | 545 |
| 551 | 546 |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 } | 1045 } |
| 1051 | 1046 |
| 1052 | 1047 |
| 1053 DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) { | 1048 DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) { |
| 1054 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1049 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1055 const Class& klass = Class::Handle(ref.GetClassReferent()); | 1050 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 1056 return CreateLibraryMirror(Library::Handle(klass.library())); | 1051 return CreateLibraryMirror(Library::Handle(klass.library())); |
| 1057 } | 1052 } |
| 1058 | 1053 |
| 1059 | 1054 |
| 1055 DEFINE_NATIVE_ENTRY(ClassMirror_supertype, 1) { | |
|
rmacnak
2013/07/25 20:51:51
We answer a Type instead of a ClassMirror for two
| |
| 1056 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | |
| 1057 const Class& klass = Class::Handle(ref.GetClassReferent()); | |
| 1058 return klass.super_type(); | |
| 1059 } | |
| 1060 | |
| 1060 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { | 1061 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { |
| 1061 GET_NON_NULL_NATIVE_ARGUMENT(Instance, | 1062 GET_NON_NULL_NATIVE_ARGUMENT(Instance, |
| 1062 owner_mirror, | 1063 owner_mirror, |
| 1063 arguments->NativeArgAt(0)); | 1064 arguments->NativeArgAt(0)); |
| 1064 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 1065 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
| 1065 const Class& klass = Class::Handle(ref.GetClassReferent()); | 1066 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 1066 | 1067 |
| 1067 const Array& fields = Array::Handle(klass.fields()); | 1068 const Array& fields = Array::Handle(klass.fields()); |
| 1068 // Some special types like 'dynamic' have a null fields list, but they should | 1069 // Some special types like 'dynamic' have a null fields list, but they should |
| 1069 // not wind up as the reflectees of ClassMirrors. | 1070 // not wind up as the reflectees of ClassMirrors. |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1770 | 1771 |
| 1771 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1772 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1772 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1773 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1773 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1774 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1774 | 1775 |
| 1775 const AbstractType& type = AbstractType::Handle(field.type()); | 1776 const AbstractType& type = AbstractType::Handle(field.type()); |
| 1776 return CreateTypeMirror(type); | 1777 return CreateTypeMirror(type); |
| 1777 } | 1778 } |
| 1778 | 1779 |
| 1779 } // namespace dart | 1780 } // namespace dart |
| OLD | NEW |