| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 const Function& signature = Function::Handle(Type::Cast(type).signature()); | 558 const Function& signature = Function::Handle(Type::Cast(type).signature()); |
| 559 Type& signature_type = Type::Handle(signature.SignatureType()); | 559 Type& signature_type = Type::Handle(signature.SignatureType()); |
| 560 if (signature_type.raw() != type.raw()) { | 560 if (signature_type.raw() != type.raw()) { |
| 561 ResolveType(cls, signature_type); | 561 ResolveType(cls, signature_type); |
| 562 } else { | 562 } else { |
| 563 const Class& scope_class = Class::Handle(type.type_class()); | 563 const Class& scope_class = Class::Handle(type.type_class()); |
| 564 if (scope_class.IsTypedefClass()) { | 564 if (scope_class.IsTypedefClass()) { |
| 565 ResolveSignature(scope_class, signature); | 565 ResolveSignature(scope_class, signature); |
| 566 } else { | 566 } else { |
| 567 ResolveSignature(cls, signature); | 567 ResolveSignature(cls, signature); |
| 568 if ((type.arguments() != TypeArguments::null()) && |
| 569 signature.HasInstantiatedSignature()) { |
| 570 ASSERT(scope_class.IsGeneric()); |
| 571 // Although the scope class of this function type is generic, |
| 572 // the signature of this function type does not refer to any |
| 573 // of its type parameters. Reset its scope class to _Closure. |
| 574 Type::Cast(type).set_type_class(Class::Handle( |
| 575 Isolate::Current()->object_store()->closure_class())); |
| 576 type.set_arguments(Object::null_type_arguments()); |
| 577 } |
| 568 } | 578 } |
| 569 if (signature.IsSignatureFunction()) { | 579 if (signature.IsSignatureFunction()) { |
| 570 // Drop fields that are not necessary anymore after resolution. | 580 // Drop fields that are not necessary anymore after resolution. |
| 571 // The parent function, owner, and token position of a shared | 581 // The parent function, owner, and token position of a shared |
| 572 // canonical function type are meaningless, since the canonical | 582 // canonical function type are meaningless, since the canonical |
| 573 // representent is picked arbitrarily. | 583 // representent is picked arbitrarily. |
| 574 signature.set_parent_function(Function::Handle()); | 584 signature.set_parent_function(Function::Handle()); |
| 575 // TODO(regis): As long as we support metadata in typedef signatures, | 585 // TODO(regis): As long as we support metadata in typedef signatures, |
| 576 // we cannot reset these fields used to reparse a typedef. | 586 // we cannot reset these fields used to reparse a typedef. |
| 577 // Note that the scope class of a typedef function type is always | 587 // Note that the scope class of a typedef function type is always |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after 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...) Expand 10 before | Expand all | Expand 10 after 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 |