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 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2257 /// Concrete shadow object representing a yield statement in kernel form. | 2257 /// Concrete shadow object representing a yield statement in kernel form. |
2258 class KernelYieldStatement extends YieldStatement implements KernelStatement { | 2258 class KernelYieldStatement extends YieldStatement implements KernelStatement { |
2259 KernelYieldStatement(Expression expression, {bool isYieldStar: false}) | 2259 KernelYieldStatement(Expression expression, {bool isYieldStar: false}) |
2260 : super(expression, isYieldStar: isYieldStar); | 2260 : super(expression, isYieldStar: isYieldStar); |
2261 | 2261 |
2262 @override | 2262 @override |
2263 void _inferStatement(KernelTypeInferrer inferrer) { | 2263 void _inferStatement(KernelTypeInferrer inferrer) { |
2264 inferrer.listener.yieldStatementEnter(this); | 2264 inferrer.listener.yieldStatementEnter(this); |
2265 var closureContext = inferrer.closureContext; | 2265 var closureContext = inferrer.closureContext; |
2266 var typeContext = | 2266 var typeContext = |
2267 closureContext.isGenerator ? closureContext.returnContext : null; | 2267 closureContext.isGenerator ? closureContext.returnContext : null; |
Paul Berry
2017/06/15 16:33:34
Note that the use of closureContext.isGenerator at
| |
2268 if (isYieldStar && typeContext != null) { | 2268 if (isYieldStar && typeContext != null) { |
2269 typeContext = inferrer.wrapType( | 2269 typeContext = inferrer.wrapType( |
2270 typeContext, | 2270 typeContext, |
2271 closureContext.isAsync | 2271 closureContext.isAsync |
2272 ? inferrer.coreTypes.streamClass | 2272 ? inferrer.coreTypes.streamClass |
2273 : inferrer.coreTypes.iterableClass); | 2273 : inferrer.coreTypes.iterableClass); |
2274 } | 2274 } |
2275 var inferredType = inferrer.inferExpression( | 2275 var inferredType = inferrer.inferExpression(expression, typeContext, true); |
2276 expression, typeContext, closureContext != null); | |
2277 closureContext.handleYield(inferrer, isYieldStar, inferredType); | 2276 closureContext.handleYield(inferrer, isYieldStar, inferredType); |
2278 inferrer.listener.yieldStatementExit(this); | 2277 inferrer.listener.yieldStatementExit(this); |
2279 } | 2278 } |
2280 } | 2279 } |
2281 | 2280 |
2282 class _UnfinishedCascade extends Expression { | 2281 class _UnfinishedCascade extends Expression { |
2283 accept(v) { | 2282 accept(v) { |
2284 return internalError("Internal error: Unsupported operation."); | 2283 return internalError("Internal error: Unsupported operation."); |
2285 } | 2284 } |
2286 | 2285 |
2287 accept1(v, arg) { | 2286 accept1(v, arg) { |
2288 return internalError("Internal error: Unsupported operation."); | 2287 return internalError("Internal error: Unsupported operation."); |
2289 } | 2288 } |
2290 | 2289 |
2291 getStaticType(types) { | 2290 getStaticType(types) { |
2292 return internalError("Internal error: Unsupported operation."); | 2291 return internalError("Internal error: Unsupported operation."); |
2293 } | 2292 } |
2294 | 2293 |
2295 transformChildren(v) { | 2294 transformChildren(v) { |
2296 return internalError("Internal error: Unsupported operation."); | 2295 return internalError("Internal error: Unsupported operation."); |
2297 } | 2296 } |
2298 | 2297 |
2299 visitChildren(v) { | 2298 visitChildren(v) { |
2300 return internalError("Internal error: Unsupported operation."); | 2299 return internalError("Internal error: Unsupported operation."); |
2301 } | 2300 } |
2302 } | 2301 } |
OLD | NEW |