OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.resolution.members; | 5 library dart2js.resolution.members; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Selectors; | 8 import '../common/names.dart' show Selectors; |
9 import '../common/resolution.dart' show Feature; | 9 import '../common/resolution.dart' show Feature; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3530 reporter.reportErrorMessage(node, MessageKind.RETURN_IN_GENERATOR, | 3530 reporter.reportErrorMessage(node, MessageKind.RETURN_IN_GENERATOR, |
3531 {'modifier': currentAsyncMarker}); | 3531 {'modifier': currentAsyncMarker}); |
3532 } | 3532 } |
3533 } | 3533 } |
3534 visit(node.expression); | 3534 visit(node.expression); |
3535 return const NoneResult(); | 3535 return const NoneResult(); |
3536 } | 3536 } |
3537 | 3537 |
3538 ResolutionResult visitYield(Yield node) { | 3538 ResolutionResult visitYield(Yield node) { |
3539 if (!compiler.backend.supportsAsyncAwait) { | 3539 if (!compiler.backend.supportsAsyncAwait) { |
3540 reporter.reportErrorMessage(node.yieldToken, | 3540 reporter.reportErrorMessage( |
3541 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3541 node.yieldToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
3542 } else { | 3542 } else { |
3543 if (!currentAsyncMarker.isYielding) { | 3543 if (!currentAsyncMarker.isYielding) { |
3544 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); | 3544 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); |
3545 } | 3545 } |
3546 if (currentAsyncMarker.isAsync) { | 3546 if (currentAsyncMarker.isAsync) { |
3547 coreClasses.streamClass.ensureResolved(resolution); | 3547 coreClasses.streamClass.ensureResolved(resolution); |
3548 } else { | 3548 } else { |
3549 coreClasses.iterableClass.ensureResolved(resolution); | 3549 coreClasses.iterableClass.ensureResolved(resolution); |
3550 } | 3550 } |
3551 } | 3551 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3671 } | 3671 } |
3672 | 3672 |
3673 ResolutionResult visitThrow(Throw node) { | 3673 ResolutionResult visitThrow(Throw node) { |
3674 registry.registerFeature(Feature.THROW_EXPRESSION); | 3674 registry.registerFeature(Feature.THROW_EXPRESSION); |
3675 visit(node.expression); | 3675 visit(node.expression); |
3676 return const NoneResult(); | 3676 return const NoneResult(); |
3677 } | 3677 } |
3678 | 3678 |
3679 ResolutionResult visitAwait(Await node) { | 3679 ResolutionResult visitAwait(Await node) { |
3680 if (!compiler.backend.supportsAsyncAwait) { | 3680 if (!compiler.backend.supportsAsyncAwait) { |
3681 reporter.reportErrorMessage(node.awaitToken, | 3681 reporter.reportErrorMessage( |
3682 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3682 node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
3683 } else { | 3683 } else { |
3684 if (!currentAsyncMarker.isAsync) { | 3684 if (!currentAsyncMarker.isAsync) { |
3685 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); | 3685 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); |
3686 } | 3686 } |
3687 coreClasses.futureClass.ensureResolved(resolution); | 3687 coreClasses.futureClass.ensureResolved(resolution); |
3688 } | 3688 } |
3689 visit(node.expression); | 3689 visit(node.expression); |
3690 return const NoneResult(); | 3690 return const NoneResult(); |
3691 } | 3691 } |
3692 | 3692 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4198 registry.registerTargetOf(node, target); | 4198 registry.registerTargetOf(node, target); |
4199 return const NoneResult(); | 4199 return const NoneResult(); |
4200 } | 4200 } |
4201 | 4201 |
4202 registerImplicitInvocation(Selector selector) { | 4202 registerImplicitInvocation(Selector selector) { |
4203 registry.registerDynamicUse(new DynamicUse(selector, null)); | 4203 registry.registerDynamicUse(new DynamicUse(selector, null)); |
4204 } | 4204 } |
4205 | 4205 |
4206 ResolutionResult visitAsyncForIn(AsyncForIn node) { | 4206 ResolutionResult visitAsyncForIn(AsyncForIn node) { |
4207 if (!compiler.backend.supportsAsyncAwait) { | 4207 if (!compiler.backend.supportsAsyncAwait) { |
4208 reporter.reportErrorMessage(node.awaitToken, | 4208 reporter.reportErrorMessage( |
4209 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 4209 node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
4210 } else { | 4210 } else { |
4211 if (!currentAsyncMarker.isAsync) { | 4211 if (!currentAsyncMarker.isAsync) { |
4212 reporter.reportErrorMessage( | 4212 reporter.reportErrorMessage( |
4213 node.awaitToken, MessageKind.INVALID_AWAIT_FOR_IN); | 4213 node.awaitToken, MessageKind.INVALID_AWAIT_FOR_IN); |
4214 } | 4214 } |
4215 registry.registerFeature(Feature.ASYNC_FOR_IN); | 4215 registry.registerFeature(Feature.ASYNC_FOR_IN); |
4216 registry.registerDynamicUse( | 4216 registry.registerDynamicUse(new DynamicUse(Selectors.current, null)); |
4217 new DynamicUse(Selectors.current, null)); | 4217 registry.registerDynamicUse(new DynamicUse(Selectors.moveNext, null)); |
4218 registry.registerDynamicUse( | |
4219 new DynamicUse(Selectors.moveNext, null)); | |
4220 } | 4218 } |
4221 visit(node.expression); | 4219 visit(node.expression); |
4222 | 4220 |
4223 Scope blockScope = new BlockScope(scope); | 4221 Scope blockScope = new BlockScope(scope); |
4224 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); | 4222 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); |
4225 visitLoopBodyIn(node, node.body, blockScope); | 4223 visitLoopBodyIn(node, node.body, blockScope); |
4226 return const NoneResult(); | 4224 return const NoneResult(); |
4227 } | 4225 } |
4228 | 4226 |
4229 ResolutionResult visitSyncForIn(SyncForIn node) { | 4227 ResolutionResult visitSyncForIn(SyncForIn node) { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4687 } | 4685 } |
4688 return const NoneResult(); | 4686 return const NoneResult(); |
4689 } | 4687 } |
4690 } | 4688 } |
4691 | 4689 |
4692 /// Looks up [name] in [scope] and unwraps the result. | 4690 /// Looks up [name] in [scope] and unwraps the result. |
4693 Element lookupInScope( | 4691 Element lookupInScope( |
4694 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4692 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
4695 return Elements.unwrap(scope.lookup(name), reporter, node); | 4693 return Elements.unwrap(scope.lookup(name), reporter, node); |
4696 } | 4694 } |
OLD | NEW |