| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 // However, subtyping constraints are checked below, even for a raw type. | 629 // However, subtyping constraints are checked below, even for a raw type. |
| 630 if (!arguments.IsNull() && (arguments.Length() != num_type_parameters)) { | 630 if (!arguments.IsNull() && (arguments.Length() != num_type_parameters)) { |
| 631 // TODO(regis): We need to store the token_index in each type. | 631 // TODO(regis): We need to store the token_index in each type. |
| 632 ReportError("wrong number of type arguments in type '%s'\n", | 632 ReportError("wrong number of type arguments in type '%s'\n", |
| 633 String::Handle(type.Name()).ToCString()); | 633 String::Handle(type.Name()).ToCString()); |
| 634 } | 634 } |
| 635 // The full type argument vector consists of the type arguments of the | 635 // The full type argument vector consists of the type arguments of the |
| 636 // super types of type_class, which may be initialized from the parsed | 636 // super types of type_class, which may be initialized from the parsed |
| 637 // type arguments, followed by the parsed type arguments. | 637 // type arguments, followed by the parsed type arguments. |
| 638 if (num_type_arguments > 0) { | 638 if (num_type_arguments > 0) { |
| 639 const TypeArguments& full_arguments = TypeArguments::Handle( | 639 TypeArguments& full_arguments = TypeArguments::Handle( |
| 640 TypeArguments::New(num_type_arguments)); | 640 TypeArguments::New(num_type_arguments)); |
| 641 // Copy the parsed type arguments at the correct offset in the full type | 641 // Copy the parsed type arguments at the correct offset in the full type |
| 642 // argument vector. | 642 // argument vector. |
| 643 const intptr_t offset = num_type_arguments - num_type_parameters; | 643 const intptr_t offset = num_type_arguments - num_type_parameters; |
| 644 AbstractType& type = AbstractType::Handle(Type::DynamicType()); | 644 AbstractType& type = AbstractType::Handle(Type::DynamicType()); |
| 645 for (intptr_t i = 0; i < num_type_parameters; i++) { | 645 for (intptr_t i = 0; i < num_type_parameters; i++) { |
| 646 // If no type parameters were provided, a raw type is desired, so we | 646 // If no type parameters were provided, a raw type is desired, so we |
| 647 // create a vector of DynamicType. | 647 // create a vector of DynamicType. |
| 648 if (!arguments.IsNull()) { | 648 if (!arguments.IsNull()) { |
| 649 type = arguments.TypeAt(i); | 649 type = arguments.TypeAt(i); |
| 650 } | 650 } |
| 651 full_arguments.SetTypeAt(offset + i, type); | 651 full_arguments.SetTypeAt(offset + i, type); |
| 652 } | 652 } |
| 653 if (type_class.IsSignatureClass()) { | 653 if (type_class.IsSignatureClass()) { |
| 654 const Function& signature_fun = | 654 const Function& signature_fun = |
| 655 Function::Handle(type_class.signature_function()); | 655 Function::Handle(type_class.signature_function()); |
| 656 ASSERT(!signature_fun.is_static()); | 656 ASSERT(!signature_fun.is_static()); |
| 657 const Class& signature_fun_owner = Class::Handle(signature_fun.owner()); | 657 const Class& signature_fun_owner = Class::Handle(signature_fun.owner()); |
| 658 FinalizeTypeArguments(signature_fun_owner, full_arguments); | 658 FinalizeTypeArguments(signature_fun_owner, full_arguments); |
| 659 } else { | 659 } else { |
| 660 FinalizeTypeArguments(type_class, full_arguments); | 660 FinalizeTypeArguments(type_class, full_arguments); |
| 661 } | 661 } |
| 662 // FinalizeTypeArguments can modify 'full_arguments', |
| 663 // canonicalize afterwards. |
| 664 full_arguments ^= full_arguments.Canonicalize(); |
| 662 parameterized_type.set_arguments(full_arguments); | 665 parameterized_type.set_arguments(full_arguments); |
| 663 | 666 |
| 664 // Mark the type as finalized before finalizing the upper bounds, because | 667 // Mark the type as finalized before finalizing the upper bounds, because |
| 665 // cycles via upper bounds are legal at compile time. | 668 // cycles via upper bounds are legal at compile time. |
| 666 parameterized_type.set_is_finalized(); | 669 parameterized_type.set_is_finalized(); |
| 667 | 670 |
| 668 ResolveAndFinalizeUpperBounds(type_class); | 671 ResolveAndFinalizeUpperBounds(type_class); |
| 669 if (FLAG_enable_type_checks) { | 672 if (FLAG_enable_type_checks) { |
| 670 VerifyUpperBounds(type_class, full_arguments); | 673 VerifyUpperBounds(type_class, full_arguments); |
| 671 } | 674 } |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 va_end(args); | 1294 va_end(args); |
| 1292 if (FLAG_warning_as_error) { | 1295 if (FLAG_warning_as_error) { |
| 1293 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); | 1296 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); |
| 1294 UNREACHABLE(); | 1297 UNREACHABLE(); |
| 1295 } else { | 1298 } else { |
| 1296 OS::Print(message_buffer); | 1299 OS::Print(message_buffer); |
| 1297 } | 1300 } |
| 1298 } | 1301 } |
| 1299 | 1302 |
| 1300 } // namespace dart | 1303 } // namespace dart |
| OLD | NEW |