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

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

Issue 8372041: Canonicalize types. (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') | 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) 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 RawString;
16 class RawType; 15 class RawType;
17 class Script; 16 class Script;
17 class String;
18 class Type; 18 class Type;
19 class TypeArguments; 19 class TypeArguments;
20 20
21 // Traverses all pending, unfinalized classes, validates and marks them as 21 // Traverses all pending, unfinalized classes, validates and marks them as
22 // finalized. 22 // finalized.
23 class ClassFinalizer : public AllStatic { 23 class ClassFinalizer : public AllStatic {
24 public: 24 public:
25 // Add 'interface' to 'interface_list' if it is not already in the list and 25 // 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 26 // return true. Also return true if 'interface' is not added, because it is
27 // not unique, i.e. it is already in the list. 27 // not unique, i.e. it is already in the list.
28 // Return false if 'interface' conflicts with an interface already in the list 28 // Return false if 'interface' conflicts with an interface already in the list
29 // with the same class, but different type arguments. 29 // with the same class, but different type arguments.
30 // In the case of a conflict, set 'conflicting' to the existing interface. 30 // In the case of a conflict, set 'conflicting' to the existing interface.
31 static bool AddInterfaceIfUnique(GrowableArray<Type*>* interface_list, 31 static bool AddInterfaceIfUnique(GrowableArray<Type*>* interface_list,
32 Type* interface, 32 Type* interface,
33 Type* conflicting); 33 Type* conflicting);
34 34
35 // Finalize type. Used for local variable types. 35 // Finalize and canonicalize type while parsing.
36 static void FinalizeType(const Type& type); 36 // Set the error message on failure (to String::null() if no error).
37 static RawString* FinalizeTypeWhileParsing(const Type& type); 37 static RawType* FinalizeAndCanonicalizeType(const Type& type, String* errmsg);
38 38
39 // Pending classes are classes that need to be finalized. 39 // Pending classes are classes that need to be finalized.
40 static void AddPendingClasses(const GrowableArray<const Class*>& classes); 40 static void AddPendingClasses(const GrowableArray<const Class*>& classes);
41 41
42 // Return false if we still have classes pending to be finalized. 42 // Return false if we still have classes pending to be finalized.
43 static bool AllClassesFinalized(); 43 static bool AllClassesFinalized();
44 44
45 // Return whether class finalization failed. 45 // Return whether class finalization failed.
46 // The function returns true if the finalization was successful. 46 // The function returns true if the finalization was successful.
47 // If finalization fails, an error message is set in the sticky error field 47 // If finalization fails, an error message is set in the sticky error field
48 // in the object store. 48 // in the object store.
49 static bool FinalizePendingClasses(); 49 static bool FinalizePendingClasses();
50 50
51 // Verify that the pending classes have been properly prefinalized. This is 51 // Verify that the pending classes have been properly prefinalized. This is
52 // needed during bootstrapping where the classes have been preloaded. 52 // needed during bootstrapping where the classes have been preloaded.
53 static void VerifyBootstrapClasses(); 53 static void VerifyBootstrapClasses();
54 54
55 private: 55 private:
56 static void FinalizeClass(const Class& cls); 56 static void FinalizeClass(const Class& cls);
57 static bool IsSuperCycleFree(const Class& cls); 57 static bool IsSuperCycleFree(const Class& cls);
58 static void CheckForLegalConstClass(const Class& cls); 58 static void CheckForLegalConstClass(const Class& cls);
59 static void ResolveSuperClass(const Class& cls); 59 static void ResolveSuperClass(const Class& cls);
60 static void ResolveDefaultClass(const Class& cls); 60 static void ResolveDefaultClass(const Class& cls);
61 static void ResolveInterfaces(const Class& cls, 61 static void ResolveInterfaces(const Class& cls,
62 GrowableArray<const Class*>* visited); 62 GrowableArray<const Class*>* visited);
63 static void FinalizeTypeArguments(const Class& cls, 63 static void FinalizeTypeArguments(const Class& cls,
64 const TypeArguments& arguments); 64 const TypeArguments& arguments);
65 static RawType* ResolveType(const Class& cls, const Type& type); 65 static RawType* ResolveType(const Class& cls, const Type& type);
66 static void FinalizeType(const Type& type);
66 static void ResolveAndFinalizeSignature(const Class& cls, 67 static void ResolveAndFinalizeSignature(const Class& cls,
67 const Function& function); 68 const Function& function);
68 static void ResolveAndFinalizeMemberTypes(const Class& cls); 69 static void ResolveAndFinalizeMemberTypes(const Class& cls);
69 static void PrintClassInformation(const Class& cls); 70 static void PrintClassInformation(const Class& cls);
70 static void VerifyClassImplements(const Class& cls); 71 static void VerifyClassImplements(const Class& cls);
71 static void CollectInterfaces(const Class& cls, 72 static void CollectInterfaces(const Class& cls,
72 GrowableArray<const Class*>* interfaces); 73 GrowableArray<const Class*>* interfaces);
73 static void ReportError(const Script& script, 74 static void ReportError(const Script& script,
74 intptr_t token_index, 75 intptr_t token_index,
75 const char* format, ...); 76 const char* format, ...);
76 static void ReportError(const char* format, ...); 77 static void ReportError(const char* format, ...);
77 }; 78 };
78 79
79 } // namespace dart 80 } // namespace dart
80 81
81 #endif // VM_CLASS_FINALIZER_H_ 82 #endif // VM_CLASS_FINALIZER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698