OLD | NEW |
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 #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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Traverses all pending, unfinalized classes, validates and marks them as | 26 // Traverses all pending, unfinalized classes, validates and marks them as |
27 // finalized. | 27 // finalized. |
28 class ClassFinalizer : public AllStatic { | 28 class ClassFinalizer : public AllStatic { |
29 public: | 29 public: |
30 // Modes for type resolution and finalization. The ordering is relevant. | 30 // Modes for type resolution and finalization. The ordering is relevant. |
31 enum FinalizationKind { | 31 enum FinalizationKind { |
32 kIgnore, // Type is ignored and replaced by dynamic. | 32 kIgnore, // Type is ignored and replaced by dynamic. |
33 kDoNotResolve, // Type resolution is postponed. | 33 kDoNotResolve, // Type resolution is postponed. |
34 kTryResolve, // Type resolution is attempted. | 34 kTryResolve, // Type resolution is attempted. |
35 kFinalize, // Type resolution and type finalization are | 35 kFinalize, // Type resolution and type finalization are |
36 // required; a malformed type is tolerated. | 36 // required; a malformed type is tolerated, since |
| 37 // the type may be used as a type annotation. |
37 kCanonicalize, // Same as kFinalize, but with canonicalization. | 38 kCanonicalize, // Same as kFinalize, but with canonicalization. |
38 kCanonicalizeForCreation, // Same as kCanonicalize, but do not tolerate | 39 kCanonicalizeExpression, // Same as kCanonicalize, but do not tolerate |
39 // wrong number of type arguments. | 40 // wrong number of type arguments or ambiguous |
| 41 // type reference, since the type is not used as |
| 42 // a type annotation, but as a type expression. |
40 kCanonicalizeWellFormed // Error-free resolution, finalization, and | 43 kCanonicalizeWellFormed // Error-free resolution, finalization, and |
41 // canonicalization are required; a malformed | 44 // canonicalization are required; a malformed |
42 // type is not tolerated. | 45 // type is not tolerated. |
43 }; | 46 }; |
44 | 47 |
45 // Finalize given type while parsing class cls. | 48 // Finalize given type while parsing class cls. |
46 // Also canonicalize type if applicable. | 49 // Also canonicalize type if applicable. |
47 static RawAbstractType* FinalizeType(const Class& cls, | 50 static RawAbstractType* FinalizeType(const Class& cls, |
48 const AbstractType& type, | 51 const AbstractType& type, |
49 FinalizationKind finalization); | 52 FinalizationKind finalization); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 static void ReportError(const Error& error); | 126 static void ReportError(const Error& error); |
124 static void ReportError(const Script& script, | 127 static void ReportError(const Script& script, |
125 intptr_t token_index, | 128 intptr_t token_index, |
126 const char* format, ...) PRINTF_ATTRIBUTE(3, 4); | 129 const char* format, ...) PRINTF_ATTRIBUTE(3, 4); |
127 static void ReportError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); | 130 static void ReportError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); |
128 }; | 131 }; |
129 | 132 |
130 } // namespace dart | 133 } // namespace dart |
131 | 134 |
132 #endif // VM_CLASS_FINALIZER_H_ | 135 #endif // VM_CLASS_FINALIZER_H_ |
OLD | NEW |