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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 | 1732 |
1733 | 1733 |
1734 void Class::CalculateFieldOffsets() const { | 1734 void Class::CalculateFieldOffsets() const { |
1735 Array& flds = Array::Handle(fields()); | 1735 Array& flds = Array::Handle(fields()); |
1736 const Class& super = Class::Handle(SuperClass()); | 1736 const Class& super = Class::Handle(SuperClass()); |
1737 intptr_t offset = 0; | 1737 intptr_t offset = 0; |
1738 intptr_t type_args_field_offset = kNoTypeArguments; | 1738 intptr_t type_args_field_offset = kNoTypeArguments; |
1739 if (super.IsNull()) { | 1739 if (super.IsNull()) { |
1740 offset = sizeof(RawObject); | 1740 offset = sizeof(RawObject); |
1741 } else { | 1741 } else { |
| 1742 ASSERT(super.is_finalized() || super.is_prefinalized()); |
1742 type_args_field_offset = super.type_arguments_field_offset(); | 1743 type_args_field_offset = super.type_arguments_field_offset(); |
1743 offset = super.next_field_offset(); | 1744 offset = super.next_field_offset(); |
1744 ASSERT(offset > 0); | 1745 ASSERT(offset > 0); |
1745 // We should never call CalculateFieldOffsets for native wrapper | 1746 // We should never call CalculateFieldOffsets for native wrapper |
1746 // classes, assert this. | 1747 // classes, assert this. |
1747 ASSERT(num_native_fields() == 0); | 1748 ASSERT(num_native_fields() == 0); |
1748 set_num_native_fields(super.num_native_fields()); | 1749 set_num_native_fields(super.num_native_fields()); |
1749 } | 1750 } |
1750 // If the super class is parameterized, use the same type_arguments field. | 1751 // If the super class is parameterized, use the same type_arguments field, |
| 1752 // otherwise, if this class is the first in the super chain to be |
| 1753 // parameterized, introduce a new type_arguments field. |
1751 if (type_args_field_offset == kNoTypeArguments) { | 1754 if (type_args_field_offset == kNoTypeArguments) { |
1752 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1755 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
1753 if (!type_params.IsNull()) { | 1756 if (!type_params.IsNull()) { |
1754 ASSERT(type_params.Length() > 0); | 1757 ASSERT(type_params.Length() > 0); |
1755 // The instance needs a type_arguments field. | 1758 // The instance needs a type_arguments field. |
1756 type_args_field_offset = offset; | 1759 type_args_field_offset = offset; |
1757 offset += kWordSize; | 1760 offset += kWordSize; |
1758 } | 1761 } |
1759 } | 1762 } |
1760 set_type_arguments_field_offset(type_args_field_offset); | 1763 set_type_arguments_field_offset(type_args_field_offset); |
(...skipping 12607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14368 } | 14371 } |
14369 | 14372 |
14370 | 14373 |
14371 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14374 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14372 stream->OpenObject(); | 14375 stream->OpenObject(); |
14373 stream->CloseObject(); | 14376 stream->CloseObject(); |
14374 } | 14377 } |
14375 | 14378 |
14376 | 14379 |
14377 } // namespace dart | 14380 } // namespace dart |
OLD | NEW |