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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1129693005: MutableVariable no longer has a host Element. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update SExpressionUnstringifier Created 5 years, 7 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/compiler/lib/src/cps_ir/cps_ir_nodes.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../constants/constant_system.dart'; 7 import '../constants/constant_system.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../constants/values.dart' show PrimitiveConstantValue; 9 import '../constants/values.dart' show PrimitiveConstantValue;
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 /// Mutable variables are treated as boxed. Writes to them are observable 484 /// Mutable variables are treated as boxed. Writes to them are observable
485 /// side effects. 485 /// side effects.
486 Map<Local, ir.MutableVariable> mutableVariables; 486 Map<Local, ir.MutableVariable> mutableVariables;
487 487
488 /// True if [local] should currently be accessed from a [ir.MutableVariable]. 488 /// True if [local] should currently be accessed from a [ir.MutableVariable].
489 bool isInMutableVariable(Local local) { 489 bool isInMutableVariable(Local local) {
490 return mutableVariables.containsKey(local); 490 return mutableVariables.containsKey(local);
491 } 491 }
492 492
493 /// Creates a [ir.MutableVariable] for the given local. 493 /// Creates a [ir.MutableVariable] for the given local.
494 void makeMutableVariable(Local local, [ClosureClassMap closureMap]) { 494 void makeMutableVariable(Local local) {
495 ExecutableElement owner; 495 mutableVariables[local] = new ir.MutableVariable(local);
496 if (closureMap == null || closureMap.closureClassElement == null) {
497 owner = local.executableContext;
498 } else {
499 assert(local.executableContext == closureMap.closureElement);
500 owner = closureMap.callElement;
501 }
502 mutableVariables[local] = new ir.MutableVariable(owner, local);
503 } 496 }
504 497
505 /// Remove an [ir.MutableVariable] for a local. 498 /// Remove an [ir.MutableVariable] for a local.
506 /// 499 ///
507 /// Subsequent access to the local will be direct rather than through the 500 /// Subsequent access to the local will be direct rather than through the
508 /// mutable variable. 501 /// mutable variable.
509 void removeMutableVariable(Local local) { 502 void removeMutableVariable(Local local) {
510 mutableVariables.remove(local); 503 mutableVariables.remove(local);
511 } 504 }
512 505
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 JumpCollector join = new ForwardJumpCollector(environment); 1751 JumpCollector join = new ForwardJumpCollector(environment);
1759 IrBuilder tryCatchBuilder = makeDelimitedBuilder(); 1752 IrBuilder tryCatchBuilder = makeDelimitedBuilder();
1760 1753
1761 // Variables treated as mutable in a try are not mutable outside of it. 1754 // Variables treated as mutable in a try are not mutable outside of it.
1762 // Work with a copy of the outer builder's mutable variables. 1755 // Work with a copy of the outer builder's mutable variables.
1763 tryCatchBuilder.mutableVariables = 1756 tryCatchBuilder.mutableVariables =
1764 new Map<Local, ir.MutableVariable>.from(mutableVariables); 1757 new Map<Local, ir.MutableVariable>.from(mutableVariables);
1765 for (LocalVariableElement variable in tryStatementInfo.boxedOnEntry) { 1758 for (LocalVariableElement variable in tryStatementInfo.boxedOnEntry) {
1766 assert(!tryCatchBuilder.isInMutableVariable(variable)); 1759 assert(!tryCatchBuilder.isInMutableVariable(variable));
1767 ir.Primitive value = tryCatchBuilder.buildLocalVariableGet(variable); 1760 ir.Primitive value = tryCatchBuilder.buildLocalVariableGet(variable);
1768 tryCatchBuilder.makeMutableVariable(variable, closureClassMap); 1761 tryCatchBuilder.makeMutableVariable(variable);
1769 tryCatchBuilder.declareLocalVariable(variable, initialValue: value); 1762 tryCatchBuilder.declareLocalVariable(variable, initialValue: value);
1770 } 1763 }
1771 1764
1772 IrBuilder tryBuilder = tryCatchBuilder.makeDelimitedBuilder(); 1765 IrBuilder tryBuilder = tryCatchBuilder.makeDelimitedBuilder();
1773 1766
1774 void interceptJumps(JumpCollector collector) { 1767 void interceptJumps(JumpCollector collector) {
1775 collector.enterTry(tryStatementInfo.boxedOnEntry); 1768 collector.enterTry(tryStatementInfo.boxedOnEntry);
1776 } 1769 }
1777 void restoreJumps(JumpCollector collector) { 1770 void restoreJumps(JumpCollector collector) {
1778 collector.leaveTry(); 1771 collector.leaveTry();
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 } 2728 }
2736 2729
2737 /// Synthetic parameter to a JavaScript factory method that takes the type 2730 /// Synthetic parameter to a JavaScript factory method that takes the type
2738 /// argument given for the type variable [variable]. 2731 /// argument given for the type variable [variable].
2739 class TypeInformationParameter implements Local { 2732 class TypeInformationParameter implements Local {
2740 final TypeVariableElement variable; 2733 final TypeVariableElement variable;
2741 final ExecutableElement executableContext; 2734 final ExecutableElement executableContext;
2742 TypeInformationParameter(this.variable, this.executableContext); 2735 TypeInformationParameter(this.variable, this.executableContext);
2743 String get name => variable.name; 2736 String get name => variable.name;
2744 } 2737 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698