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

Side by Side Diff: pkg/compiler/lib/src/kernel/closure.dart

Issue 2951723002: Add closure_test for kernel based members (Closed)
Patch Set: Cleanup Created 3 years, 6 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common/tasks.dart'; 8 import '../common/tasks.dart';
9 import '../elements/entities.dart'; 9 import '../elements/entities.dart';
10 import '../world.dart'; 10 import '../world.dart';
(...skipping 29 matching lines...) Expand all
40 node.visitChildren(this); 40 node.visitChildren(this);
41 _inTry = oldInTry; 41 _inTry = oldInTry;
42 } 42 }
43 43
44 @override 44 @override
45 visitVariableGet(ir.VariableGet node) { 45 visitVariableGet(ir.VariableGet node) {
46 if (_inTry) { 46 if (_inTry) {
47 info.registerUsedInTryOrSync(_localsMap.getLocal(node.variable)); 47 info.registerUsedInTryOrSync(_localsMap.getLocal(node.variable));
48 } 48 }
49 } 49 }
50
51 @override
52 visitVariableSet(ir.VariableSet node) {
53 if (_inTry) {
54 info.registerUsedInTryOrSync(_localsMap.getLocal(node.variable));
55 }
56 node.visitChildren(this);
57 }
50 } 58 }
51 59
52 /// Closure conversion code using our new Entity model. Closure conversion is 60 /// Closure conversion code using our new Entity model. Closure conversion is
53 /// necessary because the semantics of closures are slightly different in Dart 61 /// necessary because the semantics of closures are slightly different in Dart
54 /// than JavaScript. Closure conversion is separated out into two phases: 62 /// than JavaScript. Closure conversion is separated out into two phases:
55 /// generation of a new (temporary) representation to store where variables need 63 /// generation of a new (temporary) representation to store where variables need
56 /// to be hoisted/captured up at another level to re-write the closure, and then 64 /// to be hoisted/captured up at another level to re-write the closure, and then
57 /// the code generation phase where we generate elements and/or instructions to 65 /// the code generation phase where we generate elements and/or instructions to
58 /// represent this new code path. 66 /// represent this new code path.
59 /// 67 ///
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 final Set<Local> _localsUsedInTryOrSync = new Set<Local>(); 132 final Set<Local> _localsUsedInTryOrSync = new Set<Local>();
125 133
126 KernelClosureRepresentationInfo(this.thisLocal); 134 KernelClosureRepresentationInfo(this.thisLocal);
127 135
128 void registerUsedInTryOrSync(Local local) { 136 void registerUsedInTryOrSync(Local local) {
129 _localsUsedInTryOrSync.add(local); 137 _localsUsedInTryOrSync.add(local);
130 } 138 }
131 139
132 bool variableIsUsedInTryOrSync(Local variable) => 140 bool variableIsUsedInTryOrSync(Local variable) =>
133 _localsUsedInTryOrSync.contains(variable); 141 _localsUsedInTryOrSync.contains(variable);
142
143 String toString() {
144 StringBuffer sb = new StringBuffer();
145 sb.write('this=$thisLocal,');
146 sb.write('localsUsedInTryOrSync={${_localsUsedInTryOrSync.join(', ')}}');
147 return sb.toString();
148 }
134 } 149 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_model/js_strategy.dart ('k') | pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698