| 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 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 } | 1686 } |
| 1687 } | 1687 } |
| 1688 | 1688 |
| 1689 const TypeArguments& cloned_type_params = TypeArguments::Handle(zone, | 1689 const TypeArguments& cloned_type_params = TypeArguments::Handle(zone, |
| 1690 TypeArguments::New((share_type_params ? 0 : num_super_type_params) + | 1690 TypeArguments::New((share_type_params ? 0 : num_super_type_params) + |
| 1691 num_mixin_type_params)); | 1691 num_mixin_type_params)); |
| 1692 TypeParameter& param = TypeParameter::Handle(zone); | 1692 TypeParameter& param = TypeParameter::Handle(zone); |
| 1693 TypeParameter& cloned_param = TypeParameter::Handle(zone); | 1693 TypeParameter& cloned_param = TypeParameter::Handle(zone); |
| 1694 String& param_name = String::Handle(zone); | 1694 String& param_name = String::Handle(zone); |
| 1695 AbstractType& param_bound = AbstractType::Handle(zone); | 1695 AbstractType& param_bound = AbstractType::Handle(zone); |
| 1696 Function& null_function = Function::Handle(zone); |
| 1696 intptr_t cloned_index = 0; | 1697 intptr_t cloned_index = 0; |
| 1697 | 1698 |
| 1698 // First, clone the super class type parameters. Rename them so that | 1699 // First, clone the super class type parameters. Rename them so that |
| 1699 // there can be no name conflict between the parameters of the super | 1700 // there can be no name conflict between the parameters of the super |
| 1700 // class and the mixin class. | 1701 // class and the mixin class. |
| 1701 if (!share_type_params && (num_super_type_params > 0)) { | 1702 if (!share_type_params && (num_super_type_params > 0)) { |
| 1702 const TypeArguments& super_type_params = | 1703 const TypeArguments& super_type_params = |
| 1703 TypeArguments::Handle(zone, super_class.type_parameters()); | 1704 TypeArguments::Handle(zone, super_class.type_parameters()); |
| 1704 const TypeArguments& super_type_args = TypeArguments::Handle(zone, | 1705 const TypeArguments& super_type_args = TypeArguments::Handle(zone, |
| 1705 TypeArguments::New(num_super_type_params)); | 1706 TypeArguments::New(num_super_type_params)); |
| 1706 // The cloned super class type parameters do not need to repeat their | 1707 // The cloned super class type parameters do not need to repeat their |
| 1707 // bounds, since the bound checks will be performed at the super class | 1708 // bounds, since the bound checks will be performed at the super class |
| 1708 // level. As a consequence, if this mixin application is used itself as a | 1709 // level. As a consequence, if this mixin application is used itself as a |
| 1709 // mixin in another mixin application, the bounds will be ignored, which | 1710 // mixin in another mixin application, the bounds will be ignored, which |
| 1710 // is correct, because the other mixin application does not inherit from | 1711 // is correct, because the other mixin application does not inherit from |
| 1711 // the super class of its mixin. Note also that the other mixin | 1712 // the super class of its mixin. Note also that the other mixin |
| 1712 // application will only mixin the last mixin type listed in the first | 1713 // application will only mixin the last mixin type listed in the first |
| 1713 // mixin application it is mixing in. | 1714 // mixin application it is mixing in. |
| 1714 param_bound = thread->isolate()->object_store()->object_type(); | 1715 param_bound = thread->isolate()->object_store()->object_type(); |
| 1715 for (intptr_t i = 0; i < num_super_type_params; i++) { | 1716 for (intptr_t i = 0; i < num_super_type_params; i++) { |
| 1716 param ^= super_type_params.TypeAt(i); | 1717 param ^= super_type_params.TypeAt(i); |
| 1717 param_name = param.name(); | 1718 param_name = param.name(); |
| 1718 param_name = Symbols::FromConcat(thread, | 1719 param_name = Symbols::FromConcat(thread, |
| 1719 param_name, Symbols::Backtick()); | 1720 param_name, Symbols::Backtick()); |
| 1720 cloned_param = TypeParameter::New(mixin_app_class, | 1721 cloned_param = TypeParameter::New(mixin_app_class, |
| 1722 null_function, |
| 1721 cloned_index, | 1723 cloned_index, |
| 1722 param_name, | 1724 param_name, |
| 1723 param_bound, | 1725 param_bound, |
| 1724 param.token_pos()); | 1726 param.token_pos()); |
| 1725 cloned_type_params.SetTypeAt(cloned_index, cloned_param); | 1727 cloned_type_params.SetTypeAt(cloned_index, cloned_param); |
| 1726 // Change the type arguments of the super type to refer to the | 1728 // Change the type arguments of the super type to refer to the |
| 1727 // cloned type parameters of the mixin application class. | 1729 // cloned type parameters of the mixin application class. |
| 1728 super_type_args.SetTypeAt(cloned_index, cloned_param); | 1730 super_type_args.SetTypeAt(cloned_index, cloned_param); |
| 1729 cloned_index++; | 1731 cloned_index++; |
| 1730 } | 1732 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1749 instantiator ^= TypeArguments::New(offset + num_mixin_type_params); | 1751 instantiator ^= TypeArguments::New(offset + num_mixin_type_params); |
| 1750 bool has_uninstantiated_bounds = false; | 1752 bool has_uninstantiated_bounds = false; |
| 1751 for (intptr_t i = 0; i < num_mixin_type_params; i++) { | 1753 for (intptr_t i = 0; i < num_mixin_type_params; i++) { |
| 1752 param ^= mixin_params.TypeAt(i); | 1754 param ^= mixin_params.TypeAt(i); |
| 1753 param_name = param.name(); | 1755 param_name = param.name(); |
| 1754 param_bound = param.bound(); // The bound will be adjusted below. | 1756 param_bound = param.bound(); // The bound will be adjusted below. |
| 1755 if (!param_bound.IsInstantiated()) { | 1757 if (!param_bound.IsInstantiated()) { |
| 1756 has_uninstantiated_bounds = true; | 1758 has_uninstantiated_bounds = true; |
| 1757 } | 1759 } |
| 1758 cloned_param = TypeParameter::New(mixin_app_class, | 1760 cloned_param = TypeParameter::New(mixin_app_class, |
| 1761 null_function, |
| 1759 cloned_index, // Unfinalized index. | 1762 cloned_index, // Unfinalized index. |
| 1760 param_name, | 1763 param_name, |
| 1761 param_bound, | 1764 param_bound, |
| 1762 param.token_pos()); | 1765 param.token_pos()); |
| 1763 cloned_type_params.SetTypeAt(cloned_index, cloned_param); | 1766 cloned_type_params.SetTypeAt(cloned_index, cloned_param); |
| 1764 mixin_type_args.SetTypeAt(i, cloned_param); // Unfinalized length. | 1767 mixin_type_args.SetTypeAt(i, cloned_param); // Unfinalized length. |
| 1765 instantiator.SetTypeAt(offset + i, cloned_param); // Finalized length. | 1768 instantiator.SetTypeAt(offset + i, cloned_param); // Finalized length. |
| 1766 cloned_index++; | 1769 cloned_index++; |
| 1767 } | 1770 } |
| 1768 | 1771 |
| (...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3342 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3345 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3343 field ^= fields_array.At(0); | 3346 field ^= fields_array.At(0); |
| 3344 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3347 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3345 name ^= field.name(); | 3348 name ^= field.name(); |
| 3346 expected_name ^= String::New("_data"); | 3349 expected_name ^= String::New("_data"); |
| 3347 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3350 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3348 #endif | 3351 #endif |
| 3349 } | 3352 } |
| 3350 | 3353 |
| 3351 } // namespace dart | 3354 } // namespace dart |
| OLD | NEW |