| 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 import 'common/names.dart' show Identifiers; | 5 import 'common/names.dart' show Identifiers; |
| 6 import 'common/resolution.dart' show ParsingContext, Resolution; | 6 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 7 import 'common/tasks.dart' show CompilerTask; | 7 import 'common/tasks.dart' show CompilerTask; |
| 8 import 'common.dart'; | 8 import 'common.dart'; |
| 9 import 'compiler.dart' show Compiler; | 9 import 'compiler.dart' show Compiler; |
| 10 import 'constants/expressions.dart'; | 10 import 'constants/expressions.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 /// analyzing a closure's characteristics, most commonly used to influence how | 46 /// analyzing a closure's characteristics, most commonly used to influence how |
| 47 /// code should be generated in SSA builder stage. | 47 /// code should be generated in SSA builder stage. |
| 48 class ClosureAnalysisInfo { | 48 class ClosureAnalysisInfo { |
| 49 const ClosureAnalysisInfo(); | 49 const ClosureAnalysisInfo(); |
| 50 | 50 |
| 51 /// If true, this closure accesses a variable that was defined in an outside | 51 /// If true, this closure accesses a variable that was defined in an outside |
| 52 /// scope and this variable gets modified at some point (sometimes we say that | 52 /// scope and this variable gets modified at some point (sometimes we say that |
| 53 /// variable has been "captured"). In this situation, access to this variable | 53 /// variable has been "captured"). In this situation, access to this variable |
| 54 /// is controlled via a wrapper (box) so that updates to this variable | 54 /// is controlled via a wrapper (box) so that updates to this variable |
| 55 /// are done in a way that is in line with Dart's closure rules. | 55 /// are done in a way that is in line with Dart's closure rules. |
| 56 bool requiresContextBox() => false; | 56 bool get requiresContextBox => false; |
| 57 | 57 |
| 58 /// Accessor to the local environment in which a particular closure node is | 58 /// Accessor to the local environment in which a particular closure node is |
| 59 /// executed. This will encapsulate the value of any variables that have been | 59 /// executed. This will encapsulate the value of any variables that have been |
| 60 /// scoped into this context from outside. This is an accessor to the | 60 /// scoped into this context from outside. This is an accessor to the |
| 61 /// contextBox that [requiresContextBox] is testing is required. | 61 /// contextBox that [requiresContextBox] is testing is required. |
| 62 Local get context => null; | 62 Local get context => null; |
| 63 | 63 |
| 64 /// True if the specified variable has been mutated inside the scope of this | 64 /// True if the specified variable has been mutated inside the scope of this |
| 65 /// closure. | 65 /// closure. |
| 66 bool isCaptured(Local variable) => false; | 66 bool isCaptured(Local variable) => false; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 591 |
| 592 // If the scope is attached to a [For] contains the variables that are | 592 // If the scope is attached to a [For] contains the variables that are |
| 593 // declared in the initializer of the [For] and that need to be boxed. | 593 // declared in the initializer of the [For] and that need to be boxed. |
| 594 // Otherwise contains the empty List. | 594 // Otherwise contains the empty List. |
| 595 List<Local> boxedLoopVariables = const <Local>[]; | 595 List<Local> boxedLoopVariables = const <Local>[]; |
| 596 | 596 |
| 597 ClosureScope(this.boxElement, this.capturedVariables); | 597 ClosureScope(this.boxElement, this.capturedVariables); |
| 598 | 598 |
| 599 Local get context => boxElement; | 599 Local get context => boxElement; |
| 600 | 600 |
| 601 bool requiresContextBox() => capturedVariables.keys.isNotEmpty; | 601 bool get requiresContextBox => capturedVariables.keys.isNotEmpty; |
| 602 | 602 |
| 603 List<Local> get boxedVariables => boxedLoopVariables; | 603 List<Local> get boxedVariables => boxedLoopVariables; |
| 604 | 604 |
| 605 bool get hasBoxedVariables => !boxedLoopVariables.isEmpty; | 605 bool get hasBoxedVariables => !boxedLoopVariables.isEmpty; |
| 606 | 606 |
| 607 bool isCaptured(Local variable) { | 607 bool isCaptured(Local variable) { |
| 608 return capturedVariables.containsKey(variable); | 608 return capturedVariables.containsKey(variable); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void forEachCapturedVariable( | 611 void forEachCapturedVariable( |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 /// | 1444 /// |
| 1445 /// Move the below classes to a JS model eventually. | 1445 /// Move the below classes to a JS model eventually. |
| 1446 /// | 1446 /// |
| 1447 abstract class JSEntity implements MemberEntity { | 1447 abstract class JSEntity implements MemberEntity { |
| 1448 Local get declaredEntity; | 1448 Local get declaredEntity; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1451 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1452 Entity get rootOfScope; | 1452 Entity get rootOfScope; |
| 1453 } | 1453 } |
| OLD | NEW |