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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 Function& function = Function::Handle(I); | 1413 Function& function = Function::Handle(I); |
1414 Function& overridden_function = Function::Handle(I); | 1414 Function& overridden_function = Function::Handle(I); |
1415 const intptr_t num_functions = array.Length(); | 1415 const intptr_t num_functions = array.Length(); |
1416 Error& error = Error::Handle(I); | 1416 Error& error = Error::Handle(I); |
1417 for (intptr_t i = 0; i < num_functions; i++) { | 1417 for (intptr_t i = 0; i < num_functions; i++) { |
1418 function ^= array.At(i); | 1418 function ^= array.At(i); |
1419 ResolveAndFinalizeSignature(cls, function); | 1419 ResolveAndFinalizeSignature(cls, function); |
1420 name = function.name(); | 1420 name = function.name(); |
1421 // Report signature conflicts only. | 1421 // Report signature conflicts only. |
1422 if (Isolate::Current()->ErrorOnBadOverrideEnabled() && | 1422 if (Isolate::Current()->ErrorOnBadOverrideEnabled() && |
1423 !function.is_static() && !function.IsConstructor()) { | 1423 !function.is_static() && !function.IsGenerativeConstructor()) { |
1424 // A constructor cannot override anything. | 1424 // A constructor cannot override anything. |
1425 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 1425 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
1426 super_class ^= interfaces.At(i); | 1426 super_class ^= interfaces.At(i); |
1427 // Finalize superclass since overrides check relies on all members | 1427 // Finalize superclass since overrides check relies on all members |
1428 // of the superclass to be finalized. | 1428 // of the superclass to be finalized. |
1429 FinalizeClass(super_class); | 1429 FinalizeClass(super_class); |
1430 overridden_function = super_class.LookupDynamicFunction(name); | 1430 overridden_function = super_class.LookupDynamicFunction(name); |
1431 if (!overridden_function.IsNull() && | 1431 if (!overridden_function.IsNull() && |
1432 !function.HasCompatibleParametersWith(overridden_function, | 1432 !function.HasCompatibleParametersWith(overridden_function, |
1433 &error)) { | 1433 &error)) { |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 const GrowableObjectArray& cloned_funcs) { | 2037 const GrowableObjectArray& cloned_funcs) { |
2038 const String& mixin_name = String::Handle(mixin_app.Name()); | 2038 const String& mixin_name = String::Handle(mixin_app.Name()); |
2039 const Class& super_class = Class::Handle(mixin_app.SuperClass()); | 2039 const Class& super_class = Class::Handle(mixin_app.SuperClass()); |
2040 const String& super_name = String::Handle(super_class.Name()); | 2040 const String& super_name = String::Handle(super_class.Name()); |
2041 const Type& dynamic_type = Type::Handle(Type::DynamicType()); | 2041 const Type& dynamic_type = Type::Handle(Type::DynamicType()); |
2042 const Array& functions = Array::Handle(super_class.functions()); | 2042 const Array& functions = Array::Handle(super_class.functions()); |
2043 const intptr_t num_functions = functions.Length(); | 2043 const intptr_t num_functions = functions.Length(); |
2044 Function& func = Function::Handle(); | 2044 Function& func = Function::Handle(); |
2045 for (intptr_t i = 0; i < num_functions; i++) { | 2045 for (intptr_t i = 0; i < num_functions; i++) { |
2046 func ^= functions.At(i); | 2046 func ^= functions.At(i); |
2047 if (func.IsConstructor()) { | 2047 if (func.IsGenerativeConstructor()) { |
2048 // Build constructor name from mixin application class name | 2048 // Build constructor name from mixin application class name |
2049 // and name of cloned super class constructor. | 2049 // and name of cloned super class constructor. |
2050 const String& ctor_name = String::Handle(func.name()); | 2050 const String& ctor_name = String::Handle(func.name()); |
2051 String& clone_name = String::Handle( | 2051 String& clone_name = String::Handle( |
2052 String::SubString(ctor_name, super_name.Length())); | 2052 String::SubString(ctor_name, super_name.Length())); |
2053 clone_name = String::Concat(mixin_name, clone_name); | 2053 clone_name = String::Concat(mixin_name, clone_name); |
2054 clone_name = Symbols::New(clone_name); | 2054 clone_name = Symbols::New(clone_name); |
2055 | 2055 |
2056 if (FLAG_trace_class_finalization) { | 2056 if (FLAG_trace_class_finalization) { |
2057 OS::Print("Cloning constructor '%s' as '%s'\n", | 2057 OS::Print("Cloning constructor '%s' as '%s'\n", |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 | 2123 |
2124 Array& functions = Array::Handle(isolate); | 2124 Array& functions = Array::Handle(isolate); |
2125 Function& func = Function::Handle(isolate); | 2125 Function& func = Function::Handle(isolate); |
2126 // The parser creates the mixin application class with no functions. | 2126 // The parser creates the mixin application class with no functions. |
2127 ASSERT((functions = cls.functions(), functions.Length() == 0)); | 2127 ASSERT((functions = cls.functions(), functions.Length() == 0)); |
2128 // Now clone the functions from the mixin class. | 2128 // Now clone the functions from the mixin class. |
2129 functions = mixin_cls.functions(); | 2129 functions = mixin_cls.functions(); |
2130 const intptr_t num_functions = functions.Length(); | 2130 const intptr_t num_functions = functions.Length(); |
2131 for (intptr_t i = 0; i < num_functions; i++) { | 2131 for (intptr_t i = 0; i < num_functions; i++) { |
2132 func ^= functions.At(i); | 2132 func ^= functions.At(i); |
2133 if (func.IsConstructor()) { | 2133 if (func.IsGenerativeConstructor()) { |
2134 // A mixin class must not have explicit constructors. | 2134 // A mixin class must not have explicit constructors. |
2135 if (!func.IsImplicitConstructor()) { | 2135 if (!func.IsImplicitConstructor()) { |
2136 ReportError(cls, cls.token_pos(), | 2136 ReportError(cls, cls.token_pos(), |
2137 "mixin class '%s' must not have constructors\n", | 2137 "mixin class '%s' must not have constructors\n", |
2138 String::Handle(isolate, mixin_cls.Name()).ToCString()); | 2138 String::Handle(isolate, mixin_cls.Name()).ToCString()); |
2139 } | 2139 } |
2140 continue; // Skip the implicit constructor. | 2140 continue; // Skip the implicit constructor. |
2141 } | 2141 } |
2142 if (!func.is_static() && | 2142 if (!func.is_static() && |
2143 !func.IsMethodExtractor() && | 2143 !func.IsMethodExtractor() && |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3160 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3161 field ^= fields_array.At(0); | 3161 field ^= fields_array.At(0); |
3162 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3162 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3163 name ^= field.name(); | 3163 name ^= field.name(); |
3164 expected_name ^= String::New("_data"); | 3164 expected_name ^= String::New("_data"); |
3165 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3165 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3166 #endif | 3166 #endif |
3167 } | 3167 } |
3168 | 3168 |
3169 } // namespace dart | 3169 } // namespace dart |
OLD | NEW |