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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1075923002: Refactor the try statement analysis results. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer2dart/lib/src/cps_generator.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index 37d0fa408d03daca4f60e0d302cc18f75f2d9042..5f35a3f07799933f2af2063267cd7b142365c0ea 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -416,17 +416,6 @@ class ThisParameterLocal implements Local {
abstract class IrBuilder {
IrBuilder _makeInstance();
- // TODO(johnniwinther): Remove this from the [IrBuilder].
- /// A map from TryStatements in the AST to their analysis information.
- ///
- /// This includes which variables should be copied into [ir.MutableVariable]s
- /// on entry to the try and copied out on exit.
- Map<ast.TryStatement, TryStatementInfo> get tryStatements;
-
- /// The set of local variables that will spend their lifetime as
- /// [ir.MutableVariable]s due to being captured by a nested function.
- Set<Local> get mutableCapturedVariables;
-
/// True if [local] should currently be accessed from a [ir.MutableVariable].
bool isInMutableVariable(Local local);
@@ -1593,11 +1582,7 @@ abstract class IrBuilder {
// we can not identify all of them in the same pass where we identify the
// variables assigned in the try (they may be captured by a closure after
// the try statement).
- Iterable<LocalVariableElement> boxedOnEntry =
- tryStatementInfo.boxedOnEntry.where((LocalVariableElement variable) {
- return !tryCatchBuilder.mutableCapturedVariables.contains(variable);
- });
- for (LocalVariableElement variable in boxedOnEntry) {
+ for (LocalVariableElement variable in tryStatementInfo.boxedOnEntry) {
assert(!tryCatchBuilder.isInMutableVariable(variable));
ir.Primitive value = tryCatchBuilder.buildLocalGet(variable);
tryCatchBuilder.makeMutableVariable(variable);
@@ -1607,7 +1592,7 @@ abstract class IrBuilder {
IrBuilder tryBuilder = tryCatchBuilder.makeDelimitedBuilder();
void interceptJumps(JumpCollector collector) {
- collector.enterTry(boxedOnEntry);
+ collector.enterTry(tryStatementInfo.boxedOnEntry);
}
void restoreJumps(JumpCollector collector) {
collector.leaveTry();
@@ -1624,7 +1609,7 @@ abstract class IrBuilder {
tryBuilder.state.continueCollectors.forEach(restoreJumps);
IrBuilder catchBuilder = tryCatchBuilder.makeDelimitedBuilder();
- for (LocalVariableElement variable in boxedOnEntry) {
+ for (LocalVariableElement variable in tryStatementInfo.boxedOnEntry) {
assert(catchBuilder.isInMutableVariable(variable));
ir.Primitive value = catchBuilder.buildLocalGet(variable);
// Note that we remove the variable from the set of mutable variables
@@ -1902,9 +1887,6 @@ class DartIrBuilderSharedState {
final Map<Local, ir.MutableVariable> local2mutable =
<Local, ir.MutableVariable>{};
- // Move this to the IrBuilderVisitor.
- final DartCapturedVariables capturedVariables;
-
/// Creates a [MutableVariable] for the given local.
void makeMutableVariable(Local local) {
ir.MutableVariable variable =
@@ -1915,8 +1897,8 @@ class DartIrBuilderSharedState {
/// [MutableVariable]s that should temporarily be treated as registers.
final Set<Local> registerizedMutableVariables = new Set<Local>();
- DartIrBuilderSharedState(this.capturedVariables) {
- capturedVariables.capturedVariables.forEach(makeMutableVariable);
+ DartIrBuilderSharedState(Set<Local> capturedVariables) {
+ capturedVariables.forEach(makeMutableVariable);
}
}
@@ -1935,19 +1917,11 @@ class DartIrBuilder extends IrBuilder {
DartIrBuilder(ConstantSystem constantSystem,
ExecutableElement currentElement,
- DartCapturedVariables capturedVariables)
+ Set<Local> capturedVariables)
: dartState = new DartIrBuilderSharedState(capturedVariables) {
_init(constantSystem, currentElement);
}
- Map<ast.TryStatement, TryStatementInfo> get tryStatements {
- return dartState.capturedVariables.tryStatements;
- }
-
- Set<Local> get mutableCapturedVariables {
- return dartState.capturedVariables.capturedVariables;
- }
-
bool isInMutableVariable(Local local) {
return dartState.local2mutable.containsKey(local) &&
!dartState.registerizedMutableVariables.contains(local);
« no previous file with comments | « pkg/analyzer2dart/lib/src/cps_generator.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698