OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ | 5 #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ |
6 #define V8_SNAPSHOT_SOURCE_SINK_H_ | 6 #define V8_SNAPSHOT_SOURCE_SINK_H_ |
7 | 7 |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 virtual void PutSection(int byte, const char* description) { | 75 virtual void PutSection(int byte, const char* description) { |
76 Put(byte, description); | 76 Put(byte, description); |
77 } | 77 } |
78 void PutInt(uintptr_t integer, const char* description); | 78 void PutInt(uintptr_t integer, const char* description); |
79 void PutRaw(byte* data, int number_of_bytes, const char* description); | 79 void PutRaw(byte* data, int number_of_bytes, const char* description); |
80 void PutBlob(byte* data, int number_of_bytes, const char* description); | 80 void PutBlob(byte* data, int number_of_bytes, const char* description); |
81 virtual int Position() = 0; | 81 virtual int Position() = 0; |
82 }; | 82 }; |
83 | 83 |
84 | 84 |
| 85 class DummySnapshotSink : public SnapshotByteSink { |
| 86 public: |
| 87 DummySnapshotSink() : length_(0) {} |
| 88 virtual ~DummySnapshotSink() {} |
| 89 virtual void Put(int byte, const char* description) { length_++; } |
| 90 virtual int Position() { return length_; } |
| 91 |
| 92 private: |
| 93 int length_; |
| 94 }; |
| 95 |
| 96 |
| 97 // Wrap a SnapshotByteSink into a DebugSnapshotSink to get debugging output. |
| 98 class DebugSnapshotSink : public SnapshotByteSink { |
| 99 public: |
| 100 explicit DebugSnapshotSink(SnapshotByteSink* chained) : sink_(chained) {} |
| 101 virtual void Put(int byte, const char* description) V8_OVERRIDE; |
| 102 virtual int Position() V8_OVERRIDE { return sink_->Position(); } |
| 103 |
| 104 private: |
| 105 SnapshotByteSink* sink_; |
| 106 }; |
| 107 |
| 108 |
| 109 class ListSnapshotSink : public i::SnapshotByteSink { |
| 110 public: |
| 111 explicit ListSnapshotSink(i::List<char>* data) : data_(data) {} |
| 112 virtual void Put(int byte, const char* description) V8_OVERRIDE { |
| 113 data_->Add(byte); |
| 114 } |
| 115 virtual int Position() V8_OVERRIDE { return data_->length(); } |
| 116 |
| 117 private: |
| 118 i::List<char>* data_; |
| 119 }; |
| 120 |
85 } // namespace v8::internal | 121 } // namespace v8::internal |
86 } // namespace v8 | 122 } // namespace v8 |
87 | 123 |
88 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ | 124 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ |
OLD | NEW |