5 #ifndef V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ 6 #define V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ 8 #include "src/base/logging.h" 23 : data_(reinterpret_cast<const byte*>(data)),
28 : data_(payload.start()), length_(payload.length()), position_(0) {}
32 bool HasMore() {
return position_ < length_; }
35 DCHECK(position_ < length_);
36 return data_[position_++];
39 void Advance(
int by) { position_ += by; }
41 void CopyRaw(byte* to,
int number_of_bytes) {
42 memcpy(to, data_ + position_, number_of_bytes);
43 position_ += number_of_bytes;
49 DCHECK(position_ + 3 < length_);
51 answer |= data_[position_ + 1] << 8;
52 answer |= data_[position_ + 2] << 16;
53 answer |= data_[position_ + 3] << 24;
54 int bytes = (answer & 3) + 1;
57 mask >>= 32 - (bytes << 3);
64 int GetBlob(
const byte** data);
66 int position() {
return position_; }
67 void set_position(
int position) { position_ = position; }
90 void Put(byte b,
const char* description) { data_.push_back(b); }
92 void PutSection(
int b,
const char* description) {
93 DCHECK_LE(b, kMaxUInt8);
94 Put(static_cast<byte>(b), description);
97 void PutInt(
uintptr_t integer,
const char* description);
98 void PutRaw(
const byte* data,
int number_of_bytes,
const char* description);
101 int Position()
const {
return static_cast<int>(data_.size()); }
103 const std::vector<byte>* data()
const {
return &data_; }
106 std::vector<byte> data_;
112 #endif // V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_