| 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 "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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // Input: C<String, double> expressed as | 504 // Input: C<String, double> expressed as |
| 505 // cls = C, arguments = [null, null, String, double], | 505 // cls = C, arguments = [null, null, String, double], |
| 506 // i.e. cls_args = [String, double], offset = 2, length = 2. | 506 // i.e. cls_args = [String, double], offset = 2, length = 2. |
| 507 // Output: arguments = [int, double, String, double] | 507 // Output: arguments = [int, double, String, double] |
| 508 void ClassFinalizer::FinalizeTypeArguments( | 508 void ClassFinalizer::FinalizeTypeArguments( |
| 509 const Class& cls, | 509 const Class& cls, |
| 510 const AbstractTypeArguments& arguments, | 510 const AbstractTypeArguments& arguments, |
| 511 FinalizationKind finalization) { | 511 FinalizationKind finalization) { |
| 512 ASSERT(arguments.Length() >= cls.NumTypeArguments()); | 512 ASSERT(arguments.Length() >= cls.NumTypeArguments()); |
| 513 if (!cls.is_finalized()) { | 513 if (!cls.is_finalized()) { |
| 514 const GrowableObjectArray& visited = |
| 515 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 516 ResolveInterfaces(cls, visited); |
| 514 FinalizeTypeParameters(cls); | 517 FinalizeTypeParameters(cls); |
| 515 } | 518 } |
| 516 Type& super_type = Type::Handle(cls.super_type()); | 519 Type& super_type = Type::Handle(cls.super_type()); |
| 517 if (!super_type.IsNull()) { | 520 if (!super_type.IsNull()) { |
| 518 super_type ^= FinalizeType(cls, super_type, finalization); | 521 super_type ^= FinalizeType(cls, super_type, finalization); |
| 519 cls.set_super_type(super_type); | 522 cls.set_super_type(super_type); |
| 520 const Class& super_class = Class::Handle(super_type.type_class()); | 523 const Class& super_class = Class::Handle(super_type.type_class()); |
| 521 const AbstractTypeArguments& super_type_args = | 524 const AbstractTypeArguments& super_type_args = |
| 522 AbstractTypeArguments::Handle(super_type.arguments()); | 525 AbstractTypeArguments::Handle(super_type.arguments()); |
| 523 const intptr_t num_super_type_params = super_class.NumTypeParameters(); | 526 const intptr_t num_super_type_params = super_class.NumTypeParameters(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 intptr_t num_arguments = arguments.Length(); | 600 intptr_t num_arguments = arguments.Length(); |
| 598 for (intptr_t i = 0; i < num_arguments; i++) { | 601 for (intptr_t i = 0; i < num_arguments; i++) { |
| 599 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); | 602 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); |
| 600 type_argument = FinalizeType(cls, type_argument, finalization); | 603 type_argument = FinalizeType(cls, type_argument, finalization); |
| 601 arguments.SetTypeAt(i, type_argument); | 604 arguments.SetTypeAt(i, type_argument); |
| 602 } | 605 } |
| 603 } | 606 } |
| 604 | 607 |
| 605 // The type class does not need to be finalized in order to finalize the type, | 608 // The type class does not need to be finalized in order to finalize the type, |
| 606 // however, it must at least be resolved (this was done as part of resolving | 609 // however, it must at least be resolved (this was done as part of resolving |
| 607 // the type itself, a precondition to calling FinalizeType) and the upper | 610 // the type itself, a precondition to calling FinalizeType). |
| 608 // bounds of its type parameters must be finalized (done here). | 611 // Also, the interfaces of the type class must be resolved and the type |
| 612 // parameters of the type class must be finalized. |
| 609 Class& type_class = Class::Handle(parameterized_type.type_class()); | 613 Class& type_class = Class::Handle(parameterized_type.type_class()); |
| 610 if (!type_class.is_finalized()) { | 614 if (!type_class.is_finalized()) { |
| 615 const GrowableObjectArray& visited = |
| 616 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 617 ResolveInterfaces(type_class, visited); |
| 611 FinalizeTypeParameters(type_class); | 618 FinalizeTypeParameters(type_class); |
| 612 } | 619 } |
| 613 | 620 |
| 614 // If the type class is a signature class, we are finalizing its signature | 621 // If the type class is a signature class, we are finalizing its signature |
| 615 // type, thereby finalizing the result type and parameter types of its | 622 // type, thereby finalizing the result type and parameter types of its |
| 616 // signature function. | 623 // signature function. |
| 617 // Do this before marking this type as finalized in order to detect cycles. | 624 // Do this before marking this type as finalized in order to detect cycles. |
| 618 if (type_class.IsSignatureClass()) { | 625 if (type_class.IsSignatureClass()) { |
| 619 // Signature classes are finalized upon creation. | 626 // Signature classes are finalized upon creation. |
| 620 ASSERT(type_class.is_finalized()); | 627 ASSERT(type_class.is_finalized()); |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 void ClassFinalizer::ReportError(const char* format, ...) { | 1322 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1316 va_list args; | 1323 va_list args; |
| 1317 va_start(args, format); | 1324 va_start(args, format); |
| 1318 const Error& error = Error::Handle( | 1325 const Error& error = Error::Handle( |
| 1319 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1326 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1320 va_end(args); | 1327 va_end(args); |
| 1321 ReportError(error); | 1328 ReportError(error); |
| 1322 } | 1329 } |
| 1323 | 1330 |
| 1324 } // namespace dart | 1331 } // namespace dart |
| OLD | NEW |