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

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

Issue 49853004: Implement stricter rule about self referencing typedefs (fix issue 13675). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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/vm/class_finalizer.cc ('k') | runtime/vm/parser.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 result.set_type_arguments_field_offset(Closure::type_arguments_offset()); 2409 result.set_type_arguments_field_offset(Closure::type_arguments_offset());
2410 if (!signature_function.IsNull()) { 2410 if (!signature_function.IsNull()) {
2411 result.PatchSignatureFunction(signature_function); 2411 result.PatchSignatureFunction(signature_function);
2412 } 2412 }
2413 return result.raw(); 2413 return result.raw();
2414 } 2414 }
2415 2415
2416 2416
2417 void Class::PatchSignatureFunction(const Function& signature_function) const { 2417 void Class::PatchSignatureFunction(const Function& signature_function) const {
2418 ASSERT(!signature_function.IsNull()); 2418 ASSERT(!signature_function.IsNull());
2419 set_signature_function(signature_function);
2419 const Class& owner_class = Class::Handle(signature_function.Owner()); 2420 const Class& owner_class = Class::Handle(signature_function.Owner());
2420 ASSERT(!owner_class.IsNull()); 2421 ASSERT(!owner_class.IsNull());
2421 TypeArguments& type_parameters = TypeArguments::Handle(); 2422 // A signature class extends class Instance and is either not parameterized or
2422 // A signature class extends class Instance and is parameterized in the same 2423 // parameterized with exactly the same list of type parameters as the owner
2423 // way as the owner class of its non-static signature function. 2424 // class of its function.
2424 // It is not type parameterized if its signature function is static. 2425 // In case of a function type alias, the function owner is the alias class,
2425 // In case of a function type alias, the function owner is the alias class 2426 // which is also the signature class. The signature class is therefore
2426 // instead of the enclosing class. 2427 // parameterized according to the alias class declaration, even if the
2427 if (!signature_function.is_static() && 2428 // function type is not generic.
2428 (owner_class.NumTypeParameters() > 0) && 2429 // Otherwise, if the function is static or if its signature type is
2429 !signature_function.HasInstantiatedSignature()) { 2430 // non-generic, i.e. it does not depend on any type parameter of the owner
2430 type_parameters = owner_class.type_parameters(); 2431 // class, then the signature class is not parameterized, although the owner
2431 } 2432 // class may be.
2432 set_signature_function(signature_function);
2433 set_type_parameters(type_parameters);
2434 if (owner_class.raw() == raw()) { 2433 if (owner_class.raw() == raw()) {
2435 // This signature class is an alias, which cannot be the canonical 2434 // This signature class is an alias, which cannot be the canonical
2436 // signature class for this signature function. 2435 // signature class for this signature function.
2437 ASSERT(!IsCanonicalSignatureClass()); 2436 ASSERT(!IsCanonicalSignatureClass());
2438 } else if (signature_function.signature_class() == Object::null()) { 2437 // Do not modify the declared type parameters of the alias, even if unused.
2439 // Make this signature class the canonical signature class. 2438 } else {
2440 signature_function.set_signature_class(*this); 2439 // Copy the type parameters only for an instance function type that is not
2441 ASSERT(IsCanonicalSignatureClass()); 2440 // instantiated, i.e. that depends on the type parameters of the owner
2441 // class.
2442 // TODO(regis): Verify that it is not a problem for the copied type
2443 // parameters to refer to the owner class rather than to the signature
2444 // class. In other words, uninstantiated function types should only get
2445 // instantiated by the owner class as instantiator and never by the
2446 // signature class itself.
2447 TypeArguments& type_parameters = TypeArguments::Handle();
2448 if (!signature_function.is_static() &&
2449 (owner_class.NumTypeParameters() > 0) &&
2450 !signature_function.HasInstantiatedSignature()) {
2451 type_parameters = owner_class.type_parameters();
2452 }
2453 set_type_parameters(type_parameters);
2454 if (signature_function.signature_class() == Object::null()) {
2455 // Make this signature class the canonical signature class.
2456 signature_function.set_signature_class(*this);
2457 ASSERT(IsCanonicalSignatureClass());
2458 }
2442 } 2459 }
2443 set_is_prefinalized(); 2460 set_is_prefinalized();
2444 } 2461 }
2445 2462
2446 2463
2447 RawClass* Class::NewNativeWrapper(const Library& library, 2464 RawClass* Class::NewNativeWrapper(const Library& library,
2448 const String& name, 2465 const String& name,
2449 int field_count) { 2466 int field_count) {
2450 Class& cls = Class::Handle(library.LookupClass(name)); 2467 Class& cls = Class::Handle(library.LookupClass(name));
2451 if (cls.IsNull()) { 2468 if (cls.IsNull()) {
(...skipping 13132 matching lines...) Expand 10 before | Expand all | Expand 10 after
15584 return "_MirrorReference"; 15601 return "_MirrorReference";
15585 } 15602 }
15586 15603
15587 15604
15588 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15605 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15589 JSONObject jsobj(stream); 15606 JSONObject jsobj(stream);
15590 } 15607 }
15591 15608
15592 15609
15593 } // namespace dart 15610 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698