| 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 #ifndef VM_FLOW_GRAPH_BUILDER_H_ | 5 #ifndef VM_FLOW_GRAPH_BUILDER_H_ |
| 6 #define VM_FLOW_GRAPH_BUILDER_H_ | 6 #define VM_FLOW_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 protected: | 91 protected: |
| 92 // Helpers for translating parts of the AST. | 92 // Helpers for translating parts of the AST. |
| 93 void TranslateArgumentList(const ArgumentListNode& node, | 93 void TranslateArgumentList(const ArgumentListNode& node, |
| 94 intptr_t next_temp_index, | 94 intptr_t next_temp_index, |
| 95 ZoneGrowableArray<Value*>* values); | 95 ZoneGrowableArray<Value*>* values); |
| 96 | 96 |
| 97 void CloseFragment() { exit_ = NULL; } | 97 void CloseFragment() { exit_ = NULL; } |
| 98 intptr_t AllocateTempIndex() { return temp_index_++; } | 98 intptr_t AllocateTempIndex() { return temp_index_++; } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 // Specify a value as the final result. Does nothing in an effect context |
| 102 // but is normally overridden by subclasses. |
| 103 virtual void ReturnValue(Value* value) { } |
| 104 |
| 101 // Specify a computation as the final result. Adds a Do instruction to | 105 // Specify a computation as the final result. Adds a Do instruction to |
| 102 // the graph, but normally overridden in subclasses. | 106 // the graph, but normally overridden in subclasses. |
| 103 virtual void ReturnComputation(Computation* computation) { | 107 virtual void ReturnComputation(Computation* computation) { |
| 104 AddInstruction(new DoInstr(computation)); | 108 AddInstruction(new DoInstr(computation)); |
| 105 } | 109 } |
| 106 | 110 |
| 107 // Shared global state. | 111 // Shared global state. |
| 108 FlowGraphBuilder* owner_; | 112 FlowGraphBuilder* owner_; |
| 109 | 113 |
| 110 // Input parameters. | 114 // Input parameters. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return true_successor_address_; | 214 return true_successor_address_; |
| 211 } | 215 } |
| 212 TargetEntryInstr** false_successor_address() const { | 216 TargetEntryInstr** false_successor_address() const { |
| 213 ASSERT(can_be_false()); | 217 ASSERT(can_be_false()); |
| 214 return false_successor_address_; | 218 return false_successor_address_; |
| 215 } | 219 } |
| 216 | 220 |
| 217 private: | 221 private: |
| 218 // Construct and concatenate a Branch instruction to this graph fragment. | 222 // Construct and concatenate a Branch instruction to this graph fragment. |
| 219 // Closes the fragment and sets the output parameters. | 223 // Closes the fragment and sets the output parameters. |
| 220 void BranchOnValue(Value* value); | 224 void ReturnValue(Value* value); |
| 221 | 225 |
| 222 // Specify a computation as the final result. Adds a Bind instruction to | 226 // Specify a computation as the final result. Adds a Bind instruction to |
| 223 // the graph and branches on its value. | 227 // the graph and branches on its value. |
| 224 virtual void ReturnComputation(Computation* computation) { | 228 virtual void ReturnComputation(Computation* computation) { |
| 225 AddInstruction(new BindInstr(temp_index(), computation)); | 229 AddInstruction(new BindInstr(temp_index(), computation)); |
| 226 BranchOnValue(new TempVal(temp_index())); | 230 ReturnValue(new TempVal(temp_index())); |
| 227 } | 231 } |
| 228 | 232 |
| 229 // Output parameters. | 233 // Output parameters. |
| 230 TargetEntryInstr** true_successor_address_; | 234 TargetEntryInstr** true_successor_address_; |
| 231 TargetEntryInstr** false_successor_address_; | 235 TargetEntryInstr** false_successor_address_; |
| 232 }; | 236 }; |
| 233 | 237 |
| 234 } // namespace dart | 238 } // namespace dart |
| 235 | 239 |
| 236 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 240 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |