OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
6 | 6 |
7 #include "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 type_argument = arguments.TypeAt(i); | 503 type_argument = arguments.TypeAt(i); |
504 ResolveType(cls, type_argument); | 504 ResolveType(cls, type_argument); |
505 } | 505 } |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 | 509 |
510 void ClassFinalizer::FinalizeTypeParameters( | 510 void ClassFinalizer::FinalizeTypeParameters( |
511 const Class& cls, | 511 const Class& cls, |
512 GrowableObjectArray* pending_types) { | 512 GrowableObjectArray* pending_types) { |
| 513 if (FLAG_trace_type_finalization) { |
| 514 OS::Print("Finalizing type parameters of '%s'\n", |
| 515 String::Handle(cls.Name()).ToCString()); |
| 516 } |
513 if (cls.IsMixinApplication()) { | 517 if (cls.IsMixinApplication()) { |
514 // Setup the type parameters of the mixin application and finalize the | 518 // Setup the type parameters of the mixin application and finalize the |
515 // mixin type. | 519 // mixin type. |
516 ApplyMixinType(cls, pending_types); | 520 ApplyMixinType(cls, pending_types); |
517 } | 521 } |
518 // The type parameter bounds are not finalized here. | 522 // The type parameter bounds are not finalized here. |
519 const TypeArguments& type_parameters = | 523 const TypeArguments& type_parameters = |
520 TypeArguments::Handle(cls.type_parameters()); | 524 TypeArguments::Handle(cls.type_parameters()); |
521 if (!type_parameters.IsNull()) { | 525 if (!type_parameters.IsNull()) { |
522 TypeParameter& type_parameter = TypeParameter::Handle(); | 526 TypeParameter& type_parameter = TypeParameter::Handle(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 // each other via their bounds. | 814 // each other via their bounds. |
811 type_arg = BoundedType::New(type_arg, instantiated_bound, type_param); | 815 type_arg = BoundedType::New(type_arg, instantiated_bound, type_param); |
812 arguments.SetTypeAt(offset + i, type_arg); | 816 arguments.SetTypeAt(offset + i, type_arg); |
813 continue; | 817 continue; |
814 } | 818 } |
815 // Shortcut the special case where we check a type parameter against its | 819 // Shortcut the special case where we check a type parameter against its |
816 // declared upper bound. | 820 // declared upper bound. |
817 if (error.IsNull() && | 821 if (error.IsNull() && |
818 !(type_arg.Equals(type_param) && | 822 !(type_arg.Equals(type_param) && |
819 instantiated_bound.Equals(declared_bound))) { | 823 instantiated_bound.Equals(declared_bound))) { |
| 824 // If type_arg is a type parameter, its declared bound may not be |
| 825 // resolved yet. |
| 826 if (type_arg.IsTypeParameter()) { |
| 827 const Class& type_arg_cls = Class::Handle( |
| 828 TypeParameter::Cast(type_arg).parameterized_class()); |
| 829 const AbstractType& bound = AbstractType::Handle( |
| 830 TypeParameter::Cast(type_arg).bound()); |
| 831 ResolveType(type_arg_cls, bound); |
| 832 } |
820 if (!type_param.CheckBound(type_arg, instantiated_bound, &error) && | 833 if (!type_param.CheckBound(type_arg, instantiated_bound, &error) && |
821 error.IsNull()) { | 834 error.IsNull()) { |
822 // The bound cannot be checked at compile time; postpone to run time. | 835 // The bound cannot be checked at compile time; postpone to run time. |
823 type_arg = BoundedType::New(type_arg, instantiated_bound, type_param); | 836 type_arg = BoundedType::New(type_arg, instantiated_bound, type_param); |
824 arguments.SetTypeAt(offset + i, type_arg); | 837 arguments.SetTypeAt(offset + i, type_arg); |
825 } | 838 } |
826 } | 839 } |
827 if (!error.IsNull() && bound_error->IsNull()) { | 840 if (!error.IsNull() && bound_error->IsNull()) { |
828 *bound_error = error.raw(); | 841 *bound_error = error.raw(); |
829 } | 842 } |
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3172 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3160 field ^= fields_array.At(0); | 3173 field ^= fields_array.At(0); |
3161 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3174 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3162 name ^= field.name(); | 3175 name ^= field.name(); |
3163 expected_name ^= String::New("_data"); | 3176 expected_name ^= String::New("_data"); |
3164 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3177 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3165 #endif | 3178 #endif |
3166 } | 3179 } |
3167 | 3180 |
3168 } // namespace dart | 3181 } // namespace dart |
OLD | NEW |