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

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

Issue 839323003: Implementation of async-await transformation on js ast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing functions to the MockCompiler's library Created 5 years, 10 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 | Annotate | Revision Log
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 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
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 if (functionExpression.body.asReturn() != null && 515 } else if (functionExpression.body.asReturn() != null &&
520 element.asyncMarker.isYielding) { 516 element.asyncMarker.isYielding) {
521 compiler.reportError(asyncModifier, 517 compiler.reportError(asyncModifier,
522 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, 518 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
523 {'modifier': element.asyncMarker}); 519 {'modifier': element.asyncMarker});
524 } 520 }
521 registry.registerAsyncMarker(element);
525 } 522 }
526 } 523 }
527 524
528 TreeElements resolveMethodElementImplementation( 525 TreeElements resolveMethodElementImplementation(
529 FunctionElement element, FunctionExpression tree) { 526 FunctionElement element, FunctionExpression tree) {
530 return compiler.withCurrentElement(element, () { 527 return compiler.withCurrentElement(element, () {
531 if (element.isExternal && tree.hasBody()) { 528 if (element.isExternal && tree.hasBody()) {
532 compiler.reportError(element, 529 compiler.reportError(element,
533 MessageKind.EXTERNAL_WITH_BODY, 530 MessageKind.EXTERNAL_WITH_BODY,
534 {'functionName': element.name}); 531 {'functionName': element.name});
535 } 532 }
536 if (element.isConstructor) { 533 if (element.isConstructor) {
537 if (tree.returnType != null) { 534 if (tree.returnType != null) {
538 compiler.reportError(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); 535 compiler.reportError(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE);
539 } 536 }
540 if (element.isConst && 537 if (element.isConst &&
541 tree.hasBody() && 538 tree.hasBody() &&
542 !tree.isRedirectingFactory) { 539 !tree.isRedirectingFactory) {
543 compiler.reportError(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY); 540 compiler.reportError(tree, MessageKind.CONST_CONSTRUCTOR_HAS_BODY);
544 } 541 }
545 } 542 }
546 543
547 ResolverVisitor visitor = visitorFor(element); 544 ResolverVisitor visitor = visitorFor(element);
548 ResolutionRegistry registry = visitor.registry; 545 ResolutionRegistry registry = visitor.registry;
549 registry.defineFunction(tree, element); 546 registry.defineFunction(tree, element);
550 visitor.setupFunction(tree, element); 547 visitor.setupFunction(tree, element);
548 processAsyncMarker(compiler, element, registry);
551 549
552 if (element.isGenerativeConstructor) { 550 if (element.isGenerativeConstructor) {
553 // Even if there is no initializer list we still have to do the 551 // Even if there is no initializer list we still have to do the
554 // resolution in case there is an implicit super constructor call. 552 // resolution in case there is an implicit super constructor call.
555 InitializerResolver resolver = new InitializerResolver(visitor); 553 InitializerResolver resolver = new InitializerResolver(visitor);
556 FunctionElement redirection = 554 FunctionElement redirection =
557 resolver.resolveInitializers(element, tree); 555 resolver.resolveInitializers(element, tree);
558 if (redirection != null) { 556 if (redirection != null) {
559 resolveRedirectingConstructor(resolver, tree, element, redirection); 557 resolveRedirectingConstructor(resolver, tree, element, redirection);
560 } 558 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 registry.registerImplicitSuperCall(target); 613 registry.registerImplicitSuperCall(target);
616 } 614 }
617 return registry.mapping; 615 return registry.mapping;
618 } else { 616 } else {
619 assert(element.isDeferredLoaderGetter || element.isErroneous); 617 assert(element.isDeferredLoaderGetter || element.isErroneous);
620 return _ensureTreeElements(element); 618 return _ensureTreeElements(element);
621 } 619 }
622 } else { 620 } else {
623 element.parseNode(compiler); 621 element.parseNode(compiler);
624 element.computeType(compiler); 622 element.computeType(compiler);
625 processAsyncMarker(compiler, element);
626 FunctionElementX implementation = element; 623 FunctionElementX implementation = element;
627 if (element.isExternal) { 624 if (element.isExternal) {
628 implementation = compiler.backend.resolveExternalFunction(element); 625 implementation = compiler.backend.resolveExternalFunction(element);
629 } 626 }
630 return resolveMethodElementImplementation( 627 return resolveMethodElementImplementation(
631 implementation, implementation.node); 628 implementation, implementation.node);
632 } 629 }
633 }); 630 });
634 } 631 }
635 632
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 name = ""; 2463 name = "";
2467 } else { 2464 } else {
2468 name = node.name.asIdentifier().source; 2465 name = node.name.asIdentifier().source;
2469 } 2466 }
2470 LocalFunctionElementX function = new LocalFunctionElementX( 2467 LocalFunctionElementX function = new LocalFunctionElementX(
2471 name, node, ElementKind.FUNCTION, Modifiers.EMPTY, 2468 name, node, ElementKind.FUNCTION, Modifiers.EMPTY,
2472 enclosingElement); 2469 enclosingElement);
2473 function.functionSignatureCache = 2470 function.functionSignatureCache =
2474 SignatureResolver.analyze(compiler, node.parameters, node.returnType, 2471 SignatureResolver.analyze(compiler, node.parameters, node.returnType,
2475 function, registry, createRealParameters: true); 2472 function, registry, createRealParameters: true);
2476 ResolverTask.processAsyncMarker(compiler, function); 2473 ResolverTask.processAsyncMarker(compiler, function, registry);
2477 checkLocalDefinitionName(node, function); 2474 checkLocalDefinitionName(node, function);
2478 registry.defineFunction(node, function); 2475 registry.defineFunction(node, function);
2479 if (doAddToScope) { 2476 if (doAddToScope) {
2480 addToScope(function); 2477 addToScope(function);
2481 } 2478 }
2482 Scope oldScope = scope; // The scope is modified by [setupFunction]. 2479 Scope oldScope = scope; // The scope is modified by [setupFunction].
2483 setupFunction(node, function); 2480 setupFunction(node, function);
2484 2481
2485 Element previousEnclosingElement = enclosingElement; 2482 Element previousEnclosingElement = enclosingElement;
2486 enclosingElement = function; 2483 enclosingElement = function;
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 } 5023 }
5027 5024
5028 /// The result for the resolution of the `assert` method. 5025 /// The result for the resolution of the `assert` method.
5029 class AssertResult implements ResolutionResult { 5026 class AssertResult implements ResolutionResult {
5030 const AssertResult(); 5027 const AssertResult();
5031 5028
5032 Element get element => null; 5029 Element get element => null;
5033 5030
5034 String toString() => 'AssertResult()'; 5031 String toString() => 'AssertResult()';
5035 } 5032 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698