| 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/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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } | 764 } |
| 765 parameterized_type.set_arguments(full_arguments); | 765 parameterized_type.set_arguments(full_arguments); |
| 766 } else { | 766 } else { |
| 767 ASSERT(full_arguments.IsNull()); // Use null vector for raw type. | 767 ASSERT(full_arguments.IsNull()); // Use null vector for raw type. |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 | 770 |
| 771 // Self referencing types may get finalized indirectly. | 771 // Self referencing types may get finalized indirectly. |
| 772 if (!parameterized_type.IsFinalized()) { | 772 if (!parameterized_type.IsFinalized()) { |
| 773 // Mark the type as finalized. | 773 // Mark the type as finalized. |
| 774 if (parameterized_type.IsInstantiated()) { | 774 parameterized_type.SetIsFinalized(); |
| 775 parameterized_type.set_is_finalized_instantiated(); | |
| 776 } else { | |
| 777 parameterized_type.set_is_finalized_uninstantiated(); | |
| 778 } | |
| 779 } | 775 } |
| 780 | 776 |
| 781 // Upper bounds of the finalized type arguments are only verified in checked | 777 // Upper bounds of the finalized type arguments are only verified in checked |
| 782 // mode, since bound errors are never reported by the vm in production mode. | 778 // mode, since bound errors are never reported by the vm in production mode. |
| 783 if (FLAG_enable_type_checks && | 779 if (FLAG_enable_type_checks && |
| 784 !full_arguments.IsNull() && | 780 !full_arguments.IsNull() && |
| 785 full_arguments.IsInstantiated()) { | 781 full_arguments.IsInstantiated()) { |
| 786 ResolveAndFinalizeUpperBounds(type_class); | 782 ResolveAndFinalizeUpperBounds(type_class); |
| 787 Error& malformed_error = Error::Handle(); | 783 Error& malformed_error = Error::Handle(); |
| 788 // Pass the full type argument vector as the bounds instantiator. | 784 // Pass the full type argument vector as the bounds instantiator. |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 // We do not want an unresolved class to end up in a snapshot. | 1621 // We do not want an unresolved class to end up in a snapshot. |
| 1626 type.set_type_class(Object::Handle(Object::null_class())); | 1622 type.set_type_class(Object::Handle(Object::null_class())); |
| 1627 } | 1623 } |
| 1628 } else { | 1624 } else { |
| 1629 // In production mode, do not mark the type with a resolved type class as | 1625 // In production mode, do not mark the type with a resolved type class as |
| 1630 // malformed, but make it raw. | 1626 // malformed, but make it raw. |
| 1631 type.set_arguments(AbstractTypeArguments::Handle()); | 1627 type.set_arguments(AbstractTypeArguments::Handle()); |
| 1632 } | 1628 } |
| 1633 ASSERT(type.HasResolvedTypeClass()); | 1629 ASSERT(type.HasResolvedTypeClass()); |
| 1634 if (!type.IsFinalized()) { | 1630 if (!type.IsFinalized()) { |
| 1635 type.set_is_finalized_instantiated(); | 1631 type.SetIsFinalized(); |
| 1636 // Do not canonicalize malformed types, since they may not be resolved. | 1632 // Do not canonicalize malformed types, since they may not be resolved. |
| 1637 } else { | 1633 } else { |
| 1638 // The only case where the malformed type was already finalized is when its | 1634 // The only case where the malformed type was already finalized is when its |
| 1639 // type arguments are not within bounds. In that case, we have a prev_error. | 1635 // type arguments are not within bounds. In that case, we have a prev_error. |
| 1640 ASSERT(!prev_error.IsNull()); | 1636 ASSERT(!prev_error.IsNull()); |
| 1641 } | 1637 } |
| 1642 } | 1638 } |
| 1643 | 1639 |
| 1644 | 1640 |
| 1645 RawType* ClassFinalizer::NewFinalizedMalformedType( | 1641 RawType* ClassFinalizer::NewFinalizedMalformedType( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 void ClassFinalizer::ReportError(const char* format, ...) { | 1692 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1697 va_list args; | 1693 va_list args; |
| 1698 va_start(args, format); | 1694 va_start(args, format); |
| 1699 const Error& error = Error::Handle( | 1695 const Error& error = Error::Handle( |
| 1700 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1696 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1701 va_end(args); | 1697 va_end(args); |
| 1702 ReportError(error); | 1698 ReportError(error); |
| 1703 } | 1699 } |
| 1704 | 1700 |
| 1705 } // namespace dart | 1701 } // namespace dart |
| OLD | NEW |