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 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 /// Shadow object for [Rethrow]. | 1528 /// Shadow object for [Rethrow]. |
1529 class KernelRethrow extends Rethrow implements KernelExpression { | 1529 class KernelRethrow extends Rethrow implements KernelExpression { |
1530 @override | 1530 @override |
1531 void _collectDependencies(KernelDependencyCollector collector) { | 1531 void _collectDependencies(KernelDependencyCollector collector) { |
1532 // No inference dependencies. | 1532 // No inference dependencies. |
1533 } | 1533 } |
1534 | 1534 |
1535 @override | 1535 @override |
1536 DartType _inferExpression( | 1536 DartType _inferExpression( |
1537 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 1537 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
1538 // TODO(scheglov): implement. | 1538 typeNeeded = |
1539 return typeNeeded ? const DynamicType() : null; | 1539 inferrer.listener.rethrowEnter(this, typeContext) || typeNeeded; |
| 1540 var inferredType = typeNeeded ? const BottomType() : null; |
| 1541 inferrer.listener.rethrowExit(this, inferredType); |
| 1542 return inferredType; |
1540 } | 1543 } |
1541 } | 1544 } |
1542 | 1545 |
1543 /// Concrete shadow object representing a return statement in kernel form. | 1546 /// Concrete shadow object representing a return statement in kernel form. |
1544 class KernelReturnStatement extends ReturnStatement implements KernelStatement { | 1547 class KernelReturnStatement extends ReturnStatement implements KernelStatement { |
1545 KernelReturnStatement([Expression expression]) : super(expression); | 1548 KernelReturnStatement([Expression expression]) : super(expression); |
1546 | 1549 |
1547 @override | 1550 @override |
1548 void _inferStatement(KernelTypeInferrer inferrer) { | 1551 void _inferStatement(KernelTypeInferrer inferrer) { |
1549 inferrer.listener.returnStatementEnter(this); | 1552 inferrer.listener.returnStatementEnter(this); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 KernelThrow(Expression expression) : super(expression); | 1820 KernelThrow(Expression expression) : super(expression); |
1818 | 1821 |
1819 @override | 1822 @override |
1820 void _collectDependencies(KernelDependencyCollector collector) { | 1823 void _collectDependencies(KernelDependencyCollector collector) { |
1821 // No inference dependencies. | 1824 // No inference dependencies. |
1822 } | 1825 } |
1823 | 1826 |
1824 @override | 1827 @override |
1825 DartType _inferExpression( | 1828 DartType _inferExpression( |
1826 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 1829 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
| 1830 typeNeeded = inferrer.listener.throwEnter(this, typeContext) || typeNeeded; |
1827 inferrer.inferExpression(expression, null, false); | 1831 inferrer.inferExpression(expression, null, false); |
1828 return typeNeeded ? const BottomType() : null; | 1832 var inferredType = typeNeeded ? const BottomType() : null; |
| 1833 inferrer.listener.throwExit(this, inferredType); |
| 1834 return inferredType; |
1829 } | 1835 } |
1830 } | 1836 } |
1831 | 1837 |
1832 /// Concrete implementation of [TypeInferenceEngine] specialized to work with | 1838 /// Concrete implementation of [TypeInferenceEngine] specialized to work with |
1833 /// kernel objects. | 1839 /// kernel objects. |
1834 class KernelTypeInferenceEngine extends TypeInferenceEngineImpl { | 1840 class KernelTypeInferenceEngine extends TypeInferenceEngineImpl { |
1835 KernelTypeInferenceEngine(Instrumentation instrumentation, bool strongMode) | 1841 KernelTypeInferenceEngine(Instrumentation instrumentation, bool strongMode) |
1836 : super(instrumentation, strongMode); | 1842 : super(instrumentation, strongMode); |
1837 | 1843 |
1838 @override | 1844 @override |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2236 } | 2242 } |
2237 | 2243 |
2238 transformChildren(v) { | 2244 transformChildren(v) { |
2239 return internalError("Internal error: Unsupported operation."); | 2245 return internalError("Internal error: Unsupported operation."); |
2240 } | 2246 } |
2241 | 2247 |
2242 visitChildren(v) { | 2248 visitChildren(v) { |
2243 return internalError("Internal error: Unsupported operation."); | 2249 return internalError("Internal error: Unsupported operation."); |
2244 } | 2250 } |
2245 } | 2251 } |
OLD | NEW |