OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; |
| 6 import 'package:kernel/ast.dart'; |
| 7 |
| 8 /// Type inference listener that records inferred types and file offsets for |
| 9 /// later use by [ValidatingResolutionApplier]. |
| 10 class InstrumentedResolutionStorer extends ResolutionStorer { |
| 11 final List<int> _typeOffsets; |
| 12 |
| 13 InstrumentedResolutionStorer(List<DartType> types, this._typeOffsets) |
| 14 : super(types); |
| 15 |
| 16 @override |
| 17 void genericExpressionExit( |
| 18 String expressionType, Expression expression, DartType inferredType) { |
| 19 assert(_types.length == _typeOffsets.length); |
| 20 this._typeOffsets.add(expression.fileOffset); |
| 21 super.genericExpressionExit(expressionType, expression, inferredType); |
| 22 } |
| 23 } |
| 24 |
| 25 /// Type inference listener that records inferred types for later use by |
| 26 /// [ResolutionApplier]. |
| 27 class ResolutionStorer extends TypeInferenceListener { |
| 28 final List<DartType> _types; |
| 29 |
| 30 ResolutionStorer(this._types); |
| 31 |
| 32 @override |
| 33 bool genericExpressionEnter( |
| 34 String expressionType, Expression expression, DartType typeContext) { |
| 35 super.genericExpressionEnter(expressionType, expression, typeContext); |
| 36 return true; |
| 37 } |
| 38 |
| 39 @override |
| 40 void genericExpressionExit( |
| 41 String expressionType, Expression expression, DartType inferredType) { |
| 42 _types.add(inferredType); |
| 43 super.genericExpressionExit(expressionType, expression, inferredType); |
| 44 } |
| 45 } |
OLD | NEW |