| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend | 5 /// This file declares a "shadow hierarchy" of concrete classes which extend |
| 6 /// the kernel class hierarchy, adding methods and fields needed by the | 6 /// the kernel class hierarchy, adding methods and fields needed by the |
| 7 /// BodyBuilder. | 7 /// BodyBuilder. |
| 8 /// | 8 /// |
| 9 /// Instances of these classes may be created using the factory methods in | 9 /// Instances of these classes may be created using the factory methods in |
| 10 /// `ast_factory.dart`. | 10 /// `ast_factory.dart`. |
| (...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 | 2184 |
| 2185 @override | 2185 @override |
| 2186 DartType inferFieldTopLevel( | 2186 DartType inferFieldTopLevel( |
| 2187 KernelField field, DartType type, bool typeNeeded) { | 2187 KernelField field, DartType type, bool typeNeeded) { |
| 2188 if (field.initializer == null) return const DynamicType(); | 2188 if (field.initializer == null) return const DynamicType(); |
| 2189 return inferExpression(field.initializer, type, typeNeeded); | 2189 return inferExpression(field.initializer, type, typeNeeded); |
| 2190 } | 2190 } |
| 2191 | 2191 |
| 2192 @override | 2192 @override |
| 2193 void inferInitializer(Initializer initializer) { | 2193 void inferInitializer(Initializer initializer) { |
| 2194 if (initializer is KernelInitializer) { | 2194 assert(initializer is KernelInitializer); |
| 2195 // Use polymorphic dispatch on [KernelInitializer] to perform whatever | 2195 // Use polymorphic dispatch on [KernelInitializer] to perform whatever |
| 2196 // kind of type inference is correct for this kind of initializer. | 2196 // kind of type inference is correct for this kind of initializer. |
| 2197 // TODO(paulberry): experiment to see if dynamic dispatch would be better, | 2197 // TODO(paulberry): experiment to see if dynamic dispatch would be better, |
| 2198 // so that the type hierarchy will be simpler (which may speed up "is" | 2198 // so that the type hierarchy will be simpler (which may speed up "is" |
| 2199 // checks). | 2199 // checks). |
| 2200 return initializer._inferInitializer(this); | 2200 KernelInitializer kernelInitializer = initializer; |
| 2201 } else { | 2201 return kernelInitializer._inferInitializer(this); |
| 2202 // Encountered an initializer type for which type inference is not yet | |
| 2203 // implemented, so just skip it for now. | |
| 2204 // TODO(paulberry): once the BodyBuilder uses shadow classes for | |
| 2205 // everything, this case should no longer be needed. | |
| 2206 } | |
| 2207 } | 2202 } |
| 2208 | 2203 |
| 2209 @override | 2204 @override |
| 2210 void inferStatement(Statement statement) { | 2205 void inferStatement(Statement statement) { |
| 2211 if (statement is KernelStatement) { | 2206 if (statement is KernelStatement) { |
| 2212 // Use polymorphic dispatch on [KernelStatement] to perform whatever kind | 2207 // Use polymorphic dispatch on [KernelStatement] to perform whatever kind |
| 2213 // of type inference is correct for this kind of statement. | 2208 // of type inference is correct for this kind of statement. |
| 2214 // TODO(paulberry): experiment to see if dynamic dispatch would be better, | 2209 // TODO(paulberry): experiment to see if dynamic dispatch would be better, |
| 2215 // so that the type hierarchy will be simpler (which may speed up "is" | 2210 // so that the type hierarchy will be simpler (which may speed up "is" |
| 2216 // checks). | 2211 // checks). |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 accept(v) => unsupported("accept", -1, null); | 2470 accept(v) => unsupported("accept", -1, null); |
| 2476 | 2471 |
| 2477 accept1(v, arg) => unsupported("accept1", -1, null); | 2472 accept1(v, arg) => unsupported("accept1", -1, null); |
| 2478 | 2473 |
| 2479 getStaticType(types) => unsupported("getStaticType", -1, null); | 2474 getStaticType(types) => unsupported("getStaticType", -1, null); |
| 2480 | 2475 |
| 2481 transformChildren(v) => unsupported("transformChildren", -1, null); | 2476 transformChildren(v) => unsupported("transformChildren", -1, null); |
| 2482 | 2477 |
| 2483 visitChildren(v) => unsupported("visitChildren", -1, null); | 2478 visitChildren(v) => unsupported("visitChildren", -1, null); |
| 2484 } | 2479 } |
| OLD | NEW |