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

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

Issue 23133003: Fix ClassMirror.typeArguments handling for dynamic only type arguments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | tests/lib/mirrors/generics_test.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 "lib/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 DEFINE_NATIVE_ENTRY(ClassMirror_type_variables, 1) { 585 DEFINE_NATIVE_ENTRY(ClassMirror_type_variables, 1) {
586 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 586 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
587 const Class& klass = Class::Handle(ref.GetClassReferent()); 587 const Class& klass = Class::Handle(ref.GetClassReferent());
588 return CreateTypeVariableList(klass); 588 return CreateTypeVariableList(klass);
589 } 589 }
590 590
591 591
592 DEFINE_NATIVE_ENTRY(ClassMirror_type_arguments, 1) { 592 DEFINE_NATIVE_ENTRY(ClassMirror_type_arguments, 1) {
593 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 593 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
594 594
595 const AbstractTypeArguments& args = 595 const Class& cls = Class::Handle(type.type_class());
596 AbstractTypeArguments::Handle(type.arguments()); 596 const intptr_t num_params = cls.NumTypeParameters();
597 if (args.IsNull()) { 597
598 if (num_params == 0) {
598 return Object::empty_array().raw(); 599 return Object::empty_array().raw();
599 } 600 }
600 601
601 const Class& cls = Class::Handle(type.type_class());
602 const intptr_t num_params = cls.NumTypeParameters();
603 const intptr_t num_inherited_args = args.Length() - num_params;
604
605 const Array& result = Array::Handle(Array::New(num_params)); 602 const Array& result = Array::Handle(Array::New(num_params));
606 AbstractType& arg_type = AbstractType::Handle(); 603 AbstractType& arg_type = AbstractType::Handle();
607 Instance& type_mirror = Instance::Handle(); 604 Instance& type_mirror = Instance::Handle();
605 const AbstractTypeArguments& args =
606 AbstractTypeArguments::Handle(type.arguments());
607
608 // Handle argument lists that have been optimized away, because either no
609 // arguments have been provided, or all arguments are dynamic. Return a list
610 // of typemirrors on dynamic in this case.
611 if (args.IsNull()) {
612 arg_type ^= Object::dynamic_type();
613 type_mirror ^= CreateTypeMirror(arg_type);
614 for (intptr_t i = 0; i < num_params; i++) {
615 result.SetAt(i, type_mirror);
616 }
617 return result.raw();
618 }
619
620 ASSERT(args.Length() >= num_params);
621 const intptr_t num_inherited_args = args.Length() - num_params;
608 for (intptr_t i = 0; i < num_params; i++) { 622 for (intptr_t i = 0; i < num_params; i++) {
609 arg_type ^= args.TypeAt(i + num_inherited_args); 623 arg_type ^= args.TypeAt(i + num_inherited_args);
610 type_mirror = CreateTypeMirror(arg_type); 624 type_mirror = CreateTypeMirror(arg_type);
611 result.SetAt(i, type_mirror); 625 result.SetAt(i, type_mirror);
612 } 626 }
613 return result.raw(); 627 return result.raw();
614 } 628 }
615 629
616 630
617 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { 631 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1290 }
1277 1291
1278 1292
1279 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1293 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1280 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1294 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1281 const Field& field = Field::Handle(ref.GetFieldReferent()); 1295 const Field& field = Field::Handle(ref.GetFieldReferent());
1282 return field.type(); 1296 return field.type();
1283 } 1297 }
1284 1298
1285 } // namespace dart 1299 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/mirrors/generics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698