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 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 | 14 |
15 /** | 15 /** |
16 * Source to read snapshot and builtins files from. | 16 * Source to read snapshot and builtins files from. |
17 * | 17 * |
18 * Note: Memory ownership remains with callee. | 18 * Note: Memory ownership remains with callee. |
19 */ | 19 */ |
20 class SnapshotByteSource FINAL { | 20 class SnapshotByteSource FINAL { |
21 public: | 21 public: |
22 SnapshotByteSource(const byte* data, int length) | 22 SnapshotByteSource(const char* data, int length) |
23 : data_(data), length_(length), position_(0) {} | 23 : data_(reinterpret_cast<const byte*>(data)), |
| 24 length_(length), |
| 25 position_(0) {} |
24 | 26 |
25 explicit SnapshotByteSource(Vector<const byte> payload) | 27 explicit SnapshotByteSource(Vector<const byte> payload) |
26 : data_(payload.start()), length_(payload.length()), position_(0) {} | 28 : data_(payload.start()), length_(payload.length()), position_(0) {} |
27 | 29 |
28 ~SnapshotByteSource() {} | 30 ~SnapshotByteSource() {} |
29 | 31 |
30 bool HasMore() { return position_ < length_; } | 32 bool HasMore() { return position_ < length_; } |
31 | 33 |
32 byte Get() { | 34 byte Get() { |
33 DCHECK(position_ < length_); | 35 DCHECK(position_ < length_); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const List<byte>& data() const { return data_; } | 97 const List<byte>& data() const { return data_; } |
96 | 98 |
97 private: | 99 private: |
98 List<byte> data_; | 100 List<byte> data_; |
99 }; | 101 }; |
100 | 102 |
101 } // namespace v8::internal | 103 } // namespace v8::internal |
102 } // namespace v8 | 104 } // namespace v8 |
103 | 105 |
104 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ | 106 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ |
OLD | NEW |