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 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 String::Handle(zone, mixin_cls.Name()).ToCString()); | 2415 String::Handle(zone, mixin_cls.Name()).ToCString()); |
2416 } | 2416 } |
2417 continue; // Skip the implicit constructor. | 2417 continue; // Skip the implicit constructor. |
2418 } | 2418 } |
2419 if (!func.is_static() && !func.IsMethodExtractor() && | 2419 if (!func.is_static() && !func.IsMethodExtractor() && |
2420 !func.IsNoSuchMethodDispatcher() && !func.IsInvokeFieldDispatcher()) { | 2420 !func.IsNoSuchMethodDispatcher() && !func.IsInvokeFieldDispatcher()) { |
2421 func = func.Clone(cls); | 2421 func = func.Clone(cls); |
2422 cloned_funcs.Add(func); | 2422 cloned_funcs.Add(func); |
2423 } | 2423 } |
2424 } | 2424 } |
2425 functions = Array::MakeArray(cloned_funcs); | 2425 functions = Array::MakeFixedLength(cloned_funcs); |
2426 cls.SetFunctions(functions); | 2426 cls.SetFunctions(functions); |
2427 | 2427 |
2428 // Now clone the fields from the mixin class. There should be no | 2428 // Now clone the fields from the mixin class. There should be no |
2429 // existing fields in the mixin application class. | 2429 // existing fields in the mixin application class. |
2430 ASSERT(Array::Handle(cls.fields()).Length() == 0); | 2430 ASSERT(Array::Handle(cls.fields()).Length() == 0); |
2431 const Array& fields = Array::Handle(zone, mixin_cls.fields()); | 2431 const Array& fields = Array::Handle(zone, mixin_cls.fields()); |
2432 const intptr_t num_fields = fields.Length(); | 2432 const intptr_t num_fields = fields.Length(); |
2433 Field& field = Field::Handle(zone); | 2433 Field& field = Field::Handle(zone); |
2434 GrowableArray<const Field*> cloned_fields(num_fields); | 2434 GrowableArray<const Field*> cloned_fields(num_fields); |
2435 for (intptr_t i = 0; i < num_fields; i++) { | 2435 for (intptr_t i = 0; i < num_fields; i++) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2650 if (cls.is_mixin_app_alias() && | 2650 if (cls.is_mixin_app_alias() && |
2651 (cls.functions() == Object::empty_array().raw())) { | 2651 (cls.functions() == Object::empty_array().raw())) { |
2652 const GrowableObjectArray& cloned_funcs = | 2652 const GrowableObjectArray& cloned_funcs = |
2653 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 2653 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
2654 | 2654 |
2655 const Class& mixin_app_class = Class::Handle(cls.SuperClass()); | 2655 const Class& mixin_app_class = Class::Handle(cls.SuperClass()); |
2656 const Type& mixin_type = Type::Handle(mixin_app_class.mixin()); | 2656 const Type& mixin_type = Type::Handle(mixin_app_class.mixin()); |
2657 const Class& mixin_cls = Class::Handle(mixin_type.type_class()); | 2657 const Class& mixin_cls = Class::Handle(mixin_type.type_class()); |
2658 | 2658 |
2659 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); | 2659 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); |
2660 const Array& functions = Array::Handle(Array::MakeArray(cloned_funcs)); | 2660 const Array& functions = |
| 2661 Array::Handle(Array::MakeFixedLength(cloned_funcs)); |
2661 cls.SetFunctions(functions); | 2662 cls.SetFunctions(functions); |
2662 } | 2663 } |
2663 // Every class should have at least a constructor, unless it is a top level | 2664 // Every class should have at least a constructor, unless it is a top level |
2664 // class or a typedef class. The Kernel frontend does not create an implicit | 2665 // class or a typedef class. The Kernel frontend does not create an implicit |
2665 // constructor for abstract classes. | 2666 // constructor for abstract classes. |
2666 ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() || cls.is_abstract() || | 2667 ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() || cls.is_abstract() || |
2667 (Array::Handle(cls.functions()).Length() > 0)); | 2668 (Array::Handle(cls.functions()).Length() > 0)); |
2668 // Resolve and finalize all member types. | 2669 // Resolve and finalize all member types. |
2669 ResolveAndFinalizeMemberTypes(cls); | 2670 ResolveAndFinalizeMemberTypes(cls); |
2670 // Run additional checks after all types are finalized. | 2671 // Run additional checks after all types are finalized. |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 ProgramVisitor::VisitFunctions(&function_visitor); | 3801 ProgramVisitor::VisitFunctions(&function_visitor); |
3801 | 3802 |
3802 class ClearCodeClassVisitor : public ClassVisitor { | 3803 class ClearCodeClassVisitor : public ClassVisitor { |
3803 void Visit(const Class& cls) { cls.DisableAllocationStub(); } | 3804 void Visit(const Class& cls) { cls.DisableAllocationStub(); } |
3804 }; | 3805 }; |
3805 ClearCodeClassVisitor class_visitor; | 3806 ClearCodeClassVisitor class_visitor; |
3806 ProgramVisitor::VisitClasses(&class_visitor); | 3807 ProgramVisitor::VisitClasses(&class_visitor); |
3807 } | 3808 } |
3808 | 3809 |
3809 } // namespace dart | 3810 } // namespace dart |
OLD | NEW |