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

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

Issue 3007623002: Fix many bugs with closure conversion in checked mode. (Closed)
Patch Set: Review 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
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/closure/rewriter.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 AsyncMarker, 9 AsyncMarker,
10 Arguments, 10 Arguments,
11 Block, 11 Block,
12 Catch, 12 Catch,
13 Class, 13 Class,
14 ClosureCreation, 14 ClosureCreation,
15 Constructor, 15 Constructor,
16 DartType, 16 DartType,
17 DoStatement, 17 DoStatement,
18 DynamicType,
18 EmptyStatement, 19 EmptyStatement,
19 Expression, 20 Expression,
20 ExpressionStatement, 21 ExpressionStatement,
21 Field, 22 Field,
22 ForInStatement, 23 ForInStatement,
23 ForStatement, 24 ForStatement,
24 FunctionDeclaration, 25 FunctionDeclaration,
25 FunctionExpression, 26 FunctionExpression,
26 FunctionNode, 27 FunctionNode,
27 FunctionType, 28 FunctionType,
(...skipping 18 matching lines...) Expand all
46 StaticInvocation, 47 StaticInvocation,
47 ThisExpression, 48 ThisExpression,
48 Transformer, 49 Transformer,
49 TreeNode, 50 TreeNode,
50 TypeParameter, 51 TypeParameter,
51 TypeParameterType, 52 TypeParameterType,
52 VariableDeclaration, 53 VariableDeclaration,
53 VariableGet, 54 VariableGet,
54 VariableSet, 55 VariableSet,
55 VectorCreation, 56 VectorCreation,
56 VectorType,
57 WhileStatement, 57 WhileStatement,
58 transformList; 58 transformList;
59 59
60 import '../../frontend/accessors.dart' show VariableAccessor; 60 import '../../frontend/accessors.dart' show VariableAccessor;
61 61
62 import '../../clone.dart' show CloneVisitor; 62 import '../../clone.dart' show CloneVisitor;
63 63
64 import '../../core_types.dart' show CoreTypes; 64 import '../../core_types.dart' show CoreTypes;
65 65
66 import '../../type_algebra.dart' show substitute; 66 import '../../type_algebra.dart' show substitute;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 FunctionNode enclosingFunction = currentFunction; 364 FunctionNode enclosingFunction = currentFunction;
365 Map<TypeParameter, DartType> enclosingTypeSubstitution = typeSubstitution; 365 Map<TypeParameter, DartType> enclosingTypeSubstitution = typeSubstitution;
366 currentFunction = function; 366 currentFunction = function;
367 Statement body = function.body; 367 Statement body = function.body;
368 assert(body != null); 368 assert(body != null);
369 369
370 rewriter = makeRewriterForBody(function); 370 rewriter = makeRewriterForBody(function);
371 371
372 VariableDeclaration contextVariable = 372 VariableDeclaration contextVariable =
373 new VariableDeclaration("#contextParameter", type: const VectorType()); 373 new VariableDeclaration("#contextParameter", type: const DynamicType());
374 Context parent = context; 374 Context parent = context;
375 context = context.toNestedContext( 375 context = context.toNestedContext(
376 new VariableAccessor(contextVariable, null, TreeNode.noOffset)); 376 new VariableAccessor(contextVariable, null, TreeNode.noOffset));
377 377
378 Set<TypeParameter> captured = 378 Set<TypeParameter> captured =
379 capturedTypeVariables[currentFunction] ?? new Set<TypeParameter>(); 379 capturedTypeVariables[currentFunction] ?? new Set<TypeParameter>();
380 typeSubstitution = copyTypeVariables(captured); 380 typeSubstitution = copyTypeVariables(captured);
381 381
382 function.transformChildren(this); 382 function.transformChildren(this);
383 383
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 copy.function.body.parent = copy.function; 839 copy.function.body.parent = copy.function;
840 return copy; 840 return copy;
841 } 841 }
842 842
843 void addGetterForwarder(Name name, Procedure getter) { 843 void addGetterForwarder(Name name, Procedure getter) {
844 assert(getter.isGetter); 844 assert(getter.isGetter);
845 newClassMembers 845 newClassMembers
846 .add(copyWithBody(getter, forwardToThisProperty(getter))..name = name); 846 .add(copyWithBody(getter, forwardToThisProperty(getter))..name = name);
847 } 847 }
848 } 848 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/closure/rewriter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698