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 564 matching lines...) Loading... |
575 // TODO(regis): As long as we support metadata in typedef signatures, | 575 // TODO(regis): As long as we support metadata in typedef signatures, |
576 // we cannot reset these fields used to reparse a typedef. | 576 // we cannot reset these fields used to reparse a typedef. |
577 // Note that the scope class of a typedef function type is always | 577 // Note that the scope class of a typedef function type is always |
578 // preserved as the typedef class (not reset to _Closure class), thereby | 578 // preserved as the typedef class (not reset to _Closure class), thereby |
579 // preventing sharing of canonical function types between typedefs. | 579 // preventing sharing of canonical function types between typedefs. |
580 // Not being shared, these fields are therefore always meaningful for | 580 // Not being shared, these fields are therefore always meaningful for |
581 // typedefs. | 581 // typedefs. |
582 if (!scope_class.IsTypedefClass()) { | 582 if (!scope_class.IsTypedefClass()) { |
583 signature.set_owner(Object::Handle()); | 583 signature.set_owner(Object::Handle()); |
584 signature.set_token_pos(TokenPosition::kNoSource); | 584 signature.set_token_pos(TokenPosition::kNoSource); |
| 585 if ((type.arguments() != TypeArguments::null()) && |
| 586 signature.HasInstantiatedSignature()) { |
| 587 ASSERT(scope_class.IsGeneric()); |
| 588 // Although the scope class of this function type is generic, |
| 589 // the signature of this function type does not refer to any |
| 590 // of its type parameters. Reset its scope class to _Closure. |
| 591 Type::Cast(type).set_type_class(Class::Handle( |
| 592 Isolate::Current()->object_store()->closure_class())); |
| 593 type.set_arguments(Object::null_type_arguments()); |
| 594 } |
585 } | 595 } |
586 } | 596 } |
587 } | 597 } |
588 } | 598 } |
589 } | 599 } |
590 | 600 |
591 | 601 |
592 void ClassFinalizer::FinalizeTypeParameters(const Class& cls, | 602 void ClassFinalizer::FinalizeTypeParameters(const Class& cls, |
593 PendingTypes* pending_types) { | 603 PendingTypes* pending_types) { |
594 if (FLAG_trace_type_finalization) { | 604 if (FLAG_trace_type_finalization) { |
(...skipping 104 matching lines...) Loading... |
699 ResolveUpperBounds(type_class); | 709 ResolveUpperBounds(type_class); |
700 } | 710 } |
701 | 711 |
702 // The finalized type argument vector needs num_type_arguments types. | 712 // The finalized type argument vector needs num_type_arguments types. |
703 const intptr_t num_type_arguments = type_class.NumTypeArguments(); | 713 const intptr_t num_type_arguments = type_class.NumTypeArguments(); |
704 // The class has num_type_parameters type parameters. | 714 // The class has num_type_parameters type parameters. |
705 const intptr_t num_type_parameters = type_class.NumTypeParameters(); | 715 const intptr_t num_type_parameters = type_class.NumTypeParameters(); |
706 | 716 |
707 // If we are not reifying types, drop type arguments. | 717 // If we are not reifying types, drop type arguments. |
708 if (!FLAG_reify) { | 718 if (!FLAG_reify) { |
709 type.set_arguments(TypeArguments::Handle(zone, TypeArguments::null())); | 719 type.set_arguments(Object::null_type_arguments()); |
710 } | 720 } |
711 | 721 |
712 // Initialize the type argument vector. | 722 // Initialize the type argument vector. |
713 // Check the number of parsed type arguments, if any. | 723 // Check the number of parsed type arguments, if any. |
714 // Specifying no type arguments indicates a raw type, which is not an error. | 724 // Specifying no type arguments indicates a raw type, which is not an error. |
715 // However, type parameter bounds are checked below, even for a raw type. | 725 // However, type parameter bounds are checked below, even for a raw type. |
716 TypeArguments& arguments = TypeArguments::Handle(zone, type.arguments()); | 726 TypeArguments& arguments = TypeArguments::Handle(zone, type.arguments()); |
717 if (!arguments.IsNull() && (arguments.Length() != num_type_parameters)) { | 727 if (!arguments.IsNull() && (arguments.Length() != num_type_parameters)) { |
718 // Wrong number of type arguments. The type is mapped to the raw type. | 728 // Wrong number of type arguments. The type is mapped to the raw type. |
719 if (Isolate::Current()->error_on_bad_type()) { | 729 if (Isolate::Current()->error_on_bad_type()) { |
(...skipping 2678 matching lines...) Loading... |
3398 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3408 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3399 field ^= fields_array.At(0); | 3409 field ^= fields_array.At(0); |
3400 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3410 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3401 name ^= field.name(); | 3411 name ^= field.name(); |
3402 expected_name ^= String::New("_data"); | 3412 expected_name ^= String::New("_data"); |
3403 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3413 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3404 #endif | 3414 #endif |
3405 } | 3415 } |
3406 | 3416 |
3407 } // namespace dart | 3417 } // namespace dart |
OLD | NEW |