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 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 mixin_app_class.set_mixin(mixin_type); | 2065 mixin_app_class.set_mixin(mixin_type); |
2066 } | 2066 } |
2067 | 2067 |
2068 | 2068 |
2069 void ClassFinalizer::CreateForwardingConstructors( | 2069 void ClassFinalizer::CreateForwardingConstructors( |
2070 const Class& mixin_app, | 2070 const Class& mixin_app, |
2071 const GrowableObjectArray& cloned_funcs) { | 2071 const GrowableObjectArray& cloned_funcs) { |
2072 const String& mixin_name = String::Handle(mixin_app.Name()); | 2072 const String& mixin_name = String::Handle(mixin_app.Name()); |
2073 const Class& super_class = Class::Handle(mixin_app.SuperClass()); | 2073 const Class& super_class = Class::Handle(mixin_app.SuperClass()); |
2074 const String& super_name = String::Handle(super_class.Name()); | 2074 const String& super_name = String::Handle(super_class.Name()); |
2075 const Type& dynamic_type = Type::Handle(Type::DynamicType()); | |
2076 const Array& functions = Array::Handle(super_class.functions()); | 2075 const Array& functions = Array::Handle(super_class.functions()); |
2077 const intptr_t num_functions = functions.Length(); | 2076 const intptr_t num_functions = functions.Length(); |
2078 Function& func = Function::Handle(); | 2077 Function& func = Function::Handle(); |
2079 for (intptr_t i = 0; i < num_functions; i++) { | 2078 for (intptr_t i = 0; i < num_functions; i++) { |
2080 func ^= functions.At(i); | 2079 func ^= functions.At(i); |
2081 if (func.IsGenerativeConstructor()) { | 2080 if (func.IsGenerativeConstructor()) { |
2082 // Build constructor name from mixin application class name | 2081 // Build constructor name from mixin application class name |
2083 // and name of cloned super class constructor. | 2082 // and name of cloned super class constructor. |
2084 const String& ctor_name = String::Handle(func.name()); | 2083 const String& ctor_name = String::Handle(func.name()); |
2085 String& clone_name = String::Handle( | 2084 String& clone_name = String::Handle( |
(...skipping 12 matching lines...) Expand all Loading... |
2098 false, // Not const. | 2097 false, // Not const. |
2099 false, // Not abstract. | 2098 false, // Not abstract. |
2100 false, // Not external. | 2099 false, // Not external. |
2101 false, // Not native. | 2100 false, // Not native. |
2102 mixin_app, | 2101 mixin_app, |
2103 mixin_app.token_pos())); | 2102 mixin_app.token_pos())); |
2104 | 2103 |
2105 clone.set_num_fixed_parameters(func.num_fixed_parameters()); | 2104 clone.set_num_fixed_parameters(func.num_fixed_parameters()); |
2106 clone.SetNumOptionalParameters(func.NumOptionalParameters(), | 2105 clone.SetNumOptionalParameters(func.NumOptionalParameters(), |
2107 func.HasOptionalPositionalParameters()); | 2106 func.HasOptionalPositionalParameters()); |
2108 clone.set_result_type(dynamic_type); | 2107 clone.set_result_type(Object::dynamic_type()); |
2109 clone.set_is_debuggable(false); | 2108 clone.set_is_debuggable(false); |
2110 | 2109 |
2111 const intptr_t num_parameters = func.NumParameters(); | 2110 const intptr_t num_parameters = func.NumParameters(); |
2112 // The cloned ctor shares the parameter names array with the | 2111 // The cloned ctor shares the parameter names array with the |
2113 // original. | 2112 // original. |
2114 const Array& parameter_names = Array::Handle(func.parameter_names()); | 2113 const Array& parameter_names = Array::Handle(func.parameter_names()); |
2115 ASSERT(parameter_names.Length() == num_parameters); | 2114 ASSERT(parameter_names.Length() == num_parameters); |
2116 clone.set_parameter_names(parameter_names); | 2115 clone.set_parameter_names(parameter_names); |
2117 // The parameter types of the cloned constructor are 'dynamic'. | 2116 // The parameter types of the cloned constructor are 'dynamic'. |
2118 clone.set_parameter_types(Array::Handle(Array::New(num_parameters))); | 2117 clone.set_parameter_types(Array::Handle(Array::New(num_parameters))); |
2119 for (intptr_t n = 0; n < num_parameters; n++) { | 2118 for (intptr_t n = 0; n < num_parameters; n++) { |
2120 clone.SetParameterTypeAt(n, dynamic_type); | 2119 clone.SetParameterTypeAt(n, Object::dynamic_type()); |
2121 } | 2120 } |
2122 cloned_funcs.Add(clone); | 2121 cloned_funcs.Add(clone); |
2123 } | 2122 } |
2124 } | 2123 } |
2125 } | 2124 } |
2126 | 2125 |
2127 | 2126 |
2128 void ClassFinalizer::ApplyMixinMembers(const Class& cls) { | 2127 void ClassFinalizer::ApplyMixinMembers(const Class& cls) { |
2129 Zone* zone = Thread::Current()->zone(); | 2128 Zone* zone = Thread::Current()->zone(); |
2130 const Type& mixin_type = Type::Handle(zone, cls.mixin()); | 2129 const Type& mixin_type = Type::Handle(zone, cls.mixin()); |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3204 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3203 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3205 field ^= fields_array.At(0); | 3204 field ^= fields_array.At(0); |
3206 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3205 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3207 name ^= field.name(); | 3206 name ^= field.name(); |
3208 expected_name ^= String::New("_data"); | 3207 expected_name ^= String::New("_data"); |
3209 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3208 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3210 #endif | 3209 #endif |
3211 } | 3210 } |
3212 | 3211 |
3213 } // namespace dart | 3212 } // namespace dart |
OLD | NEW |