Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: runtime/lib/mirrors.cc

Issue 20465002: Implement ClassMirror.superclass with internal code for ordinary (but not function type) classes. R… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1025 }
1031 1026
1032 1027
1033 DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) { 1028 DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) {
1034 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1029 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1035 const Class& klass = Class::Handle(ref.GetClassReferent()); 1030 const Class& klass = Class::Handle(ref.GetClassReferent());
1036 return CreateLibraryMirror(Library::Handle(klass.library())); 1031 return CreateLibraryMirror(Library::Handle(klass.library()));
1037 } 1032 }
1038 1033
1039 1034
1035 DEFINE_NATIVE_ENTRY(ClassMirror_supertype, 1) {
1036 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1037 const Class& klass = Class::Handle(ref.GetClassReferent());
1038 return klass.super_type();
1039 }
1040
1040 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { 1041 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) {
1041 GET_NON_NULL_NATIVE_ARGUMENT(Instance, 1042 GET_NON_NULL_NATIVE_ARGUMENT(Instance,
1042 owner_mirror, 1043 owner_mirror,
1043 arguments->NativeArgAt(0)); 1044 arguments->NativeArgAt(0));
1044 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 1045 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
1045 const Class& klass = Class::Handle(ref.GetClassReferent()); 1046 const Class& klass = Class::Handle(ref.GetClassReferent());
1046 1047
1047 const Array& fields = Array::Handle(klass.fields()); 1048 const Array& fields = Array::Handle(klass.fields());
1048 // Some special types like 'dynamic' have a null fields list, but they should 1049 // Some special types like 'dynamic' have a null fields list, but they should
1049 // not wind up as the reflectees of ClassMirrors. 1050 // not wind up as the reflectees of ClassMirrors.
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1758
1758 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1759 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1759 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1760 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1760 const Field& field = Field::Handle(ref.GetFieldReferent()); 1761 const Field& field = Field::Handle(ref.GetFieldReferent());
1761 1762
1762 const AbstractType& type = AbstractType::Handle(field.type()); 1763 const AbstractType& type = AbstractType::Handle(field.type());
1763 return CreateTypeMirror(type); 1764 return CreateTypeMirror(type);
1764 } 1765 }
1765 1766
1766 } // namespace dart 1767 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698