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

Side by Side Diff: pkg/compiler/lib/src/compiler.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: Address comments 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
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 world.registerStaticUse(element); 169 world.registerStaticUse(element);
170 } 170 }
171 171
172 void registerDirectInvocation(Element element) { 172 void registerDirectInvocation(Element element) {
173 world.registerStaticUse(element); 173 world.registerStaticUse(element);
174 } 174 }
175 175
176 void registerInstantiation(InterfaceType type) { 176 void registerInstantiation(InterfaceType type) {
177 world.registerInstantiatedType(type, this); 177 world.registerInstantiatedType(type, this);
178 } 178 }
179
180 void registerAsyncMarker(FunctionElement element) {
181 backend.registerAsyncMarker(element, world, this);
182 }
183
179 } 184 }
180 185
181 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. 186 /// [WorkItem] used exclusively by the [CodegenEnqueuer].
182 class CodegenWorkItem extends WorkItem { 187 class CodegenWorkItem extends WorkItem {
183 Registry registry; 188 Registry registry;
184 final TreeElements resolutionTree; 189 final TreeElements resolutionTree;
185 190
186 CodegenWorkItem(AstElement element, 191 CodegenWorkItem(AstElement element,
187 ItemCompilationContext compilationContext) 192 ItemCompilationContext compilationContext)
188 : this.resolutionTree = element.resolvedAst.elements, 193 : this.resolutionTree = element.resolvedAst.elements,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 227
223 void registerDynamicGetter(Selector selector); 228 void registerDynamicGetter(Selector selector);
224 229
225 void registerDynamicSetter(Selector selector); 230 void registerDynamicSetter(Selector selector);
226 231
227 void registerStaticInvocation(Element element); 232 void registerStaticInvocation(Element element);
228 233
229 void registerInstantiation(InterfaceType type); 234 void registerInstantiation(InterfaceType type);
230 235
231 void registerGetOfStaticFunction(FunctionElement element); 236 void registerGetOfStaticFunction(FunctionElement element);
237
238 void registerAsyncMarker(FunctionElement element);
232 } 239 }
233 240
234 abstract class Backend { 241 abstract class Backend {
235 final Compiler compiler; 242 final Compiler compiler;
236 243
237 Backend(this.compiler); 244 Backend(this.compiler);
238 245
239 /// The [ConstantSystem] used to interpret compile-time constants for this 246 /// The [ConstantSystem] used to interpret compile-time constants for this
240 /// backend. 247 /// backend.
241 ConstantSystem get constantSystem; 248 ConstantSystem get constantSystem;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 516
510 FunctionElement helperForBadMain() => null; 517 FunctionElement helperForBadMain() => null;
511 518
512 FunctionElement helperForMissingMain() => null; 519 FunctionElement helperForMissingMain() => null;
513 520
514 FunctionElement helperForMainArity() => null; 521 FunctionElement helperForMainArity() => null;
515 522
516 void forgetElement(Element element) {} 523 void forgetElement(Element element) {}
517 524
518 void registerMainHasArguments(Enqueuer enqueuer) {} 525 void registerMainHasArguments(Enqueuer enqueuer) {}
526
527 void registerAsyncMarker(FunctionElement element,
528 Enqueuer enqueuer,
529 Registry registry) {}
519 } 530 }
520 531
521 /// Backend callbacks function specific to the resolution phase. 532 /// Backend callbacks function specific to the resolution phase.
522 class ResolutionCallbacks { 533 class ResolutionCallbacks {
523 /// Register that [node] is a call to `assert`. 534 /// Register that [node] is a call to `assert`.
524 void onAssert(Send node, Registry registry) {} 535 void onAssert(Send node, Registry registry) {}
525 536
526 /// Called during resolution to notify to the backend that the 537 /// Called during resolution to notify to the backend that the
527 /// program uses string interpolation. 538 /// program uses string interpolation.
528 void onStringInterpolation(Registry registry) {} 539 void onStringInterpolation(Registry registry) {}
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 /// `true` if the last diagnostic was filtered, in which case the 744 /// `true` if the last diagnostic was filtered, in which case the
734 /// accompanying info message should be filtered as well. 745 /// accompanying info message should be filtered as well.
735 bool lastDiagnosticWasFiltered = false; 746 bool lastDiagnosticWasFiltered = false;
736 747
737 /// Map containing information about the warnings and hints that have been 748 /// Map containing information about the warnings and hints that have been
738 /// suppressed for each library. 749 /// suppressed for each library.
739 Map<Uri, SuppressionInfo> suppressedWarnings = <Uri, SuppressionInfo>{}; 750 Map<Uri, SuppressionInfo> suppressedWarnings = <Uri, SuppressionInfo>{};
740 751
741 final bool suppressWarnings; 752 final bool suppressWarnings;
742 753
743 /// `true` if async/await features are supported.
744 final bool enableAsyncAwait;
745
746 /// `true` if the compiler uses the [JavaScriptBackend].
747 final bool emitJavaScript;
748
749 /// If `true`, some values are cached for reuse in incremental compilation. 754 /// If `true`, some values are cached for reuse in incremental compilation.
750 /// Incremental compilation is basically calling [run] more than once. 755 /// Incremental compilation is basically calling [run] more than once.
751 final bool hasIncrementalSupport; 756 final bool hasIncrementalSupport;
752 757
753 /// If `true` native extension syntax is supported by the frontend. 758 /// If `true` native extension syntax is supported by the frontend.
754 final bool allowNativeExtensions; 759 final bool allowNativeExtensions;
755 760
756 /// Output provider from user of Compiler API. 761 /// Output provider from user of Compiler API.
757 api.CompilerOutputProvider userOutputProvider; 762 api.CompilerOutputProvider userOutputProvider;
758 763
759 /// Generate output even when there are compile-time errors. 764 /// Generate output even when there are compile-time errors.
760 final bool generateCodeWithCompileTimeErrors; 765 final bool generateCodeWithCompileTimeErrors;
761 766
762 bool disableInlining = false; 767 bool disableInlining = false;
763 768
764 List<Uri> librariesToAnalyzeWhenRun; 769 List<Uri> librariesToAnalyzeWhenRun;
765 770
766 Tracer tracer; 771 Tracer tracer;
767 772
768 CompilerTask measuredTask; 773 CompilerTask measuredTask;
769 Element _currentElement; 774 Element _currentElement;
770 LibraryElement coreLibrary; 775 LibraryElement coreLibrary;
776 LibraryElement asyncLibrary;
771 777
772 LibraryElement mainApp; 778 LibraryElement mainApp;
773 FunctionElement mainFunction; 779 FunctionElement mainFunction;
774 780
775 /// Initialized when dart:mirrors is loaded. 781 /// Initialized when dart:mirrors is loaded.
776 LibraryElement mirrorsLibrary; 782 LibraryElement mirrorsLibrary;
777 783
778 /// Initialized when dart:typed_data is loaded. 784 /// Initialized when dart:typed_data is loaded.
779 LibraryElement typedDataLibrary; 785 LibraryElement typedDataLibrary;
780 786
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 this.outputUri: null, 1006 this.outputUri: null,
1001 this.buildId: UNDETERMINED_BUILD_ID, 1007 this.buildId: UNDETERMINED_BUILD_ID,
1002 this.terseDiagnostics: false, 1008 this.terseDiagnostics: false,
1003 this.deferredMapUri: null, 1009 this.deferredMapUri: null,
1004 this.dumpInfo: false, 1010 this.dumpInfo: false,
1005 this.showPackageWarnings: false, 1011 this.showPackageWarnings: false,
1006 this.useContentSecurityPolicy: false, 1012 this.useContentSecurityPolicy: false,
1007 this.suppressWarnings: false, 1013 this.suppressWarnings: false,
1008 bool hasIncrementalSupport: false, 1014 bool hasIncrementalSupport: false,
1009 this.enableExperimentalMirrors: false, 1015 this.enableExperimentalMirrors: false,
1010 bool enableAsyncAwait: false,
1011 this.allowNativeExtensions: false, 1016 this.allowNativeExtensions: false,
1012 this.generateCodeWithCompileTimeErrors: false, 1017 this.generateCodeWithCompileTimeErrors: false,
1013 api.CompilerOutputProvider outputProvider, 1018 api.CompilerOutputProvider outputProvider,
1014 List<String> strips: const []}) 1019 List<String> strips: const []})
1015 : this.emitJavaScript = emitJavaScript, 1020 : this.disableTypeInferenceFlag =
1016 this.enableAsyncAwait = enableAsyncAwait || !emitJavaScript,
1017 this.disableTypeInferenceFlag =
1018 disableTypeInferenceFlag || !emitJavaScript, 1021 disableTypeInferenceFlag || !emitJavaScript,
1019 this.analyzeOnly = 1022 this.analyzeOnly =
1020 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, 1023 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag,
1021 this.analyzeSignaturesOnly = analyzeSignaturesOnly, 1024 this.analyzeSignaturesOnly = analyzeSignaturesOnly,
1022 this.analyzeAllFlag = analyzeAllFlag, 1025 this.analyzeAllFlag = analyzeAllFlag,
1023 this.hasIncrementalSupport = hasIncrementalSupport, 1026 this.hasIncrementalSupport = hasIncrementalSupport,
1024 cacheStrategy = new CacheStrategy(hasIncrementalSupport), 1027 cacheStrategy = new CacheStrategy(hasIncrementalSupport),
1025 this.userOutputProvider = (outputProvider == null) 1028 this.userOutputProvider = (outputProvider == null)
1026 ? NullSink.outputProvider 1029 ? NullSink.outputProvider
1027 : outputProvider { 1030 : outputProvider {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 Uri uri = library.canonicalUri; 1238 Uri uri = library.canonicalUri;
1236 if (uri == DART_CORE) { 1239 if (uri == DART_CORE) {
1237 initializeCoreClasses(); 1240 initializeCoreClasses();
1238 identicalFunction = coreLibrary.find('identical'); 1241 identicalFunction = coreLibrary.find('identical');
1239 } else if (uri == DART_INTERNAL) { 1242 } else if (uri == DART_INTERNAL) {
1240 symbolImplementationClass = findRequiredElement(library, 'Symbol'); 1243 symbolImplementationClass = findRequiredElement(library, 'Symbol');
1241 } else if (uri == DART_MIRRORS) { 1244 } else if (uri == DART_MIRRORS) {
1242 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); 1245 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem');
1243 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); 1246 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed');
1244 } else if (uri == DART_ASYNC) { 1247 } else if (uri == DART_ASYNC) {
1248 asyncLibrary = library;
1245 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); 1249 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary');
1246 _coreTypes.futureClass = findRequiredElement(library, 'Future'); 1250 _coreTypes.futureClass = findRequiredElement(library, 'Future');
1247 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); 1251 _coreTypes.streamClass = findRequiredElement(library, 'Stream');
1248 } else if (uri == DART_NATIVE_TYPED_DATA) { 1252 } else if (uri == DART_NATIVE_TYPED_DATA) {
1249 typedDataClass = findRequiredElement(library, 'NativeTypedData'); 1253 typedDataClass = findRequiredElement(library, 'NativeTypedData');
1250 } else if (uri == js_backend.JavaScriptBackend.DART_JS_HELPER) { 1254 } else if (uri == js_backend.JavaScriptBackend.DART_JS_HELPER) {
1251 patchAnnotationClass = findRequiredElement(library, '_Patch'); 1255 patchAnnotationClass = findRequiredElement(library, '_Patch');
1252 nativeAnnotationClass = findRequiredElement(library, 'Native'); 1256 nativeAnnotationClass = findRequiredElement(library, 'Native');
1253 } 1257 }
1254 return backend.onLibraryScanned(library, loader); 1258 return backend.onLibraryScanned(library, loader);
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 return futureClass.computeType(compiler).createInstantiation([elementType]); 2411 return futureClass.computeType(compiler).createInstantiation([elementType]);
2408 } 2412 }
2409 2413
2410 @override 2414 @override
2411 InterfaceType streamType([DartType elementType = const DynamicType()]) { 2415 InterfaceType streamType([DartType elementType = const DynamicType()]) {
2412 return streamClass.computeType(compiler).createInstantiation([elementType]); 2416 return streamClass.computeType(compiler).createInstantiation([elementType]);
2413 } 2417 }
2414 } 2418 }
2415 2419
2416 typedef void InternalErrorFunction(Spannable location, String message); 2420 typedef void InternalErrorFunction(Spannable location, String message);
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698