Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: runtime/vm/object.cc

Issue 23453024: Keep track of type parameter processing in mixin application classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 return closure.raw(); 1633 return closure.raw();
1634 } 1634 }
1635 1635
1636 1636
1637 void Class::set_signature_function(const Function& value) const { 1637 void Class::set_signature_function(const Function& value) const {
1638 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction()); 1638 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction());
1639 StorePointer(&raw_ptr()->signature_function_, value.raw()); 1639 StorePointer(&raw_ptr()->signature_function_, value.raw());
1640 } 1640 }
1641 1641
1642 1642
1643 void Class::set_class_state(RawClass::ClassState state) const {
1644 ASSERT((state == RawClass::kAllocated) ||
1645 (state == RawClass::kPreFinalized) ||
1646 (state == RawClass::kFinalized));
1647 set_state_bits(StateBits::update(state, raw_ptr()->state_bits_));
1648 }
1649
1650
1651 void Class::set_state_bits(intptr_t bits) const { 1643 void Class::set_state_bits(intptr_t bits) const {
1652 raw_ptr()->state_bits_ = static_cast<uint16_t>(bits); 1644 raw_ptr()->state_bits_ = static_cast<uint16_t>(bits);
1653 } 1645 }
1654 1646
1655 1647
1656 void Class::set_library(const Library& value) const { 1648 void Class::set_library(const Library& value) const {
1657 StorePointer(&raw_ptr()->library_, value.raw()); 1649 StorePointer(&raw_ptr()->library_, value.raw());
1658 } 1650 }
1659 1651
1660 1652
1661 void Class::set_type_parameters(const TypeArguments& value) const { 1653 void Class::set_type_parameters(const TypeArguments& value) const {
1662 StorePointer(&raw_ptr()->type_parameters_, value.raw()); 1654 StorePointer(&raw_ptr()->type_parameters_, value.raw());
1663 } 1655 }
1664 1656
1665 1657
1666 intptr_t Class::NumTypeParameters() const { 1658 intptr_t Class::NumTypeParameters() const {
1659 if ((mixin() != Type::null()) && !is_mixin_type_applied()) {
siva 2013/09/04 21:07:00 See comment on isMixin() method.
regis 2013/09/04 22:14:27 Done.
1660 ClassFinalizer::ApplyMixinType(*this);
1661 }
1667 if (type_parameters() == TypeArguments::null()) { 1662 if (type_parameters() == TypeArguments::null()) {
1668 return 0; 1663 return 0;
1669 } 1664 }
1670 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); 1665 const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
1671 return type_params.Length(); 1666 return type_params.Length();
1672 } 1667 }
1673 1668
1674 1669
1675 intptr_t Class::NumTypeArguments() const { 1670 intptr_t Class::NumTypeArguments() const {
1676 // To work properly, this call requires the super class of this class to be 1671 // To work properly, this call requires the super class of this class to be
1677 // resolved, which is checked by the SuperClass() call. 1672 // resolved, which is checked by the type_class() call on the super type.
1673 // Note that calling type_class() on a MixinAppType fails.
1678 Isolate* isolate = Isolate::Current(); 1674 Isolate* isolate = Isolate::Current();
1679 ReusableHandleScope reused_handles(isolate); 1675 ReusableHandleScope reused_handles(isolate);
1680 Class& cls = reused_handles.ClassHandle(); 1676 Class& cls = reused_handles.ClassHandle();
1681 TypeArguments& type_params = reused_handles.TypeArgumentsHandle(); 1677 TypeArguments& type_params = reused_handles.TypeArgumentsHandle();
1682 AbstractType& sup_type = reused_handles.AbstractTypeHandle(); 1678 AbstractType& sup_type = reused_handles.AbstractTypeHandle();
1683 cls ^= raw(); 1679 cls ^= raw();
1684 intptr_t num_type_args = 0; 1680 intptr_t num_type_args = 0;
1685 1681
1686 do { 1682 do {
1687 if (cls.IsSignatureClass()) { 1683 if (cls.IsSignatureClass()) {
1688 Function& signature_fun = reused_handles.FunctionHandle(); 1684 Function& signature_fun = reused_handles.FunctionHandle();
1689 signature_fun ^= cls.signature_function(); 1685 signature_fun ^= cls.signature_function();
1690 if (!signature_fun.is_static() && 1686 if (!signature_fun.is_static() &&
1691 !signature_fun.HasInstantiatedSignature()) { 1687 !signature_fun.HasInstantiatedSignature()) {
1692 cls = signature_fun.Owner(); 1688 cls = signature_fun.Owner();
1693 } 1689 }
1694 } 1690 }
1695 if (cls.type_parameters() != TypeArguments::null()) { 1691 // Calling NumTypeParameters() on a mixin application class will setup the
1692 // type parameters if not already done.
1693 if (cls.NumTypeParameters() > 0) {
1696 type_params ^= cls.type_parameters(); 1694 type_params ^= cls.type_parameters();
1697 num_type_args += type_params.Length(); 1695 num_type_args += type_params.Length();
1698 } 1696 }
1699 1697
1700 // Super type of Object class is null. 1698 // Super type of Object class is null.
1701 if (cls.super_type() == AbstractType::null() || 1699 if (cls.super_type() == AbstractType::null() ||
1702 cls.super_type() == isolate->object_store()->object_type()) { 1700 cls.super_type() == isolate->object_store()->object_type()) {
1703 break; 1701 break;
1704 } 1702 }
1705 sup_type ^= cls.super_type(); 1703 sup_type ^= cls.super_type();
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 void Class::set_is_const() const { 2345 void Class::set_is_const() const {
2348 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_)); 2346 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_));
2349 } 2347 }
2350 2348
2351 2349
2352 void Class::set_is_mixin_typedef() const { 2350 void Class::set_is_mixin_typedef() const {
2353 set_state_bits(MixinTypedefBit::update(true, raw_ptr()->state_bits_)); 2351 set_state_bits(MixinTypedefBit::update(true, raw_ptr()->state_bits_));
2354 } 2352 }
2355 2353
2356 2354
2355 void Class::set_is_mixin_type_applied() const {
2356 set_state_bits(MixinTypeAppliedBit::update(true, raw_ptr()->state_bits_));
2357 }
2358
2359
2357 void Class::set_is_finalized() const { 2360 void Class::set_is_finalized() const {
2358 ASSERT(!is_finalized()); 2361 ASSERT(!is_finalized());
2359 set_state_bits(StateBits::update(RawClass::kFinalized, 2362 set_state_bits(ClassFinalizedBits::update(RawClass::kFinalized,
2360 raw_ptr()->state_bits_)); 2363 raw_ptr()->state_bits_));
2361 } 2364 }
2362 2365
2363 2366
2364 void Class::set_is_prefinalized() const { 2367 void Class::set_is_prefinalized() const {
2365 ASSERT(!is_finalized()); 2368 ASSERT(!is_finalized());
2366 set_state_bits(StateBits::update(RawClass::kPreFinalized, 2369 set_state_bits(ClassFinalizedBits::update(RawClass::kPreFinalized,
2367 raw_ptr()->state_bits_)); 2370 raw_ptr()->state_bits_));
2368 } 2371 }
2369 2372
2370 2373
2371 void Class::set_is_marked_for_parsing() const { 2374 void Class::set_is_marked_for_parsing() const {
2372 set_state_bits(MarkedForParsingBit::update(true, raw_ptr()->state_bits_)); 2375 set_state_bits(MarkedForParsingBit::update(true, raw_ptr()->state_bits_));
2373 } 2376 }
2374 2377
2375 2378
2376 void Class::reset_is_marked_for_parsing() const { 2379 void Class::reset_is_marked_for_parsing() const {
2377 set_state_bits(MarkedForParsingBit::update(false, raw_ptr()->state_bits_)); 2380 set_state_bits(MarkedForParsingBit::update(false, raw_ptr()->state_bits_));
(...skipping 12534 matching lines...) Expand 10 before | Expand all | Expand 10 after
14912 } 14915 }
14913 14916
14914 14917
14915 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14918 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14916 stream->OpenObject(); 14919 stream->OpenObject();
14917 stream->CloseObject(); 14920 stream->CloseObject();
14918 } 14921 }
14919 14922
14920 14923
14921 } // namespace dart 14924 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698