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

Side by Side Diff: pkg/kernel/lib/transformations/closure/converter.dart

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Temporarily disable Run step in closures test suite Created 3 years, 5 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
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/closure/info.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) 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.closure.converter; 5 library kernel.transformations.closure.converter;
6 6
7 import '../../ast.dart' 7 import '../../ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 Block, 10 Block,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 body = new Block(<Statement>[body]); 229 body = new Block(<Statement>[body]);
230 function.body = function.body.parent = body; 230 function.body = function.body.parent = body;
231 } 231 }
232 return new BlockRewriter(body); 232 return new BlockRewriter(body);
233 } 233 }
234 234
235 bool isObject(DartType type) { 235 bool isObject(DartType type) {
236 return type is InterfaceType && type.classNode.supertype == null; 236 return type is InterfaceType && type.classNode.supertype == null;
237 } 237 }
238 238
239 TreeNode visitField(Field node) {
240 currentMember = node;
241 context = new NoContext(this);
242 node = super.visitField(node);
243 context = null;
244 currentMember = null;
245 return node;
246 }
247
239 Expression handleLocalFunction(FunctionNode function) { 248 Expression handleLocalFunction(FunctionNode function) {
240 FunctionNode enclosingFunction = currentFunction; 249 FunctionNode enclosingFunction = currentFunction;
241 Map<TypeParameter, DartType> enclosingTypeSubstitution = typeSubstitution; 250 Map<TypeParameter, DartType> enclosingTypeSubstitution = typeSubstitution;
242 currentFunction = function; 251 currentFunction = function;
243 Statement body = function.body; 252 Statement body = function.body;
244 assert(body != null); 253 assert(body != null);
245 254
246 rewriter = makeRewriterForBody(function); 255 rewriter = makeRewriterForBody(function);
247 256
248 VariableDeclaration contextVariable = 257 VariableDeclaration contextVariable =
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 .forEach(extendContextWith); 432 .forEach(extendContextWith);
424 assert(node.body != null); 433 assert(node.body != null);
425 node.body = node.body.accept(this); 434 node.body = node.body.accept(this);
426 node.body.parent = node; 435 node.body.parent = node;
427 return node; 436 return node;
428 } 437 }
429 438
430 TreeNode visitBlock(Block node) { 439 TreeNode visitBlock(Block node) {
431 return saveContext(() { 440 return saveContext(() {
432 BlockRewriter blockRewriter = rewriter = rewriter.forNestedBlock(node); 441 BlockRewriter blockRewriter = rewriter = rewriter.forNestedBlock(node);
433 blockRewriter.transformStatements(node, this); 442 blockRewriter.transformStatements(this);
434 return node; 443 return node;
435 }); 444 });
436 } 445 }
437 446
438 TreeNode visitVariableDeclaration(VariableDeclaration node) { 447 TreeNode visitVariableDeclaration(VariableDeclaration node) {
439 node.transformChildren(this); 448 node.transformChildren(this);
440 449
441 if (!capturedVariables.contains(node)) return node; 450 if (!capturedVariables.contains(node)) return node;
442 if (node.initializer == null && node.parent is FunctionNode) { 451 if (node.initializer == null && node.parent is FunctionNode) {
443 // If the variable is a function parameter and doesn't have an 452 // If the variable is a function parameter and doesn't have an
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 copy.function.body.parent = copy.function; 702 copy.function.body.parent = copy.function;
694 return copy; 703 return copy;
695 } 704 }
696 705
697 void addGetterForwarder(Name name, Procedure getter) { 706 void addGetterForwarder(Name name, Procedure getter) {
698 assert(getter.isGetter); 707 assert(getter.isGetter);
699 newClassMembers 708 newClassMembers
700 .add(copyWithBody(getter, forwardToThisProperty(getter))..name = name); 709 .add(copyWithBody(getter, forwardToThisProperty(getter))..name = name);
701 } 710 }
702 } 711 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/closure/info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698