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

Side by Side Diff: pkg/kernel/lib/transformations/continuation.dart

Issue 2680303002: Kernel debugging; service tests (Closed)
Patch Set: New failing test Created 3 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
OLDNEW
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // return new _SyncIterable(:sync_body); 140 // return new _SyncIterable(:sync_body);
141 final arguments = new Arguments([new VariableGet(nestedClosureVariable)]); 141 final arguments = new Arguments([new VariableGet(nestedClosureVariable)]);
142 final returnStatement = new ReturnStatement( 142 final returnStatement = new ReturnStatement(
143 new ConstructorInvocation(helper.syncIterableConstructor, arguments)); 143 new ConstructorInvocation(helper.syncIterableConstructor, arguments));
144 144
145 enclosingFunction.body = new Block([] 145 enclosingFunction.body = new Block([]
146 ..addAll(variableDeclarations()) 146 ..addAll(variableDeclarations())
147 ..addAll([closureFunction, returnStatement])); 147 ..addAll([closureFunction, returnStatement]));
148 enclosingFunction.body.parent = enclosingFunction; 148 enclosingFunction.body.parent = enclosingFunction;
149 enclosingFunction.asyncMarker = AsyncMarker.Sync; 149 enclosingFunction.asyncMarker = AsyncMarker.Sync;
150 enclosingFunction.debuggable = false;
150 return enclosingFunction; 151 return enclosingFunction;
151 } 152 }
152 153
153 Statement buildClosureBody() { 154 Statement buildClosureBody() {
154 // The body will insert calls to 155 // The body will insert calls to
155 // :iterator.current_= 156 // :iterator.current_=
156 // :iterator.isYieldEach= 157 // :iterator.isYieldEach=
157 // and return `true` as long as it did something and `false` when it's done. 158 // and return `true` as long as it did something and `false` when it's done.
158 return new Block(<Statement>[ 159 return new Block(<Statement>[
159 enclosingFunction.body.accept(this), 160 enclosingFunction.body.accept(this),
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 693
693 // return :controller.stream; 694 // return :controller.stream;
694 var completerGet = new VariableGet(controllerVariable); 695 var completerGet = new VariableGet(controllerVariable);
695 var returnStatement = new ReturnStatement( 696 var returnStatement = new ReturnStatement(
696 new PropertyGet(completerGet, new Name('stream', helper.asyncLibrary))); 697 new PropertyGet(completerGet, new Name('stream', helper.asyncLibrary)));
697 statements.add(returnStatement); 698 statements.add(returnStatement);
698 699
699 enclosingFunction.body = new Block(statements); 700 enclosingFunction.body = new Block(statements);
700 enclosingFunction.body.parent = enclosingFunction; 701 enclosingFunction.body.parent = enclosingFunction;
701 enclosingFunction.asyncMarker = AsyncMarker.Sync; 702 enclosingFunction.asyncMarker = AsyncMarker.Sync;
703 enclosingFunction.debuggable = false;
702 return enclosingFunction; 704 return enclosingFunction;
703 } 705 }
704 706
705 Statement buildWrappedBody() { 707 Statement buildWrappedBody() {
706 ++currentTryDepth; 708 ++currentTryDepth;
707 Statement body = super.buildWrappedBody(); 709 Statement body = super.buildWrappedBody();
708 --currentTryDepth; 710 --currentTryDepth;
709 711
710 var finallyBody = new ExpressionStatement(new MethodInvocation( 712 var finallyBody = new ExpressionStatement(new MethodInvocation(
711 new VariableGet(controllerVariable), 713 new VariableGet(controllerVariable),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 new Name("complete", helper.asyncLibrary), 847 new Name("complete", helper.asyncLibrary),
846 new Arguments([new VariableGet(returnVariable)]))), 848 new Arguments([new VariableGet(returnVariable)]))),
847 new ReturnStatement()..fileOffset = enclosingFunction.fileEndOffset 849 new ReturnStatement()..fileOffset = enclosingFunction.fileEndOffset
848 ]); 850 ]);
849 } 851 }
850 852
851 visitReturnStatement(ReturnStatement node) { 853 visitReturnStatement(ReturnStatement node) {
852 var expr = node.expression == null 854 var expr = node.expression == null
853 ? new NullLiteral() 855 ? new NullLiteral()
854 : expressionRewriter.rewrite(node.expression, statements); 856 : expressionRewriter.rewrite(node.expression, statements);
855 statements 857 statements.add(new ExpressionStatement(
856 .add(new ExpressionStatement(new VariableSet(returnVariable, expr))); 858 new VariableSet(returnVariable, expr)..fileOffset = node.fileOffset));
857 statements 859 statements.add(new BreakStatement(labeledBody));
858 .add(new BreakStatement(labeledBody)..fileOffset = node.fileOffset);
859 return null; 860 return null;
860 } 861 }
861 } 862 }
862 863
863 class HelperNodes { 864 class HelperNodes {
864 final Library asyncLibrary; 865 final Library asyncLibrary;
865 final Library coreLibrary; 866 final Library coreLibrary;
866 final Class iteratorClass; 867 final Class iteratorClass;
867 final Class futureClass; 868 final Class futureClass;
868 final Class completerClass; 869 final Class completerClass;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 findConstructor(syncIterableClass, ''), 971 findConstructor(syncIterableClass, ''),
971 findConstructor(streamIteratorClass, ''), 972 findConstructor(streamIteratorClass, ''),
972 findFactoryConstructor(futureClass, 'microtask'), 973 findFactoryConstructor(futureClass, 'microtask'),
973 findConstructor(streamControllerClass, ''), 974 findConstructor(streamControllerClass, ''),
974 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'), 975 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'),
975 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'), 976 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'),
976 findProcedure(asyncLibrary, '_awaitHelper'), 977 findProcedure(asyncLibrary, '_awaitHelper'),
977 new CoreTypes(program)); 978 new CoreTypes(program));
978 } 979 }
979 } 980 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698