| OLD | NEW | 
|---|
| 1 // Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.transformations.continuation; | 5 library kernel.transformations.continuation; | 
| 6 | 6 | 
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; | 
| 8 | 8 | 
| 9 import '../ast.dart'; | 9 import '../ast.dart'; | 
| 10 import '../core_types.dart'; | 10 import '../core_types.dart'; | 
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 787       if (future_type.classNode == helper.futureClass) { | 787       if (future_type.classNode == helper.futureClass) { | 
| 788         if (future_type.typeArguments.length == 0) { | 788         if (future_type.typeArguments.length == 0) { | 
| 789           returnType = const DynamicType(); | 789           returnType = const DynamicType(); | 
| 790         } else if (future_type.typeArguments.length == 1) { | 790         } else if (future_type.typeArguments.length == 1) { | 
| 791           returnType = future_type.typeArguments[0]; | 791           returnType = future_type.typeArguments[0]; | 
| 792         } else { | 792         } else { | 
| 793           returnType = const InvalidType(); | 793           returnType = const InvalidType(); | 
| 794         } | 794         } | 
| 795       } | 795       } | 
| 796     } | 796     } | 
|  | 797     // In an "Future<FooBar> foo() async {}" function the body can either return | 
|  | 798     // a "FooBar" or a "Future<FooBar>" => a "FutureOr<FooBar>". | 
|  | 799     returnType = | 
|  | 800         new InterfaceType(helper.futureOrClass, <DartType>[returnType]); | 
| 797     var completerTypeArguments = <DartType>[returnType]; | 801     var completerTypeArguments = <DartType>[returnType]; | 
| 798     var completerType = | 802     var completerType = | 
| 799         new InterfaceType(helper.completerClass, completerTypeArguments); | 803         new InterfaceType(helper.completerClass, completerTypeArguments); | 
| 800 | 804 | 
| 801     // final Completer<T> :completer = new Completer<T>.sync(); | 805     // final Completer<T> :completer = new Completer<T>.sync(); | 
| 802     completerVariable = new VariableDeclaration(":completer", | 806     completerVariable = new VariableDeclaration(":completer", | 
| 803         initializer: new StaticInvocation(helper.completerConstructor, | 807         initializer: new StaticInvocation(helper.completerConstructor, | 
| 804             new Arguments([], types: completerTypeArguments)) | 808             new Arguments([], types: completerTypeArguments)) | 
| 805           ..fileOffset = enclosingFunction.body.fileOffset, | 809           ..fileOffset = enclosingFunction.body.fileOffset, | 
| 806         isFinal: true, | 810         isFinal: true, | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 864     statements.add(new BreakStatement(labeledBody)); | 868     statements.add(new BreakStatement(labeledBody)); | 
| 865     return null; | 869     return null; | 
| 866   } | 870   } | 
| 867 } | 871 } | 
| 868 | 872 | 
| 869 class HelperNodes { | 873 class HelperNodes { | 
| 870   final Library asyncLibrary; | 874   final Library asyncLibrary; | 
| 871   final Library coreLibrary; | 875   final Library coreLibrary; | 
| 872   final Class iteratorClass; | 876   final Class iteratorClass; | 
| 873   final Class futureClass; | 877   final Class futureClass; | 
|  | 878   final Class futureOrClass; | 
| 874   final Class completerClass; | 879   final Class completerClass; | 
| 875   final Procedure printProcedure; | 880   final Procedure printProcedure; | 
| 876   final Procedure completerConstructor; | 881   final Procedure completerConstructor; | 
| 877   final Procedure futureMicrotaskConstructor; | 882   final Procedure futureMicrotaskConstructor; | 
| 878   final Constructor streamControllerConstructor; | 883   final Constructor streamControllerConstructor; | 
| 879   final Constructor syncIterableConstructor; | 884   final Constructor syncIterableConstructor; | 
| 880   final Constructor streamIteratorConstructor; | 885   final Constructor streamIteratorConstructor; | 
| 881   final Procedure asyncThenWrapper; | 886   final Procedure asyncThenWrapper; | 
| 882   final Procedure asyncErrorWrapper; | 887   final Procedure asyncErrorWrapper; | 
| 883   final Procedure awaitHelper; | 888   final Procedure awaitHelper; | 
| 884   final CoreTypes coreTypes; | 889   final CoreTypes coreTypes; | 
| 885 | 890 | 
| 886   HelperNodes( | 891   HelperNodes( | 
| 887       this.asyncLibrary, | 892       this.asyncLibrary, | 
| 888       this.coreLibrary, | 893       this.coreLibrary, | 
| 889       this.iteratorClass, | 894       this.iteratorClass, | 
| 890       this.futureClass, | 895       this.futureClass, | 
|  | 896       this.futureOrClass, | 
| 891       this.completerClass, | 897       this.completerClass, | 
| 892       this.printProcedure, | 898       this.printProcedure, | 
| 893       this.completerConstructor, | 899       this.completerConstructor, | 
| 894       this.syncIterableConstructor, | 900       this.syncIterableConstructor, | 
| 895       this.streamIteratorConstructor, | 901       this.streamIteratorConstructor, | 
| 896       this.futureMicrotaskConstructor, | 902       this.futureMicrotaskConstructor, | 
| 897       this.streamControllerConstructor, | 903       this.streamControllerConstructor, | 
| 898       this.asyncThenWrapper, | 904       this.asyncThenWrapper, | 
| 899       this.asyncErrorWrapper, | 905       this.asyncErrorWrapper, | 
| 900       this.awaitHelper, | 906       this.awaitHelper, | 
| 901       this.coreTypes); | 907       this.coreTypes); | 
| 902 | 908 | 
| 903   factory HelperNodes.fromProgram(Program program) { | 909   factory HelperNodes.fromProgram(Program program) { | 
| 904     var coreTypes = new CoreTypes(program); | 910     var coreTypes = new CoreTypes(program); | 
| 905     return new HelperNodes( | 911     return new HelperNodes( | 
| 906         coreTypes.getLibrary('dart:async'), | 912         coreTypes.getLibrary('dart:async'), | 
| 907         coreTypes.getLibrary('dart:core'), | 913         coreTypes.getLibrary('dart:core'), | 
| 908         coreTypes.getClass('dart:core', 'Iterator'), | 914         coreTypes.getClass('dart:core', 'Iterator'), | 
| 909         coreTypes.getClass('dart:async', 'Future'), | 915         coreTypes.getClass('dart:async', 'Future'), | 
|  | 916         coreTypes.getClass('dart:async', 'FutureOr'), | 
| 910         coreTypes.getClass('dart:async', 'Completer'), | 917         coreTypes.getClass('dart:async', 'Completer'), | 
| 911         coreTypes.getTopLevelMember('dart:core', 'print'), | 918         coreTypes.getTopLevelMember('dart:core', 'print'), | 
| 912         coreTypes.getMember('dart:async', 'Completer', 'sync'), | 919         coreTypes.getMember('dart:async', 'Completer', 'sync'), | 
| 913         coreTypes.getMember('dart:core', '_SyncIterable', ''), | 920         coreTypes.getMember('dart:core', '_SyncIterable', ''), | 
| 914         coreTypes.getMember('dart:async', '_StreamIterator', ''), | 921         coreTypes.getMember('dart:async', '_StreamIterator', ''), | 
| 915         coreTypes.getMember('dart:async', 'Future', 'microtask'), | 922         coreTypes.getMember('dart:async', 'Future', 'microtask'), | 
| 916         coreTypes.getMember('dart:async', '_AsyncStarStreamController', ''), | 923         coreTypes.getMember('dart:async', '_AsyncStarStreamController', ''), | 
| 917         coreTypes.getTopLevelMember('dart:async', '_asyncThenWrapperHelper'), | 924         coreTypes.getTopLevelMember('dart:async', '_asyncThenWrapperHelper'), | 
| 918         coreTypes.getTopLevelMember('dart:async', '_asyncErrorWrapperHelper'), | 925         coreTypes.getTopLevelMember('dart:async', '_asyncErrorWrapperHelper'), | 
| 919         coreTypes.getTopLevelMember('dart:async', '_awaitHelper'), | 926         coreTypes.getTopLevelMember('dart:async', '_awaitHelper'), | 
| 920         coreTypes); | 927         coreTypes); | 
| 921   } | 928   } | 
| 922 } | 929 } | 
| OLD | NEW | 
|---|