Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: runtime/vm/class_finalizer.cc

Issue 212883009: Handle creating ParameterMirrors for the parameters of forwarding constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 type_argument = arguments.TypeAt(i); 484 type_argument = arguments.TypeAt(i);
485 ResolveType(cls, type_argument); 485 ResolveType(cls, type_argument);
486 } 486 }
487 } 487 }
488 } 488 }
489 489
490 490
491 void ClassFinalizer::FinalizeTypeParameters( 491 void ClassFinalizer::FinalizeTypeParameters(
492 const Class& cls, 492 const Class& cls,
493 GrowableObjectArray* pending_types) { 493 GrowableObjectArray* pending_types) {
494 if (cls.IsMixinApplication()) { 494 if (cls.IsAnonymousMixinApplication()) {
495 // Setup the type parameters of the mixin application and finalize the 495 // Setup the type parameters of the mixin application and finalize the
496 // mixin type. 496 // mixin type.
497 ApplyMixinType(cls, pending_types); 497 ApplyMixinType(cls, pending_types);
498 } 498 }
499 // The type parameter bounds are not finalized here. 499 // The type parameter bounds are not finalized here.
500 const TypeArguments& type_parameters = 500 const TypeArguments& type_parameters =
501 TypeArguments::Handle(cls.type_parameters()); 501 TypeArguments::Handle(cls.type_parameters());
502 if (!type_parameters.IsNull()) { 502 if (!type_parameters.IsNull()) {
503 TypeParameter& type_parameter = TypeParameter::Handle(); 503 TypeParameter& type_parameter = TypeParameter::Handle();
504 const intptr_t num_types = type_parameters.Length(); 504 const intptr_t num_types = type_parameters.Length();
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 // The appended type arguments are those of the super type of the mixin 1701 // The appended type arguments are those of the super type of the mixin
1702 // application alias that are forwarding to the aliased mixin type, except 1702 // application alias that are forwarding to the aliased mixin type, except
1703 // that they must refer to the type parameters of the mixin application 1703 // that they must refer to the type parameters of the mixin application
1704 // class rather than to those of the mixin application alias class. 1704 // class rather than to those of the mixin application alias class.
1705 // This type parameter substitution is performed by an instantiation step. 1705 // This type parameter substitution is performed by an instantiation step.
1706 // It is important that the type parameters of the mixin application class 1706 // It is important that the type parameters of the mixin application class
1707 // are not finalized yet, because new type parameters may have been added 1707 // are not finalized yet, because new type parameters may have been added
1708 // to the super class. 1708 // to the super class.
1709 Class& super_class = Class::Handle(isolate, super_type.type_class()); 1709 Class& super_class = Class::Handle(isolate, super_type.type_class());
1710 ASSERT(mixin_app_class.SuperClass() == super_class.raw()); 1710 ASSERT(mixin_app_class.SuperClass() == super_class.raw());
1711 while (super_class.IsMixinApplication()) { 1711 while (super_class.IsAnonymousMixinApplication()) {
rmacnak 2014/03/27 01:36:07 Do we have tests where the superclass is another m
1712 super_class = super_class.SuperClass(); 1712 super_class = super_class.SuperClass();
1713 } 1713 }
1714 const intptr_t num_super_type_params = super_class.NumTypeParameters(); 1714 const intptr_t num_super_type_params = super_class.NumTypeParameters();
1715 const intptr_t num_mixin_type_params = mixin_class.NumTypeParameters(); 1715 const intptr_t num_mixin_type_params = mixin_class.NumTypeParameters();
1716 intptr_t offset = 1716 intptr_t offset =
1717 mixin_class.NumTypeArguments() - mixin_class.NumTypeParameters(); 1717 mixin_class.NumTypeArguments() - mixin_class.NumTypeParameters();
1718 const TypeArguments& type_params = 1718 const TypeArguments& type_params =
1719 TypeArguments::Handle(isolate, mixin_app_class.type_parameters()); 1719 TypeArguments::Handle(isolate, mixin_app_class.type_parameters());
1720 TypeArguments& instantiator = TypeArguments::Handle(isolate, 1720 TypeArguments& instantiator = TypeArguments::Handle(isolate,
1721 TypeArguments::New(offset + num_mixin_type_params)); 1721 TypeArguments::New(offset + num_mixin_type_params));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 // The cloned ctor shares the parameter names array with the 1938 // The cloned ctor shares the parameter names array with the
1939 // original. 1939 // original.
1940 const Array& parameter_names = Array::Handle(func.parameter_names()); 1940 const Array& parameter_names = Array::Handle(func.parameter_names());
1941 ASSERT(parameter_names.Length() == num_parameters); 1941 ASSERT(parameter_names.Length() == num_parameters);
1942 clone.set_parameter_names(parameter_names); 1942 clone.set_parameter_names(parameter_names);
1943 // The parameter types of the cloned constructor are 'dynamic'. 1943 // The parameter types of the cloned constructor are 'dynamic'.
1944 clone.set_parameter_types(Array::Handle(Array::New(num_parameters))); 1944 clone.set_parameter_types(Array::Handle(Array::New(num_parameters)));
1945 for (intptr_t n = 0; n < num_parameters; n++) { 1945 for (intptr_t n = 0; n < num_parameters; n++) {
1946 clone.SetParameterTypeAt(n, dynamic_type); 1946 clone.SetParameterTypeAt(n, dynamic_type);
1947 } 1947 }
1948 clone.SetForwardingTarget(func);
1948 cloned_funcs.Add(clone); 1949 cloned_funcs.Add(clone);
1949 } 1950 }
1950 } 1951 }
1951 } 1952 }
1952 1953
1953 1954
1954 void ClassFinalizer::ApplyMixinMembers(const Class& cls) { 1955 void ClassFinalizer::ApplyMixinMembers(const Class& cls) {
1955 Isolate* isolate = Isolate::Current(); 1956 Isolate* isolate = Isolate::Current();
1956 const Type& mixin_type = Type::Handle(isolate, cls.mixin()); 1957 const Type& mixin_type = Type::Handle(isolate, cls.mixin());
1957 ASSERT(!mixin_type.IsNull()); 1958 ASSERT(!mixin_type.IsNull());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 2162
2162 2163
2163 void ClassFinalizer::FinalizeClass(const Class& cls) { 2164 void ClassFinalizer::FinalizeClass(const Class& cls) {
2164 HANDLESCOPE(Isolate::Current()); 2165 HANDLESCOPE(Isolate::Current());
2165 if (cls.is_finalized()) { 2166 if (cls.is_finalized()) {
2166 return; 2167 return;
2167 } 2168 }
2168 if (FLAG_trace_class_finalization) { 2169 if (FLAG_trace_class_finalization) {
2169 OS::Print("Finalize %s\n", cls.ToCString()); 2170 OS::Print("Finalize %s\n", cls.ToCString());
2170 } 2171 }
2171 if (cls.IsMixinApplication()) { 2172 if (cls.IsAnonymousMixinApplication()) {
2172 // Copy instance methods and fields from the mixin class. 2173 // Copy instance methods and fields from the mixin class.
2173 // This has to happen before the check whether the methods of 2174 // This has to happen before the check whether the methods of
2174 // the class conflict with inherited methods. 2175 // the class conflict with inherited methods.
2175 ApplyMixinMembers(cls); 2176 ApplyMixinMembers(cls);
2176 } 2177 }
2177 GrowableArray<intptr_t> added_subclass_to_cids; 2178 GrowableArray<intptr_t> added_subclass_to_cids;
2178 CollectFinalizedSuperClasses(cls, &added_subclass_to_cids); 2179 CollectFinalizedSuperClasses(cls, &added_subclass_to_cids);
2179 // Ensure super class is finalized. 2180 // Ensure super class is finalized.
2180 const Class& super = Class::Handle(cls.SuperClass()); 2181 const Class& super = Class::Handle(cls.SuperClass());
2181 if (!super.IsNull()) { 2182 if (!super.IsNull()) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 if ((*visited)[i] == cls_index) { 2321 if ((*visited)[i] == cls_index) {
2321 // We have already visited mixin 'cls'. We found a cycle. 2322 // We have already visited mixin 'cls'. We found a cycle.
2322 return false; 2323 return false;
2323 } 2324 }
2324 } 2325 }
2325 2326
2326 // Visit the super chain of cls. 2327 // Visit the super chain of cls.
2327 visited->Add(cls.id()); 2328 visited->Add(cls.id());
2328 Class& super_class = Class::Handle(cls.raw()); 2329 Class& super_class = Class::Handle(cls.raw());
2329 do { 2330 do {
2330 if (super_class.IsMixinApplication()) { 2331 if (super_class.IsAnonymousMixinApplication()) {
2331 const Type& mixin_type = Type::Handle(super_class.mixin()); 2332 const Type& mixin_type = Type::Handle(super_class.mixin());
2332 ASSERT(!mixin_type.IsNull()); 2333 ASSERT(!mixin_type.IsNull());
2333 ASSERT(mixin_type.HasResolvedTypeClass()); 2334 ASSERT(mixin_type.HasResolvedTypeClass());
2334 const Class& mixin_class = Class::Handle(mixin_type.type_class()); 2335 const Class& mixin_class = Class::Handle(mixin_type.type_class());
2335 if (!IsMixinCycleFree(mixin_class, visited)) { 2336 if (!IsMixinCycleFree(mixin_class, visited)) {
2336 return false; 2337 return false;
2337 } 2338 }
2338 } 2339 }
2339 super_class = super_class.SuperClass(); 2340 super_class = super_class.SuperClass();
2340 } while (!super_class.IsNull()); 2341 } while (!super_class.IsNull());
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 expected_name ^= String::New("_offset"); 2932 expected_name ^= String::New("_offset");
2932 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2933 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2933 field ^= fields_array.At(2); 2934 field ^= fields_array.At(2);
2934 ASSERT(field.Offset() == TypedDataView::length_offset()); 2935 ASSERT(field.Offset() == TypedDataView::length_offset());
2935 name ^= field.name(); 2936 name ^= field.name();
2936 ASSERT(name.Equals("length")); 2937 ASSERT(name.Equals("length"));
2937 #endif 2938 #endif
2938 } 2939 }
2939 2940
2940 } // namespace dart 2941 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698