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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'package:front_end/src/base/instrumentation.dart'; | 5 import 'package:front_end/src/base/instrumentation.dart'; |
6 import 'package:front_end/src/fasta/problems.dart' show unhandled; | |
7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; | 6 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; |
8 import 'package:front_end/src/fasta/names.dart' show callName; | 7 import 'package:front_end/src/fasta/names.dart' show callName; |
| 8 import 'package:front_end/src/fasta/problems.dart' show unhandled; |
9 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; | 9 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; |
10 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; | 10 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; |
11 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; | 11 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; |
12 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; | 12 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; |
13 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; | 13 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; |
14 import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart'
; | 14 import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart'
; |
15 import 'package:kernel/ast.dart' | 15 import 'package:kernel/ast.dart' |
16 show | 16 show |
17 Arguments, | 17 Arguments, |
18 AsyncMarker, | 18 AsyncMarker, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 /// Keeps track of the local state for the type inference that occurs during | 196 /// Keeps track of the local state for the type inference that occurs during |
197 /// compilation of a single method body or top level initializer. | 197 /// compilation of a single method body or top level initializer. |
198 /// | 198 /// |
199 /// This class describes the interface for use by clients of type inference | 199 /// This class describes the interface for use by clients of type inference |
200 /// (e.g. BodyBuilder). Derived classes should derive from [TypeInferrerImpl]. | 200 /// (e.g. BodyBuilder). Derived classes should derive from [TypeInferrerImpl]. |
201 abstract class TypeInferrer { | 201 abstract class TypeInferrer { |
202 /// Gets the [TypePromoter] that can be used to perform type promotion within | 202 /// Gets the [TypePromoter] that can be used to perform type promotion within |
203 /// this method body or initializer. | 203 /// this method body or initializer. |
204 TypePromoter get typePromoter; | 204 TypePromoter get typePromoter; |
205 | 205 |
| 206 /// Gets the [TypeSchemaEnvironment] being used for type inference. |
| 207 TypeSchemaEnvironment get typeSchemaEnvironment; |
| 208 |
206 /// The URI of the code for which type inference is currently being | 209 /// The URI of the code for which type inference is currently being |
207 /// performed--this is used for testing. | 210 /// performed--this is used for testing. |
208 String get uri; | 211 String get uri; |
209 | 212 |
210 /// Performs full type inference on the given field initializer. | 213 /// Performs full type inference on the given field initializer. |
211 void inferFieldInitializer(DartType declaredType, Expression initializer); | 214 void inferFieldInitializer(DartType declaredType, Expression initializer); |
212 | 215 |
213 /// Performs type inference on the given function body. | 216 /// Performs type inference on the given function body. |
214 void inferFunctionBody( | 217 void inferFunctionBody( |
215 DartType returnType, AsyncMarker asyncMarker, Statement body); | 218 DartType returnType, AsyncMarker asyncMarker, Statement body); |
(...skipping 11 matching lines...) Expand all Loading... |
227 | 230 |
228 /// Implementation of [TypeInferrer] which doesn't do any type inference. | 231 /// Implementation of [TypeInferrer] which doesn't do any type inference. |
229 /// | 232 /// |
230 /// This is intended for profiling, to ensure that type inference and type | 233 /// This is intended for profiling, to ensure that type inference and type |
231 /// promotion do not slow down compilation too much. | 234 /// promotion do not slow down compilation too much. |
232 class TypeInferrerDisabled extends TypeInferrer { | 235 class TypeInferrerDisabled extends TypeInferrer { |
233 @override | 236 @override |
234 final typePromoter = new TypePromoterDisabled(); | 237 final typePromoter = new TypePromoterDisabled(); |
235 | 238 |
236 @override | 239 @override |
| 240 final TypeSchemaEnvironment typeSchemaEnvironment; |
| 241 |
| 242 TypeInferrerDisabled(this.typeSchemaEnvironment); |
| 243 |
| 244 @override |
237 String get uri => null; | 245 String get uri => null; |
238 | 246 |
239 @override | 247 @override |
240 void inferFieldInitializer(DartType declaredType, Expression initializer) {} | 248 void inferFieldInitializer(DartType declaredType, Expression initializer) {} |
241 | 249 |
242 @override | 250 @override |
243 void inferFunctionBody( | 251 void inferFunctionBody( |
244 DartType returnType, AsyncMarker asyncMarker, Statement body) {} | 252 DartType returnType, AsyncMarker asyncMarker, Statement body) {} |
245 | 253 |
246 @override | 254 @override |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 void _forEachArgument( | 1053 void _forEachArgument( |
1046 Arguments arguments, void callback(String name, Expression expression)) { | 1054 Arguments arguments, void callback(String name, Expression expression)) { |
1047 for (var expression in arguments.positional) { | 1055 for (var expression in arguments.positional) { |
1048 callback(null, expression); | 1056 callback(null, expression); |
1049 } | 1057 } |
1050 for (var namedExpression in arguments.named) { | 1058 for (var namedExpression in arguments.named) { |
1051 callback(namedExpression.name, namedExpression.value); | 1059 callback(namedExpression.name, namedExpression.value); |
1052 } | 1060 } |
1053 } | 1061 } |
1054 } | 1062 } |
OLD | NEW |