| 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 "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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |