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/hash_table.h" | 8 #include "vm/hash_table.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 // Finalize mixin type. | 2503 // Finalize mixin type. |
2504 Type& mixin_type = Type::Handle(cls.mixin()); | 2504 Type& mixin_type = Type::Handle(cls.mixin()); |
2505 if (!mixin_type.IsNull()) { | 2505 if (!mixin_type.IsNull()) { |
2506 mixin_type ^= FinalizeType(cls, mixin_type); | 2506 mixin_type ^= FinalizeType(cls, mixin_type); |
2507 cls.set_mixin(mixin_type); | 2507 cls.set_mixin(mixin_type); |
2508 } | 2508 } |
2509 if (cls.IsTypedefClass()) { | 2509 if (cls.IsTypedefClass()) { |
2510 Function& signature = Function::Handle(cls.signature_function()); | 2510 Function& signature = Function::Handle(cls.signature_function()); |
2511 Type& type = Type::Handle(signature.SignatureType()); | 2511 Type& type = Type::Handle(signature.SignatureType()); |
2512 ASSERT(type.signature() == signature.raw()); | 2512 ASSERT(type.signature() == signature.raw()); |
| 2513 ASSERT(type.type_class() == cls.raw()); |
2513 | 2514 |
2514 // Check for illegal self references. | 2515 // Check for illegal self references. |
2515 GrowableArray<intptr_t> visited_aliases; | 2516 GrowableArray<intptr_t> visited_aliases; |
2516 if (!IsTypedefCycleFree(cls, type, &visited_aliases)) { | 2517 if (!IsTypedefCycleFree(cls, type, &visited_aliases)) { |
2517 const String& name = String::Handle(cls.Name()); | 2518 const String& name = String::Handle(cls.Name()); |
2518 ReportError(cls, cls.token_pos(), | 2519 ReportError(cls, cls.token_pos(), |
2519 "typedef '%s' illegally refers to itself", name.ToCString()); | 2520 "typedef '%s' illegally refers to itself", name.ToCString()); |
2520 } | 2521 } |
2521 cls.set_is_type_finalized(); | 2522 cls.set_is_type_finalized(); |
2522 | 2523 |
2523 // Resolve and finalize the result and parameter types of the signature | 2524 // Resolve and finalize the result and parameter types of the signature |
2524 // function of this typedef class. | 2525 // function of this typedef class. |
2525 FinalizeSignature(cls, signature); // Does not modify signature type. | 2526 FinalizeSignature(cls, signature); // Does not modify signature type. |
2526 ASSERT(signature.SignatureType() == type.raw()); | 2527 ASSERT(signature.SignatureType() == type.raw()); |
2527 | 2528 |
2528 // Resolve and finalize the signature type of this typedef. | 2529 // Resolve and finalize the signature type of this typedef. |
2529 type ^= FinalizeType(cls, type); | 2530 type ^= FinalizeType(cls, type); |
| 2531 ASSERT(type.type_class() == cls.raw()); |
2530 | 2532 |
2531 // If a different canonical signature type is returned, update the signature | 2533 // If a different canonical signature type is returned, update the signature |
2532 // function of the typedef. | 2534 // function of the typedef. |
2533 signature = type.signature(); | 2535 signature = type.signature(); |
2534 signature.SetSignatureType(type); | 2536 signature.SetSignatureType(type); |
2535 cls.set_signature_function(signature); | 2537 cls.set_signature_function(signature); |
2536 | 2538 |
2537 // Closure instances do not refer to this typedef as their class, so there | 2539 // Closure instances do not refer to this typedef as their class, so there |
2538 // is no need to add this typedef class to the subclasses of _Closure. | 2540 // is no need to add this typedef class to the subclasses of _Closure. |
2539 ASSERT(super_type.IsNull() || super_type.IsObjectType()); | 2541 ASSERT(super_type.IsNull() || super_type.IsObjectType()); |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3808 ProgramVisitor::VisitFunctions(&function_visitor); | 3810 ProgramVisitor::VisitFunctions(&function_visitor); |
3809 | 3811 |
3810 class ClearCodeClassVisitor : public ClassVisitor { | 3812 class ClearCodeClassVisitor : public ClassVisitor { |
3811 void Visit(const Class& cls) { cls.DisableAllocationStub(); } | 3813 void Visit(const Class& cls) { cls.DisableAllocationStub(); } |
3812 }; | 3814 }; |
3813 ClearCodeClassVisitor class_visitor; | 3815 ClearCodeClassVisitor class_visitor; |
3814 ProgramVisitor::VisitClasses(&class_visitor); | 3816 ProgramVisitor::VisitClasses(&class_visitor); |
3815 } | 3817 } |
3816 | 3818 |
3817 } // namespace dart | 3819 } // namespace dart |
OLD | NEW |