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/code_generator.h" | 7 #include "vm/code_generator.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 func ^= functions.At(i); | 2128 func ^= functions.At(i); |
2129 if (func.IsConstructor()) { | 2129 if (func.IsConstructor()) { |
2130 // A mixin class must not have explicit constructors. | 2130 // A mixin class must not have explicit constructors. |
2131 if (!func.IsImplicitConstructor()) { | 2131 if (!func.IsImplicitConstructor()) { |
2132 ReportError(cls, cls.token_pos(), | 2132 ReportError(cls, cls.token_pos(), |
2133 "mixin class '%s' must not have constructors\n", | 2133 "mixin class '%s' must not have constructors\n", |
2134 String::Handle(isolate, mixin_cls.Name()).ToCString()); | 2134 String::Handle(isolate, mixin_cls.Name()).ToCString()); |
2135 } | 2135 } |
2136 continue; // Skip the implicit constructor. | 2136 continue; // Skip the implicit constructor. |
2137 } | 2137 } |
2138 if (!func.is_static()) { | 2138 if (!func.is_static() && |
| 2139 !func.IsMethodExtractor() && |
| 2140 !func.IsNoSuchMethodDispatcher() && |
| 2141 !func.IsInvokeFieldDispatcher()) { |
2139 func = func.Clone(cls); | 2142 func = func.Clone(cls); |
2140 cloned_funcs.Add(func); | 2143 cloned_funcs.Add(func); |
2141 } | 2144 } |
2142 } | 2145 } |
2143 functions = Array::MakeArray(cloned_funcs); | 2146 functions = Array::MakeArray(cloned_funcs); |
2144 cls.SetFunctions(functions); | 2147 cls.SetFunctions(functions); |
2145 | 2148 |
2146 // Now clone the fields from the mixin class. There should be no | 2149 // Now clone the fields from the mixin class. There should be no |
2147 // existing fields in the mixin application class. | 2150 // existing fields in the mixin application class. |
2148 ASSERT(Array::Handle(cls.fields()).Length() == 0); | 2151 ASSERT(Array::Handle(cls.fields()).Length() == 0); |
2149 const Array& fields = Array::Handle(isolate, mixin_cls.fields()); | 2152 const Array& fields = Array::Handle(isolate, mixin_cls.fields()); |
2150 Field& field = Field::Handle(isolate); | 2153 Field& field = Field::Handle(isolate); |
2151 const GrowableObjectArray& cloned_fields = | 2154 const GrowableObjectArray& cloned_fields = |
2152 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); | 2155 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
2153 const intptr_t num_fields = fields.Length(); | 2156 const intptr_t num_fields = fields.Length(); |
2154 for (intptr_t i = 0; i < num_fields; i++) { | 2157 for (intptr_t i = 0; i < num_fields; i++) { |
2155 field ^= fields.At(i); | 2158 field ^= fields.At(i); |
| 2159 // Static fields are shared between the mixin class and the mixin |
| 2160 // application class. |
2156 if (!field.is_static()) { | 2161 if (!field.is_static()) { |
2157 field = field.Clone(cls); | 2162 field = field.Clone(cls); |
2158 cloned_fields.Add(field); | 2163 cloned_fields.Add(field); |
2159 } | 2164 } |
2160 } | 2165 } |
2161 cls.AddFields(cloned_fields); | 2166 cls.AddFields(cloned_fields); |
2162 | 2167 |
2163 if (FLAG_trace_class_finalization) { | 2168 if (FLAG_trace_class_finalization) { |
2164 OS::Print("Done applying mixin members of %s to %s\n", | 2169 OS::Print("Done applying mixin members of %s to %s\n", |
2165 mixin_cls.ToCString(), | 2170 mixin_cls.ToCString(), |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3083 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3079 field ^= fields_array.At(0); | 3084 field ^= fields_array.At(0); |
3080 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3085 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3081 name ^= field.name(); | 3086 name ^= field.name(); |
3082 expected_name ^= String::New("_data"); | 3087 expected_name ^= String::New("_data"); |
3083 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3088 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3084 #endif | 3089 #endif |
3085 } | 3090 } |
3086 | 3091 |
3087 } // namespace dart | 3092 } // namespace dart |
OLD | NEW |