| 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 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 String::Handle(zone, mixin_cls.Name()).ToCString()); | 2422 String::Handle(zone, mixin_cls.Name()).ToCString()); |
| 2423 } | 2423 } |
| 2424 continue; // Skip the implicit constructor. | 2424 continue; // Skip the implicit constructor. |
| 2425 } | 2425 } |
| 2426 if (!func.is_static() && !func.IsMethodExtractor() && | 2426 if (!func.is_static() && !func.IsMethodExtractor() && |
| 2427 !func.IsNoSuchMethodDispatcher() && !func.IsInvokeFieldDispatcher()) { | 2427 !func.IsNoSuchMethodDispatcher() && !func.IsInvokeFieldDispatcher()) { |
| 2428 func = func.Clone(cls); | 2428 func = func.Clone(cls); |
| 2429 cloned_funcs.Add(func); | 2429 cloned_funcs.Add(func); |
| 2430 } | 2430 } |
| 2431 } | 2431 } |
| 2432 functions = Array::MakeFixedLength(cloned_funcs); | 2432 functions = Array::MakeArray(cloned_funcs); |
| 2433 cls.SetFunctions(functions); | 2433 cls.SetFunctions(functions); |
| 2434 | 2434 |
| 2435 // Now clone the fields from the mixin class. There should be no | 2435 // Now clone the fields from the mixin class. There should be no |
| 2436 // existing fields in the mixin application class. | 2436 // existing fields in the mixin application class. |
| 2437 ASSERT(Array::Handle(cls.fields()).Length() == 0); | 2437 ASSERT(Array::Handle(cls.fields()).Length() == 0); |
| 2438 const Array& fields = Array::Handle(zone, mixin_cls.fields()); | 2438 const Array& fields = Array::Handle(zone, mixin_cls.fields()); |
| 2439 const intptr_t num_fields = fields.Length(); | 2439 const intptr_t num_fields = fields.Length(); |
| 2440 Field& field = Field::Handle(zone); | 2440 Field& field = Field::Handle(zone); |
| 2441 GrowableArray<const Field*> cloned_fields(num_fields); | 2441 GrowableArray<const Field*> cloned_fields(num_fields); |
| 2442 for (intptr_t i = 0; i < num_fields; i++) { | 2442 for (intptr_t i = 0; i < num_fields; i++) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 if (cls.is_mixin_app_alias() && | 2659 if (cls.is_mixin_app_alias() && |
| 2660 (cls.functions() == Object::empty_array().raw())) { | 2660 (cls.functions() == Object::empty_array().raw())) { |
| 2661 const GrowableObjectArray& cloned_funcs = | 2661 const GrowableObjectArray& cloned_funcs = |
| 2662 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 2662 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 2663 | 2663 |
| 2664 const Class& mixin_app_class = Class::Handle(cls.SuperClass()); | 2664 const Class& mixin_app_class = Class::Handle(cls.SuperClass()); |
| 2665 const Type& mixin_type = Type::Handle(mixin_app_class.mixin()); | 2665 const Type& mixin_type = Type::Handle(mixin_app_class.mixin()); |
| 2666 const Class& mixin_cls = Class::Handle(mixin_type.type_class()); | 2666 const Class& mixin_cls = Class::Handle(mixin_type.type_class()); |
| 2667 | 2667 |
| 2668 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); | 2668 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); |
| 2669 const Array& functions = | 2669 const Array& functions = Array::Handle(Array::MakeArray(cloned_funcs)); |
| 2670 Array::Handle(Array::MakeFixedLength(cloned_funcs)); | |
| 2671 cls.SetFunctions(functions); | 2670 cls.SetFunctions(functions); |
| 2672 } | 2671 } |
| 2673 // Every class should have at least a constructor, unless it is a top level | 2672 // Every class should have at least a constructor, unless it is a top level |
| 2674 // class or a typedef class. The Kernel frontend does not create an implicit | 2673 // class or a typedef class. The Kernel frontend does not create an implicit |
| 2675 // constructor for abstract classes. | 2674 // constructor for abstract classes. |
| 2676 ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() || cls.is_abstract() || | 2675 ASSERT(cls.IsTopLevel() || cls.IsTypedefClass() || cls.is_abstract() || |
| 2677 (Array::Handle(cls.functions()).Length() > 0)); | 2676 (Array::Handle(cls.functions()).Length() > 0)); |
| 2678 // Resolve and finalize all member types. | 2677 // Resolve and finalize all member types. |
| 2679 ResolveAndFinalizeMemberTypes(cls); | 2678 ResolveAndFinalizeMemberTypes(cls); |
| 2680 // Run additional checks after all types are finalized. | 2679 // Run additional checks after all types are finalized. |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3810 ProgramVisitor::VisitFunctions(&function_visitor); | 3809 ProgramVisitor::VisitFunctions(&function_visitor); |
| 3811 | 3810 |
| 3812 class ClearCodeClassVisitor : public ClassVisitor { | 3811 class ClearCodeClassVisitor : public ClassVisitor { |
| 3813 void Visit(const Class& cls) { cls.DisableAllocationStub(); } | 3812 void Visit(const Class& cls) { cls.DisableAllocationStub(); } |
| 3814 }; | 3813 }; |
| 3815 ClearCodeClassVisitor class_visitor; | 3814 ClearCodeClassVisitor class_visitor; |
| 3816 ProgramVisitor::VisitClasses(&class_visitor); | 3815 ProgramVisitor::VisitClasses(&class_visitor); |
| 3817 } | 3816 } |
| 3818 | 3817 |
| 3819 } // namespace dart | 3818 } // namespace dart |
| OLD | NEW |