| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 closureToClassMapper; | 5 library closureToClassMapper; |
| 6 | 6 |
| 7 import 'common.dart'; | 7 import 'common.dart'; |
| 8 import 'common/names.dart' show Identifiers; | 8 import 'common/names.dart' show Identifiers; |
| 9 import 'common/resolution.dart' show ParsingContext, Resolution; | 9 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 10 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 bool isCapturedVariable(VariableElement variable) { | 374 bool isCapturedVariable(VariableElement variable) { |
| 375 return capturedVariables.containsKey(variable); | 375 return capturedVariables.containsKey(variable); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void forEachCapturedVariable( | 378 void forEachCapturedVariable( |
| 379 f(LocalVariableElement variable, BoxFieldElement boxField)) { | 379 f(LocalVariableElement variable, BoxFieldElement boxField)) { |
| 380 capturedVariables.forEach(f); | 380 capturedVariables.forEach(f); |
| 381 } | 381 } |
| 382 | 382 |
| 383 String toString() { | 383 String toString() { |
| 384 String separator = ''; |
| 384 StringBuffer sb = new StringBuffer(); | 385 StringBuffer sb = new StringBuffer(); |
| 386 sb.write('ClosureScope('); |
| 385 if (boxElement != null) { | 387 if (boxElement != null) { |
| 386 sb.write('box=$boxElement'); | 388 sb.write('box=$boxElement'); |
| 389 separator = ','; |
| 387 } | 390 } |
| 388 if (boxedLoopVariables.isNotEmpty) { | 391 if (boxedLoopVariables.isNotEmpty) { |
| 389 if (sb.isNotEmpty) { | 392 sb.write(separator); |
| 390 sb.write(','); | |
| 391 } | |
| 392 sb.write('boxedLoopVariables=${boxedLoopVariables}'); | 393 sb.write('boxedLoopVariables=${boxedLoopVariables}'); |
| 394 separator = ','; |
| 393 } | 395 } |
| 394 if (capturedVariables.isNotEmpty) { | 396 if (capturedVariables.isNotEmpty) { |
| 395 if (sb.isNotEmpty) { | 397 sb.write(separator); |
| 396 sb.write(','); | 398 sb.write('capturedVariables=$capturedVariables'); |
| 397 } | |
| 398 sb.write('capturedVariables='); | |
| 399 capturedVariables.forEach((Local local, BoxFieldElement field) { | |
| 400 sb.write('$local->${field} '); | |
| 401 }); | |
| 402 } | 399 } |
| 400 sb.write(')'); |
| 403 return sb.toString(); | 401 return sb.toString(); |
| 404 } | 402 } |
| 405 } | 403 } |
| 406 | 404 |
| 407 class ClosureClassMap { | 405 class ClosureClassMap { |
| 408 // The closure's element before any translation. Will be null for methods. | 406 // The closure's element before any translation. Will be null for methods. |
| 409 final LocalFunctionElement closureElement; | 407 final LocalFunctionElement closureElement; |
| 410 // The closureClassElement will be null for methods that are not local | 408 // The closureClassElement will be null for methods that are not local |
| 411 // closures. | 409 // closures. |
| 412 final ClosureClassElement closureClassElement; | 410 final ClosureClassElement closureClassElement; |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 /// | 1167 /// |
| 1170 /// Move the below classes to a JS model eventually. | 1168 /// Move the below classes to a JS model eventually. |
| 1171 /// | 1169 /// |
| 1172 abstract class JSEntity implements Entity { | 1170 abstract class JSEntity implements Entity { |
| 1173 Entity get declaredEntity; | 1171 Entity get declaredEntity; |
| 1174 } | 1172 } |
| 1175 | 1173 |
| 1176 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1174 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1177 Entity get rootOfScope; | 1175 Entity get rootOfScope; |
| 1178 } | 1176 } |
| OLD | NEW |