Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1918903004: Make support for async/await syntax optional in the frontend. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 } else if (!node.isArrowBody && currentAsyncMarker.isYielding) { 3529 } else if (!node.isArrowBody && currentAsyncMarker.isYielding) {
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 (!currentAsyncMarker.isYielding) { 3539 if (!compiler.backend.supportsAsyncAwait) {
3540 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); 3540 reporter.reportErrorMessage(node.yieldToken,
3541 } 3541 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED);
3542 if (currentAsyncMarker.isAsync) {
3543 coreClasses.streamClass.ensureResolved(resolution);
3544 } else { 3542 } else {
3545 coreClasses.iterableClass.ensureResolved(resolution); 3543 if (!currentAsyncMarker.isYielding) {
3544 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD);
3545 }
3546 if (currentAsyncMarker.isAsync) {
3547 coreClasses.streamClass.ensureResolved(resolution);
3548 } else {
3549 coreClasses.iterableClass.ensureResolved(resolution);
3550 }
3546 } 3551 }
3547 visit(node.expression); 3552 visit(node.expression);
3548 return const NoneResult(); 3553 return const NoneResult();
3549 } 3554 }
3550 3555
3551 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) { 3556 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) {
3552 if (!enclosingElement.isFactoryConstructor) { 3557 if (!enclosingElement.isFactoryConstructor) {
3553 reporter.reportErrorMessage( 3558 reporter.reportErrorMessage(
3554 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); 3559 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY);
3555 reporter.reportHintMessage( 3560 reporter.reportHintMessage(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 return const NoneResult(); 3670 return const NoneResult();
3666 } 3671 }
3667 3672
3668 ResolutionResult visitThrow(Throw node) { 3673 ResolutionResult visitThrow(Throw node) {
3669 registry.registerFeature(Feature.THROW_EXPRESSION); 3674 registry.registerFeature(Feature.THROW_EXPRESSION);
3670 visit(node.expression); 3675 visit(node.expression);
3671 return const NoneResult(); 3676 return const NoneResult();
3672 } 3677 }
3673 3678
3674 ResolutionResult visitAwait(Await node) { 3679 ResolutionResult visitAwait(Await node) {
3675 if (!currentAsyncMarker.isAsync) { 3680 if (!compiler.backend.supportsAsyncAwait) {
3676 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); 3681 reporter.reportErrorMessage(node.awaitToken,
3682 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED);
3683 } else {
3684 if (!currentAsyncMarker.isAsync) {
3685 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT);
3686 }
3687 coreClasses.futureClass.ensureResolved(resolution);
3677 } 3688 }
3678 coreClasses.futureClass.ensureResolved(resolution);
3679 visit(node.expression); 3689 visit(node.expression);
3680 return const NoneResult(); 3690 return const NoneResult();
3681 } 3691 }
3682 3692
3683 ResolutionResult visitVariableDefinitions(VariableDefinitions node) { 3693 ResolutionResult visitVariableDefinitions(VariableDefinitions node) {
3684 DartType type; 3694 DartType type;
3685 if (node.type != null) { 3695 if (node.type != null) {
3686 type = resolveTypeAnnotation(node.type); 3696 type = resolveTypeAnnotation(node.type);
3687 } else { 3697 } else {
3688 type = const DynamicType(); 3698 type = const DynamicType();
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 } 4197 }
4188 registry.registerTargetOf(node, target); 4198 registry.registerTargetOf(node, target);
4189 return const NoneResult(); 4199 return const NoneResult();
4190 } 4200 }
4191 4201
4192 registerImplicitInvocation(Selector selector) { 4202 registerImplicitInvocation(Selector selector) {
4193 registry.registerDynamicUse(new DynamicUse(selector, null)); 4203 registry.registerDynamicUse(new DynamicUse(selector, null));
4194 } 4204 }
4195 4205
4196 ResolutionResult visitAsyncForIn(AsyncForIn node) { 4206 ResolutionResult visitAsyncForIn(AsyncForIn node) {
4197 if (!currentAsyncMarker.isAsync) { 4207 if (!compiler.backend.supportsAsyncAwait) {
4198 reporter.reportErrorMessage( 4208 reporter.reportErrorMessage(node.awaitToken,
4199 node.awaitToken, MessageKind.INVALID_AWAIT_FOR_IN); 4209 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED);
4210 } else {
4211 if (!currentAsyncMarker.isAsync) {
4212 reporter.reportErrorMessage(
4213 node.awaitToken, MessageKind.INVALID_AWAIT_FOR_IN);
4214 }
4215 registry.registerFeature(Feature.ASYNC_FOR_IN);
4216 registry.registerDynamicUse(
4217 new DynamicUse(Selectors.current, null));
4218 registry.registerDynamicUse(
4219 new DynamicUse(Selectors.moveNext, null));
4200 } 4220 }
4201 registry.registerFeature(Feature.ASYNC_FOR_IN);
4202 registry.registerDynamicUse(new DynamicUse(Selectors.current, null));
4203 registry.registerDynamicUse(new DynamicUse(Selectors.moveNext, null));
4204
4205 visit(node.expression); 4221 visit(node.expression);
4206 4222
4207 Scope blockScope = new BlockScope(scope); 4223 Scope blockScope = new BlockScope(scope);
4208 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); 4224 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope);
4209 visitLoopBodyIn(node, node.body, blockScope); 4225 visitLoopBodyIn(node, node.body, blockScope);
4210 return const NoneResult(); 4226 return const NoneResult();
4211 } 4227 }
4212 4228
4213 ResolutionResult visitSyncForIn(SyncForIn node) { 4229 ResolutionResult visitSyncForIn(SyncForIn node) {
4214 registry.registerFeature(Feature.SYNC_FOR_IN); 4230 registry.registerFeature(Feature.SYNC_FOR_IN);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
4671 } 4687 }
4672 return const NoneResult(); 4688 return const NoneResult();
4673 } 4689 }
4674 } 4690 }
4675 4691
4676 /// Looks up [name] in [scope] and unwraps the result. 4692 /// Looks up [name] in [scope] and unwraps the result.
4677 Element lookupInScope( 4693 Element lookupInScope(
4678 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4694 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4679 return Elements.unwrap(scope.lookup(name), reporter, node); 4695 return Elements.unwrap(scope.lookup(name), reporter, node);
4680 } 4696 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698