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

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

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Comments. Created 3 years, 3 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.closure.invalidate; 5 library kernel.transformations.closure.invalidate;
6 6
7 import '../../ast.dart'; 7 import '../../ast.dart';
8 8
9 class InvalidateClosures extends Transformer { 9 class InvalidateClosures extends Transformer {
10 FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) { 10 FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) {
11 invalidate(node.function); 11 invalidate(node.function);
12 return node; 12 return node;
13 } 13 }
14 14
15 FunctionExpression visitFunctionExpression(FunctionExpression node) { 15 FunctionExpression visitFunctionExpression(FunctionExpression node) {
16 invalidate(node.function); 16 invalidate(node.function);
17 return node; 17 return node;
18 } 18 }
19 19
20 void invalidate(FunctionNode function) { 20 void invalidate(FunctionNode function) {
21 if (function.asyncMarker != AsyncMarker.Sync) return;
21 var position = function.location; 22 var position = function.location;
22 function.body = new ExpressionStatement(new Throw( 23 function.body = new ExpressionStatement(new Throw(
23 new StringLiteral("Calling unconverted closure at $position"))) 24 new StringLiteral("Calling unconverted closure at $position")))
24 ..parent = function; 25 ..parent = function;
25 } 26 }
26 } 27 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | pkg/kernel/testcases/closures/arity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698