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

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

Issue 1380513002: Revert "dart2js cps: Add helpers for common IR manipulation." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/insert_refinements.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 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void set body(Expression body); 69 void set body(Expression body);
70 } 70 }
71 71
72 /// An expression that creates new bindings and continues evaluation in 72 /// An expression that creates new bindings and continues evaluation in
73 /// a subexpression. 73 /// a subexpression.
74 /// 74 ///
75 /// The interior expressions are [LetPrim], [LetCont], [LetHandler], and 75 /// The interior expressions are [LetPrim], [LetCont], [LetHandler], and
76 /// [LetMutable]. 76 /// [LetMutable].
77 abstract class InteriorExpression extends Expression implements InteriorNode { 77 abstract class InteriorExpression extends Expression implements InteriorNode {
78 Expression get next => body; 78 Expression get next => body;
79
80 /// Removes this expression from its current position in the IR.
81 ///
82 /// The node can be re-inserted elsewhere or remain orphaned.
83 ///
84 /// If orphaned, the caller is responsible for unlinking all references in
85 /// the orphaned node. Use [Reference.unlink] or [Primitive.destroy] for this.
86 void remove() {
87 assert(parent != null);
88 assert(parent.body == this);
89 assert(body.parent == this);
90 parent.body = body;
91 body.parent = parent;
92 parent = null;
93 body = null;
94 }
95
96 /// Inserts this above [node].
97 ///
98 /// This node must be orphaned first.
99 void insertAbove(InteriorExpression node) {
100 insertBelow(node.parent);
101 }
102
103 /// Inserts this below [node].
104 ///
105 /// This node must be orphaned first.
106 void insertBelow(InteriorNode newParent) {
107 assert(parent == null);
108 assert(body == null);
109 Expression child = newParent.body;
110 newParent.body = this;
111 this.body = child;
112 child.parent = this;
113 this.parent = newParent;
114 }
115 } 79 }
116 80
117 /// An expression that passes a continuation to a call. 81 /// An expression that passes a continuation to a call.
118 abstract class CallExpression extends Expression { 82 abstract class CallExpression extends Expression {
119 Reference<Continuation> get continuation; 83 Reference<Continuation> get continuation;
120 Expression get next => continuation.definition.body; 84 Expression get next => continuation.definition.body;
121 } 85 }
122 86
123 /// An expression without a continuation or a subexpression body. 87 /// An expression without a continuation or a subexpression body.
124 /// 88 ///
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 EffectiveUseIterable get effectiveUses => new EffectiveUseIterable(this); 210 EffectiveUseIterable get effectiveUses => new EffectiveUseIterable(this);
247 211
248 bool get hasMultipleEffectiveUses { 212 bool get hasMultipleEffectiveUses {
249 Iterator it = effectiveUses.iterator; 213 Iterator it = effectiveUses.iterator;
250 return it.moveNext() && it.moveNext(); 214 return it.moveNext() && it.moveNext();
251 } 215 }
252 216
253 bool get hasNoEffectiveUses { 217 bool get hasNoEffectiveUses {
254 return effectiveUses.isEmpty; 218 return effectiveUses.isEmpty;
255 } 219 }
256
257 /// Unlinks all references contained in this node.
258 void destroy() {
259 assert(hasNoUses);
260 RemovalVisitor.remove(this);
261 }
262 } 220 }
263 221
264 /// Operands to invocations and primitives are always variables. They point to 222 /// Operands to invocations and primitives are always variables. They point to
265 /// their definition and are doubly-linked into a list of occurrences. 223 /// their definition and are doubly-linked into a list of occurrences.
266 class Reference<T extends Definition<T>> { 224 class Reference<T extends Definition<T>> {
267 T definition; 225 T definition;
268 Reference<T> previous; 226 Reference<T> previous;
269 Reference<T> next; 227 Reference<T> next;
270 228
271 /// A pointer to the parent node. Is null until set by optimization passes. 229 /// A pointer to the parent node. Is null until set by optimization passes.
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 1775 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
1818 class RemovalVisitor extends RecursiveVisitor { 1776 class RemovalVisitor extends RecursiveVisitor {
1819 processReference(Reference reference) { 1777 processReference(Reference reference) {
1820 reference.unlink(); 1778 reference.unlink();
1821 } 1779 }
1822 1780
1823 static void remove(Node node) { 1781 static void remove(Node node) {
1824 (new RemovalVisitor()).visit(node); 1782 (new RemovalVisitor()).visit(node);
1825 } 1783 }
1826 } 1784 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/insert_refinements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698