| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 if (seen.contains(redirection)) { | 485 if (seen.contains(redirection)) { |
| 486 resolver.visitor.error(node, MessageKind.REDIRECTING_CONSTRUCTOR_CYCLE); | 486 resolver.visitor.error(node, MessageKind.REDIRECTING_CONSTRUCTOR_CYCLE); |
| 487 return; | 487 return; |
| 488 } | 488 } |
| 489 seen.add(redirection); | 489 seen.add(redirection); |
| 490 redirection = resolver.visitor.resolveConstructorRedirection(redirection); | 490 redirection = resolver.visitor.resolveConstructorRedirection(redirection); |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 | 493 |
| 494 static void processAsyncMarker(Compiler compiler, | 494 static void processAsyncMarker(Compiler compiler, |
| 495 BaseFunctionElementX element) { | 495 BaseFunctionElementX element, |
| 496 Registry registry) { |
| 496 FunctionExpression functionExpression = element.node; | 497 FunctionExpression functionExpression = element.node; |
| 497 AsyncModifier asyncModifier = functionExpression.asyncModifier; | 498 AsyncModifier asyncModifier = functionExpression.asyncModifier; |
| 498 if (asyncModifier != null) { | 499 if (asyncModifier != null) { |
| 499 if (!compiler.enableAsyncAwait) { | |
| 500 compiler.reportError(asyncModifier, | |
| 501 MessageKind.EXPERIMENTAL_ASYNC_AWAIT, | |
| 502 {'modifier': element.asyncMarker}); | |
| 503 } | |
| 504 | 500 |
| 505 if (asyncModifier.isAsynchronous) { | 501 if (asyncModifier.isAsynchronous) { |
| 506 element.asyncMarker = asyncModifier.isYielding | 502 element.asyncMarker = asyncModifier.isYielding |
| 507 ? AsyncMarker.ASYNC_STAR : AsyncMarker.ASYNC; | 503 ? AsyncMarker.ASYNC_STAR : AsyncMarker.ASYNC; |
| 508 } else { | 504 } else { |
| 509 element.asyncMarker = AsyncMarker.SYNC_STAR; | 505 element.asyncMarker = AsyncMarker.SYNC_STAR; |
| 510 } | 506 } |
| 511 if (element.isAbstract) { | 507 if (element.isAbstract) { |
| 512 compiler.reportError(asyncModifier, | 508 compiler.reportError(asyncModifier, |
| 513 MessageKind.ASYNC_MODIFIER_ON_ABSTRACT_METHOD, | 509 MessageKind.ASYNC_MODIFIER_ON_ABSTRACT_METHOD, |
| 514 {'modifier': element.asyncMarker}); | 510 {'modifier': element.asyncMarker}); |
| 515 } else if (element.isConstructor) { | 511 } else if (element.isConstructor) { |
| 516 compiler.reportError(asyncModifier, | 512 compiler.reportError(asyncModifier, |
| 517 MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR, | 513 MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR, |
| 518 {'modifier': element.asyncMarker}); | 514 {'modifier': element.asyncMarker}); |
| 519 } else { | 515 } else { |
| 520 if (element.isSetter) { | 516 if (element.isSetter) { |
| 521 compiler.reportError(asyncModifier, | 517 compiler.reportError(asyncModifier, |
| 522 MessageKind.ASYNC_MODIFIER_ON_SETTER, | 518 MessageKind.ASYNC_MODIFIER_ON_SETTER, |
| 523 {'modifier': element.asyncMarker}); | 519 {'modifier': element.asyncMarker}); |
| 524 | 520 |
| 525 } | 521 } |
| 526 if (functionExpression.body.asReturn() != null && | 522 if (functionExpression.body.asReturn() != null && |
| 527 element.asyncMarker.isYielding) { | 523 element.asyncMarker.isYielding) { |
| 528 compiler.reportError(asyncModifier, | 524 compiler.reportError(asyncModifier, |
| 529 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, | 525 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, |
| 530 {'modifier': element.asyncMarker}); | 526 {'modifier': element.asyncMarker}); |
| 531 } | 527 } |
| 532 } | 528 } |
| 529 registry.registerAsyncMarker(element); |
| 533 } | 530 } |
| 534 } | 531 } |
| 535 | 532 |
| 536 TreeElements resolveMethodElementImplementation( | 533 TreeElements resolveMethodElementImplementation( |
| 537 FunctionElement element, FunctionExpression tree) { | 534 FunctionElement element, FunctionExpression tree) { |
| 538 return compiler.withCurrentElement(element, () { | 535 return compiler.withCurrentElement(element, () { |
| 539 if (element.isExternal && tree.hasBody()) { | 536 if (element.isExternal && tree.hasBody()) { |
| 540 compiler.reportError(element, | 537 compiler.reportError(element, |
| 541 MessageKind.EXTERNAL_WITH_BODY, | 538 MessageKind.EXTERNAL_WITH_BODY, |
| 542 {'functionName': element.name}); | 539 {'functionName': element.name}); |
| 543 } | 540 } |
| 544 if (element.isConstructor) { | 541 if (element.isConstructor) { |
| 545 if (tree.returnType != null) { | 542 if (tree.returnType != null) { |
| 546 compiler.reportError(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); | 543 compiler.reportError(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); |
| 547 } | 544 } |
| 548 if (element.isConst && | 545 if (element.isConst && |
| 549 tree.hasBody() && | 546 tree.hasBody() && |
| 550 !tree.isRedirectingFactory) { | 547 !tree.isRedirectingFactory) { |
| 551 compiler.reportError(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY); | 548 compiler.reportError(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY); |
| 552 } | 549 } |
| 553 } | 550 } |
| 554 | 551 |
| 555 ResolverVisitor visitor = visitorFor(element); | 552 ResolverVisitor visitor = visitorFor(element); |
| 556 ResolutionRegistry registry = visitor.registry; | 553 ResolutionRegistry registry = visitor.registry; |
| 557 registry.defineFunction(tree, element); | 554 registry.defineFunction(tree, element); |
| 558 visitor.setupFunction(tree, element); | 555 visitor.setupFunction(tree, element); |
| 556 processAsyncMarker(compiler, element, registry); |
| 559 | 557 |
| 560 if (element.isGenerativeConstructor) { | 558 if (element.isGenerativeConstructor) { |
| 561 // Even if there is no initializer list we still have to do the | 559 // Even if there is no initializer list we still have to do the |
| 562 // resolution in case there is an implicit super constructor call. | 560 // resolution in case there is an implicit super constructor call. |
| 563 InitializerResolver resolver = new InitializerResolver(visitor); | 561 InitializerResolver resolver = new InitializerResolver(visitor); |
| 564 FunctionElement redirection = | 562 FunctionElement redirection = |
| 565 resolver.resolveInitializers(element, tree); | 563 resolver.resolveInitializers(element, tree); |
| 566 if (redirection != null) { | 564 if (redirection != null) { |
| 567 resolveRedirectingConstructor(resolver, tree, element, redirection); | 565 resolveRedirectingConstructor(resolver, tree, element, redirection); |
| 568 } | 566 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 registry.registerImplicitSuperCall(target); | 621 registry.registerImplicitSuperCall(target); |
| 624 } | 622 } |
| 625 return registry.mapping; | 623 return registry.mapping; |
| 626 } else { | 624 } else { |
| 627 assert(element.isDeferredLoaderGetter || element.isErroneous); | 625 assert(element.isDeferredLoaderGetter || element.isErroneous); |
| 628 return _ensureTreeElements(element); | 626 return _ensureTreeElements(element); |
| 629 } | 627 } |
| 630 } else { | 628 } else { |
| 631 element.parseNode(compiler); | 629 element.parseNode(compiler); |
| 632 element.computeType(compiler); | 630 element.computeType(compiler); |
| 633 processAsyncMarker(compiler, element); | |
| 634 FunctionElementX implementation = element; | 631 FunctionElementX implementation = element; |
| 635 if (element.isExternal) { | 632 if (element.isExternal) { |
| 636 implementation = compiler.backend.resolveExternalFunction(element); | 633 implementation = compiler.backend.resolveExternalFunction(element); |
| 637 } | 634 } |
| 638 return resolveMethodElementImplementation( | 635 return resolveMethodElementImplementation( |
| 639 implementation, implementation.node); | 636 implementation, implementation.node); |
| 640 } | 637 } |
| 641 }); | 638 }); |
| 642 } | 639 } |
| 643 | 640 |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 visit(node.returnType); | 2468 visit(node.returnType); |
| 2472 String name; | 2469 String name; |
| 2473 if (node.name == null) { | 2470 if (node.name == null) { |
| 2474 name = ""; | 2471 name = ""; |
| 2475 } else { | 2472 } else { |
| 2476 name = node.name.asIdentifier().source; | 2473 name = node.name.asIdentifier().source; |
| 2477 } | 2474 } |
| 2478 LocalFunctionElementX function = new LocalFunctionElementX( | 2475 LocalFunctionElementX function = new LocalFunctionElementX( |
| 2479 name, node, ElementKind.FUNCTION, Modifiers.EMPTY, | 2476 name, node, ElementKind.FUNCTION, Modifiers.EMPTY, |
| 2480 enclosingElement); | 2477 enclosingElement); |
| 2481 ResolverTask.processAsyncMarker(compiler, function); | 2478 ResolverTask.processAsyncMarker(compiler, function, registry); |
| 2482 function.functionSignatureCache = SignatureResolver.analyze( | 2479 function.functionSignatureCache = SignatureResolver.analyze( |
| 2483 compiler, | 2480 compiler, |
| 2484 node.parameters, | 2481 node.parameters, |
| 2485 node.returnType, | 2482 node.returnType, |
| 2486 function, | 2483 function, |
| 2487 registry, | 2484 registry, |
| 2488 createRealParameters: true, | 2485 createRealParameters: true, |
| 2489 isFunctionExpression: !inFunctionDeclaration); | 2486 isFunctionExpression: !inFunctionDeclaration); |
| 2490 checkLocalDefinitionName(node, function); | 2487 checkLocalDefinitionName(node, function); |
| 2491 registry.defineFunction(node, function); | 2488 registry.defineFunction(node, function); |
| (...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5039 } | 5036 } |
| 5040 | 5037 |
| 5041 /// The result for the resolution of the `assert` method. | 5038 /// The result for the resolution of the `assert` method. |
| 5042 class AssertResult implements ResolutionResult { | 5039 class AssertResult implements ResolutionResult { |
| 5043 const AssertResult(); | 5040 const AssertResult(); |
| 5044 | 5041 |
| 5045 Element get element => null; | 5042 Element get element => null; |
| 5046 | 5043 |
| 5047 String toString() => 'AssertResult()'; | 5044 String toString() => 'AssertResult()'; |
| 5048 } | 5045 } |
| OLD | NEW |