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

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

Issue 8506001: Finalize all classes (fix issue 364). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 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 | « no previous file | runtime/vm/class_finalizer.cc » ('j') | runtime/vm/class_finalizer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #ifndef VM_CLASS_FINALIZER_H_ 5 #ifndef VM_CLASS_FINALIZER_H_
6 #define VM_CLASS_FINALIZER_H_ 6 #define VM_CLASS_FINALIZER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 class Class; 13 class Class;
14 class Function; 14 class Function;
15 class RawClass;
15 class RawType; 16 class RawType;
16 class Script; 17 class Script;
17 class String; 18 class String;
18 class Type; 19 class Type;
19 class TypeArguments; 20 class TypeArguments;
21 class UnresolvedClass;
20 22
21 // Traverses all pending, unfinalized classes, validates and marks them as 23 // Traverses all pending, unfinalized classes, validates and marks them as
22 // finalized. 24 // finalized.
23 class ClassFinalizer : public AllStatic { 25 class ClassFinalizer : public AllStatic {
24 public: 26 public:
25 // Add 'interface' to 'interface_list' if it is not already in the list and 27 // Add 'interface' to 'interface_list' if it is not already in the list and
26 // return true. Also return true if 'interface' is not added, because it is 28 // return true. Also return true if 'interface' is not added, because it is
27 // not unique, i.e. it is already in the list. 29 // not unique, i.e. it is already in the list.
28 // Return false if 'interface' conflicts with an interface already in the list 30 // Return false if 'interface' conflicts with an interface already in the list
29 // with the same class, but different type arguments. 31 // with the same class, but different type arguments.
30 // In the case of a conflict, set 'conflicting' to the existing interface. 32 // In the case of a conflict, set 'conflicting' to the existing interface.
31 static bool AddInterfaceIfUnique(GrowableArray<Type*>* interface_list, 33 static bool AddInterfaceIfUnique(GrowableArray<Type*>* interface_list,
32 Type* interface, 34 Type* interface,
33 Type* conflicting); 35 Type* conflicting);
34 36
35 // Finalize and canonicalize type while parsing. 37 // Finalize and canonicalize type while parsing.
36 // Set the error message on failure (to String::null() if no error). 38 // Set the error message on failure (to String::null() if no error).
37 static RawType* FinalizeAndCanonicalizeType(const Type& type, String* errmsg); 39 static RawType* FinalizeAndCanonicalizeType(const Type& type, String* errmsg);
38 40
41 // Notify finalizer to expect classes to be finalized.
srdjan 2011/11/09 21:22:43 Maybe add somewhere the comment that we are flaggi
regis 2011/11/09 23:31:01 Done.
42 static void ExpectPendingClasses();
43
39 // Pending classes are classes that need to be finalized. 44 // Pending classes are classes that need to be finalized.
45 // ExpectPendingClasses() must be called prior to AddPendingClasses().
40 static void AddPendingClasses(const GrowableArray<const Class*>& classes); 46 static void AddPendingClasses(const GrowableArray<const Class*>& classes);
41 47
42 // Return false if we still have classes pending to be finalized. 48 // Return false if we still have classes pending to be finalized or if we were
49 // notified to expect some.
43 static bool AllClassesFinalized(); 50 static bool AllClassesFinalized();
44 51
45 // Return whether class finalization failed. 52 // Return whether class finalization failed.
46 // The function returns true if the finalization was successful. 53 // The function returns true if the finalization was successful.
47 // If finalization fails, an error message is set in the sticky error field 54 // If finalization fails, an error message is set in the sticky error field
48 // in the object store. 55 // in the object store.
49 static bool FinalizePendingClasses(); 56 static bool FinalizePendingClasses();
50 57
51 // Verify that the pending classes have been properly prefinalized. This is 58 // Verify that the pending classes have been properly prefinalized. This is
52 // needed during bootstrapping where the classes have been preloaded. 59 // needed during bootstrapping where the classes have been preloaded.
53 static void VerifyBootstrapClasses(); 60 static void VerifyBootstrapClasses();
54 61
55 private: 62 private:
56 static void FinalizeClass(const Class& cls); 63 static void FinalizeClass(const Class& cls);
57 static bool IsSuperCycleFree(const Class& cls); 64 static bool IsSuperCycleFree(const Class& cls);
58 static void CheckForLegalConstClass(const Class& cls); 65 static void CheckForLegalConstClass(const Class& cls);
66 static RawClass* ResolveClass(const Class& cls,
67 const UnresolvedClass& unresolved_class);
59 static void ResolveSuperClass(const Class& cls); 68 static void ResolveSuperClass(const Class& cls);
60 static void ResolveDefaultClass(const Class& cls); 69 static void ResolveDefaultClass(const Class& cls);
61 static void ResolveInterfaces(const Class& cls, 70 static void ResolveInterfaces(const Class& cls,
62 GrowableArray<const Class*>* visited); 71 GrowableArray<const Class*>* visited);
63 static void FinalizeTypeArguments(const Class& cls, 72 static void FinalizeTypeArguments(const Class& cls,
64 const TypeArguments& arguments); 73 const TypeArguments& arguments);
65 static RawType* ResolveType(const Class& cls, const Type& type); 74 static RawType* ResolveType(const Class& cls, const Type& type);
66 static RawType* FinalizeType(const Type& type); 75 static RawType* FinalizeType(const Type& type);
76 static void ResolveAndFinalizeUpperBounds(const Class& cls);
67 static void ResolveAndFinalizeSignature(const Class& cls, 77 static void ResolveAndFinalizeSignature(const Class& cls,
68 const Function& function); 78 const Function& function);
69 static void ResolveAndFinalizeMemberTypes(const Class& cls); 79 static void ResolveAndFinalizeMemberTypes(const Class& cls);
70 static void PrintClassInformation(const Class& cls); 80 static void PrintClassInformation(const Class& cls);
71 static void VerifyClassImplements(const Class& cls); 81 static void VerifyClassImplements(const Class& cls);
72 static void CollectInterfaces(const Class& cls, 82 static void CollectInterfaces(const Class& cls,
73 GrowableArray<const Class*>* interfaces); 83 GrowableArray<const Class*>* interfaces);
74 static void ReportError(const Script& script, 84 static void ReportError(const Script& script,
75 intptr_t token_index, 85 intptr_t token_index,
76 const char* format, ...); 86 const char* format, ...);
77 static void ReportError(const char* format, ...); 87 static void ReportError(const char* format, ...);
78 }; 88 };
79 89
80 } // namespace dart 90 } // namespace dart
81 91
82 #endif // VM_CLASS_FINALIZER_H_ 92 #endif // VM_CLASS_FINALIZER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/class_finalizer.cc » ('j') | runtime/vm/class_finalizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698