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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1253333002: dart2js cps: Support async/await by rewriting the JavaScript AST. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add issue number to status file. Created 5 years, 4 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 part of js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 if (compiler.useCpsIr) { 2724 if (compiler.useCpsIr) {
2725 compiler.reportHint( 2725 compiler.reportHint(
2726 node, 2726 node,
2727 MessageKind.GENERIC, 2727 MessageKind.GENERIC,
2728 {'text': "Generation of code with compile time errors is currently " 2728 {'text': "Generation of code with compile time errors is currently "
2729 "not supported with the CPS IR."}); 2729 "not supported with the CPS IR."});
2730 return false; 2730 return false;
2731 } 2731 }
2732 return true; 2732 return true;
2733 } 2733 }
2734
2735 jsAst.Expression rewriteAsync(FunctionElement element,
2736 jsAst.Expression code) {
2737 AsyncRewriterBase rewriter = null;
2738 jsAst.Name name = namer.methodPropertyName(element);
2739 if (element.asyncMarker == AsyncMarker.ASYNC) {
2740 rewriter = new AsyncRewriter(
2741 compiler,
2742 compiler.currentElement,
2743 asyncHelper:
2744 emitter.staticFunctionAccess(getAsyncHelper()),
2745 newCompleter: emitter.staticFunctionAccess(
2746 getCompleterConstructor()),
2747 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2748 bodyName: namer.deriveAsyncBodyName(name));
2749 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) {
2750 rewriter = new SyncStarRewriter(
2751 compiler,
2752 compiler.currentElement,
2753 endOfIteration: emitter.staticFunctionAccess(
2754 getEndOfIteration()),
2755 newIterable: emitter.staticFunctionAccess(
2756 getSyncStarIterableConstructor()),
2757 yieldStarExpression: emitter.staticFunctionAccess(
2758 getYieldStar()),
2759 uncaughtErrorExpression: emitter.staticFunctionAccess(
2760 getSyncStarUncaughtError()),
2761 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2762 bodyName: namer.deriveAsyncBodyName(name));
2763 }
2764 else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) {
Kevin Millikin (Google) 2015/08/07 08:52:32 else if is on the wrong line. I'd probably write
2765 rewriter = new AsyncStarRewriter(
2766 compiler,
2767 compiler.currentElement,
2768 asyncStarHelper: emitter.staticFunctionAccess(
2769 getAsyncStarHelper()),
2770 streamOfController: emitter.staticFunctionAccess(
2771 getStreamOfController()),
2772 newController: emitter.staticFunctionAccess(
2773 getASyncStarControllerConstructor()),
2774 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2775 yieldExpression: emitter.staticFunctionAccess(
2776 getYieldSingle()),
2777 yieldStarExpression: emitter.staticFunctionAccess(
2778 getYieldStar()),
2779 bodyName: namer.deriveAsyncBodyName(name));
2780 }
2781 return rewriter != null ? rewriter.rewrite(code) : code;
Kevin Millikin (Google) 2015/08/07 08:52:32 It seems like the only call is guarded by asyncMar
2782 }
2734 } 2783 }
2735 2784
2736 /// Handling of special annotations for tests. 2785 /// Handling of special annotations for tests.
2737 class Annotations { 2786 class Annotations {
2738 static final Uri PACKAGE_EXPECT = 2787 static final Uri PACKAGE_EXPECT =
2739 new Uri(scheme: 'package', path: 'expect/expect.dart'); 2788 new Uri(scheme: 'package', path: 'expect/expect.dart');
2740 2789
2741 final Compiler compiler; 2790 final Compiler compiler;
2742 2791
2743 ClassElement expectNoInlineClass; 2792 ClassElement expectNoInlineClass;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 } 3063 }
3015 } 3064 }
3016 3065
3017 /// Records that [constant] is used by the element behind [registry]. 3066 /// Records that [constant] is used by the element behind [registry].
3018 class Dependency { 3067 class Dependency {
3019 final ConstantValue constant; 3068 final ConstantValue constant;
3020 final Element annotatedElement; 3069 final Element annotatedElement;
3021 3070
3022 const Dependency(this.constant, this.annotatedElement); 3071 const Dependency(this.constant, this.annotatedElement);
3023 } 3072 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698