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

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 =
596 AbstractTypeArguments::Handle(type.arguments());
597 if (args.IsNull()) {
598 return Object::empty_array().raw();
599 }
600
601 const Class& cls = Class::Handle(type.type_class()); 595 const Class& cls = Class::Handle(type.type_class());
602 const intptr_t num_params = cls.NumTypeParameters(); 596 const intptr_t num_params = cls.NumTypeParameters();
603 const intptr_t num_inherited_args = args.Length() - num_params; 597
598 if (num_params == 0) return Object::empty_array().raw();
rmacnak 2013/08/14 00:07:41 While I think this looks better, we use braces eve
Michael Lippautz (Google) 2013/08/14 00:14:09 Done.
604 599
605 const Array& result = Array::Handle(Array::New(num_params)); 600 const Array& result = Array::Handle(Array::New(num_params));
606 AbstractType& arg_type = AbstractType::Handle(); 601 AbstractType& arg_type = AbstractType::Handle();
607 Instance& type_mirror = Instance::Handle(); 602 Instance& type_mirror = Instance::Handle();
603 const AbstractTypeArguments& args =
604 AbstractTypeArguments::Handle(type.arguments());
605
606 // Handle argument lists that have been optimized away, because either no
607 // arguments have been provided, or all arguments have been dynamic. Return a
siva 2013/08/14 00:22:09 or all arguments are dynamic
Michael Lippautz (Google) 2013/08/14 16:29:29 Done.
608 // list of typemirrors on dynamic in this case.
609 if (args.IsNull()) {
610 arg_type ^= Object::dynamic_type();
611 type_mirror ^= CreateTypeMirror(arg_type);
612 for (intptr_t i = 0; i < num_params; i++) {
613 result.SetAt(i, type_mirror);
614 }
615 return result.raw();
616 }
617
siva 2013/08/14 00:22:09 ASSERT(args.Length() >= num_params);
Michael Lippautz (Google) 2013/08/14 16:29:29 Done.
618 const intptr_t num_inherited_args = args.Length() - num_params;
608 for (intptr_t i = 0; i < num_params; i++) { 619 for (intptr_t i = 0; i < num_params; i++) {
609 arg_type ^= args.TypeAt(i + num_inherited_args); 620 arg_type ^= args.TypeAt(i + num_inherited_args);
610 type_mirror = CreateTypeMirror(arg_type); 621 type_mirror = CreateTypeMirror(arg_type);
611 result.SetAt(i, type_mirror); 622 result.SetAt(i, type_mirror);
612 } 623 }
613 return result.raw(); 624 return result.raw();
614 } 625 }
615 626
616 627
617 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { 628 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1287 }
1277 1288
1278 1289
1279 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1290 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1280 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1291 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1281 const Field& field = Field::Handle(ref.GetFieldReferent()); 1292 const Field& field = Field::Handle(ref.GetFieldReferent());
1282 return field.type(); 1293 return field.type();
1283 } 1294 }
1284 1295
1285 } // namespace dart 1296 } // 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