Chromium Code Reviews| Index: vm/il_printer.h |
| =================================================================== |
| --- vm/il_printer.h (revision 7699) |
| +++ vm/il_printer.h (working copy) |
| @@ -9,40 +9,48 @@ |
| namespace dart { |
| +class BufferFormatter : public ValueObject { |
| + public: |
| + BufferFormatter(char* buffer, int size) |
| + : position_(0), |
| + buffer_(buffer), |
| + size_(size) { } |
| + |
| + void Print(const char* format, ...) { |
|
srdjan
2012/05/17 22:59:22
Move the code into .cc
Florian Schneider
2012/05/18 00:28:38
Done.
|
| + int available = size_ - position_; |
| + if (available <= 0) return; |
| + va_list args; |
| + va_start(args, format); |
| + int written = OS::VSNPrint(buffer_ + position_, available, format, args); |
|
srdjan
2012/05/17 22:59:22
intptr_t
|
| + if (written >= 0) position_ += (available <= written) ? available : written; |
|
srdjan
2012/05/17 22:59:22
Use { }
Florian Schneider
2012/05/18 00:28:38
Done.
|
| + va_end(args); |
| + } |
| + |
| + private: |
| + int position_; |
| + char* buffer_; |
| + int size_; |
|
srdjan
2012/05/17 22:59:22
make size intptr_t
Florian Schneider
2012/05/18 00:28:38
Done.
|
| +}; |
| + |
| + |
| // Graph printing. |
| -class FlowGraphPrinter : public FlowGraphVisitor { |
| +class FlowGraphPrinter : public ValueObject { |
| public: |
| FlowGraphPrinter(const Function& function, |
| const GrowableArray<BlockEntryInstr*>& block_order) |
| - : FlowGraphVisitor(block_order), function_(function) { } |
| + : function_(function), block_order_(block_order) { } |
| virtual ~FlowGraphPrinter() {} |
| // Print the instructions in a block terminated by newlines. Add "goto N" |
| // to the end of the block if it ends with an unconditional jump to |
| // another block and that block is not next in reverse postorder. |
| - void VisitBlocks(); |
| + void PrintBlocks(); |
| + void Print(Instruction* instr); |
| - // Visiting a computation prints it with no indentation or newline. |
| -#define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ |
| - virtual void Visit##ShortName(ClassName* comp); |
| - |
| - // Visiting an instruction prints it with a four space indent and no |
| - // trailing newline. Basic block entries are labeled with their block |
| - // number. |
| -#define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
| - virtual void Visit##ShortName(ShortName##Instr* instr); |
| - |
| - FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
| - FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| - |
| -#undef DECLARE_VISIT_COMPUTATION |
| -#undef DECLARE_VISIT_INSTRUCTION |
| - |
| private: |
| const Function& function_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(FlowGraphPrinter); |
| + const GrowableArray<BlockEntryInstr*>& block_order_; |
| }; |
| } // namespace dart |