| 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 RUNTIME_VM_IL_PRINTER_H_ | 5 #ifndef RUNTIME_VM_IL_PRINTER_H_ |
| 6 #define RUNTIME_VM_IL_PRINTER_H_ | 6 #define RUNTIME_VM_IL_PRINTER_H_ |
| 7 | 7 |
| 8 #include "vm/flow_graph.h" | 8 #include "vm/flow_graph.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class BufferFormatter : public ValueObject { | 13 class BufferFormatter : public ValueObject { |
| 14 public: | 14 public: |
| 15 BufferFormatter(char* buffer, intptr_t size) | 15 BufferFormatter(char* buffer, intptr_t size) |
| 16 : position_(0), | 16 : position_(0), buffer_(buffer), size_(size) {} |
| 17 buffer_(buffer), | |
| 18 size_(size) { } | |
| 19 | 17 |
| 20 void VPrint(const char* format, va_list args); | 18 void VPrint(const char* format, va_list args); |
| 21 void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 19 void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
| 22 | 20 |
| 23 private: | 21 private: |
| 24 intptr_t position_; | 22 intptr_t position_; |
| 25 char* buffer_; | 23 char* buffer_; |
| 26 const intptr_t size_; | 24 const intptr_t size_; |
| 27 | 25 |
| 28 DISALLOW_COPY_AND_ASSIGN(BufferFormatter); | 26 DISALLOW_COPY_AND_ASSIGN(BufferFormatter); |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 | 29 |
| 32 class ParsedFunction; | 30 class ParsedFunction; |
| 33 | 31 |
| 34 | 32 |
| 35 // Graph printing. | 33 // Graph printing. |
| 36 class FlowGraphPrinter : public ValueObject { | 34 class FlowGraphPrinter : public ValueObject { |
| 37 public: | 35 public: |
| 38 static const intptr_t kPrintAll = -1; | 36 static const intptr_t kPrintAll = -1; |
| 39 | 37 |
| 40 FlowGraphPrinter(const FlowGraph& flow_graph, | 38 explicit FlowGraphPrinter(const FlowGraph& flow_graph, |
| 41 bool print_locations = false) | 39 bool print_locations = false) |
| 42 : function_(flow_graph.function()), | 40 : function_(flow_graph.function()), |
| 43 block_order_(flow_graph.reverse_postorder()), | 41 block_order_(flow_graph.reverse_postorder()), |
| 44 print_locations_(print_locations) { } | 42 print_locations_(print_locations) {} |
| 45 | 43 |
| 46 // Print the instructions in a block terminated by newlines. Add "goto N" | 44 // Print the instructions in a block terminated by newlines. Add "goto N" |
| 47 // to the end of the block if it ends with an unconditional jump to | 45 // to the end of the block if it ends with an unconditional jump to |
| 48 // another block and that block is not next in reverse postorder. | 46 // another block and that block is not next in reverse postorder. |
| 49 void PrintBlocks(); | 47 void PrintBlocks(); |
| 50 void PrintInstruction(Instruction* instr); | 48 void PrintInstruction(Instruction* instr); |
| 51 static void PrintOneInstruction(Instruction* instr, bool print_locations); | 49 static void PrintOneInstruction(Instruction* instr, bool print_locations); |
| 52 static void PrintTypeCheck(const ParsedFunction& parsed_function, | 50 static void PrintTypeCheck(const ParsedFunction& parsed_function, |
| 53 TokenPosition token_pos, | 51 TokenPosition token_pos, |
| 54 Value* value, | 52 Value* value, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 const Function& function_; | 70 const Function& function_; |
| 73 const GrowableArray<BlockEntryInstr*>& block_order_; | 71 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 74 const bool print_locations_; | 72 const bool print_locations_; |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 } // namespace dart | 75 } // namespace dart |
| 78 | 76 |
| 79 #endif // RUNTIME_VM_IL_PRINTER_H_ | 77 #endif // RUNTIME_VM_IL_PRINTER_H_ |
| OLD | NEW |