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

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: Rewrite to switch. 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 static final Uri DART_ISOLATE_HELPER = 236 static final Uri DART_ISOLATE_HELPER =
237 new Uri(scheme: 'dart', path: '_isolate_helper'); 237 new Uri(scheme: 'dart', path: '_isolate_helper');
238 static final Uri DART_HTML = 238 static final Uri DART_HTML =
239 new Uri(scheme: 'dart', path: 'html'); 239 new Uri(scheme: 'dart', path: 'html');
240 240
241 static const String INVOKE_ON = '_getCachedInvocation'; 241 static const String INVOKE_ON = '_getCachedInvocation';
242 static const String START_ROOT_ISOLATE = 'startRootIsolate'; 242 static const String START_ROOT_ISOLATE = 'startRootIsolate';
243 243
244 244
245 String get patchVersion => emitter.patchVersion; 245 String get patchVersion => emitter.patchVersion;
246 246
247 bool get supportsReflection => emitter.emitter.supportsReflection; 247 bool get supportsReflection => emitter.emitter.supportsReflection;
248 248
249 final Annotations annotations; 249 final Annotations annotations;
250 250
251 /// Reference to the internal library to lookup functions to always inline. 251 /// Reference to the internal library to lookup functions to always inline.
252 LibraryElement internalLibrary; 252 LibraryElement internalLibrary;
253 253
254 254
255 /// Set of classes that need to be considered for reflection although not 255 /// Set of classes that need to be considered for reflection although not
256 /// otherwise visible during resolution. 256 /// otherwise visible during resolution.
(...skipping 2467 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 switch (element.asyncMarker) {
2740 case AsyncMarker.ASYNC:
2741 rewriter = new AsyncRewriter(
2742 compiler,
2743 compiler.currentElement,
2744 asyncHelper:
2745 emitter.staticFunctionAccess(getAsyncHelper()),
2746 newCompleter: emitter.staticFunctionAccess(
2747 getCompleterConstructor()),
2748 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2749 bodyName: namer.deriveAsyncBodyName(name));
2750 break;
2751 case AsyncMarker.SYNC_STAR:
2752 rewriter = new SyncStarRewriter(
2753 compiler,
2754 compiler.currentElement,
2755 endOfIteration: emitter.staticFunctionAccess(
2756 getEndOfIteration()),
2757 newIterable: emitter.staticFunctionAccess(
2758 getSyncStarIterableConstructor()),
2759 yieldStarExpression: emitter.staticFunctionAccess(
2760 getYieldStar()),
2761 uncaughtErrorExpression: emitter.staticFunctionAccess(
2762 getSyncStarUncaughtError()),
2763 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2764 bodyName: namer.deriveAsyncBodyName(name));
2765 break;
2766 case AsyncMarker.ASYNC_STAR:
2767 rewriter = new AsyncStarRewriter(
2768 compiler,
2769 compiler.currentElement,
2770 asyncStarHelper: emitter.staticFunctionAccess(
2771 getAsyncStarHelper()),
2772 streamOfController: emitter.staticFunctionAccess(
2773 getStreamOfController()),
2774 newController: emitter.staticFunctionAccess(
2775 getASyncStarControllerConstructor()),
2776 safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
2777 yieldExpression: emitter.staticFunctionAccess(
2778 getYieldSingle()),
2779 yieldStarExpression: emitter.staticFunctionAccess(
2780 getYieldStar()),
2781 bodyName: namer.deriveAsyncBodyName(name));
2782 break;
2783 default:
2784 assert(element.asyncMarker == AsyncMarker.SYNC);
2785 return code;
2786 }
2787 return rewriter.rewrite(code);
2788 }
2734 } 2789 }
2735 2790
2736 /// Handling of special annotations for tests. 2791 /// Handling of special annotations for tests.
2737 class Annotations { 2792 class Annotations {
2738 static final Uri PACKAGE_EXPECT = 2793 static final Uri PACKAGE_EXPECT =
2739 new Uri(scheme: 'package', path: 'expect/expect.dart'); 2794 new Uri(scheme: 'package', path: 'expect/expect.dart');
2740 2795
2741 final Compiler compiler; 2796 final Compiler compiler;
2742 2797
2743 ClassElement expectNoInlineClass; 2798 ClassElement expectNoInlineClass;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 } 3069 }
3015 } 3070 }
3016 3071
3017 /// Records that [constant] is used by the element behind [registry]. 3072 /// Records that [constant] is used by the element behind [registry].
3018 class Dependency { 3073 class Dependency {
3019 final ConstantValue constant; 3074 final ConstantValue constant;
3020 final Element annotatedElement; 3075 final Element annotatedElement;
3021 3076
3022 const Dependency(this.constant, this.annotatedElement); 3077 const Dependency(this.constant, this.annotatedElement);
3023 } 3078 }
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