OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 '../elements/elements.dart'; | 5 import '../elements/elements.dart'; |
6 import '../types/types.dart'; | 6 import '../types/types.dart'; |
7 import 'nodes.dart'; | 7 import 'nodes.dart'; |
8 | 8 |
9 /// Base class for objects that build up an SSA graph. | 9 /// Base class for objects that build up an SSA graph. |
10 /// | 10 /// |
11 /// This contains helpers for building the graph and tracking information about | 11 /// This contains helpers for building the graph and tracking information about |
12 /// the current state of the graph being built. | 12 /// the current state of the graph being built. |
13 abstract class GraphBuilder { | 13 abstract class GraphBuilder { |
14 /// Holds the resulting SSA graph. | 14 /// Holds the resulting SSA graph. |
15 final HGraph graph = new HGraph(); | 15 final HGraph graph = new HGraph(); |
16 | 16 |
17 /// A stack of instructions. | 17 /// A stack of instructions. |
18 /// | 18 /// |
19 /// We build the SSA graph by simulating a stack machine. | 19 /// We build the SSA graph by simulating a stack machine. |
20 List<HInstruction> stack = <HInstruction>[]; | 20 List<HInstruction> stack = <HInstruction>[]; |
21 | 21 |
22 | |
23 void push(HInstruction instruction) { | 22 void push(HInstruction instruction) { |
24 add(instruction); | 23 add(instruction); |
25 stack.add(instruction); | 24 stack.add(instruction); |
26 } | 25 } |
27 | 26 |
28 HInstruction pop() { | 27 HInstruction pop() { |
29 return stack.removeLast(); | 28 return stack.removeLast(); |
30 } | 29 } |
31 | 30 |
32 void dup() { | 31 void dup() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 HParameterValue result = new HParameterValue(parameter, type); | 114 HParameterValue result = new HParameterValue(parameter, type); |
116 if (lastAddedParameter == null) { | 115 if (lastAddedParameter == null) { |
117 graph.entry.addBefore(graph.entry.first, result); | 116 graph.entry.addBefore(graph.entry.first, result); |
118 } else { | 117 } else { |
119 graph.entry.addAfter(lastAddedParameter, result); | 118 graph.entry.addAfter(lastAddedParameter, result); |
120 } | 119 } |
121 lastAddedParameter = result; | 120 lastAddedParameter = result; |
122 return result; | 121 return result; |
123 } | 122 } |
124 } | 123 } |
OLD | NEW |