| 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 VM_DATASTREAM_H_ | 5 #ifndef VM_DATASTREAM_H_ |
| 6 #define VM_DATASTREAM_H_ | 6 #define VM_DATASTREAM_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void ReadBytes(uint8_t* addr, intptr_t len) { | 68 void ReadBytes(uint8_t* addr, intptr_t len) { |
| 69 ASSERT((end_ - current_) >= len); | 69 ASSERT((end_ - current_) >= len); |
| 70 memmove(addr, current_, len); | 70 memmove(addr, current_, len); |
| 71 current_ += len; | 71 current_ += len; |
| 72 } | 72 } |
| 73 | 73 |
| 74 intptr_t ReadUnsigned() { | 74 intptr_t ReadUnsigned() { |
| 75 return Read<intptr_t>(kEndUnsignedByteMarker); | 75 return Read<intptr_t>(kEndUnsignedByteMarker); |
| 76 } | 76 } |
| 77 | 77 |
| 78 intptr_t Position() const { return current_ - buffer_; } |
| 79 |
| 80 void SetPosition(intptr_t value) { |
| 81 ASSERT((end_ - buffer_) > value); |
| 82 current_ = buffer_ + value; |
| 83 } |
| 84 |
| 85 const uint8_t* AddressOfCurrentPosition() const { |
| 86 return current_; |
| 87 } |
| 88 |
| 89 void Advance(intptr_t value) { |
| 90 ASSERT((end_ - current_) > value); |
| 91 current_ = current_ + value; |
| 92 } |
| 93 |
| 78 private: | 94 private: |
| 79 template<typename T> | 95 template<typename T> |
| 80 T Read() { | 96 T Read() { |
| 81 return Read<T>(kEndByteMarker); | 97 return Read<T>(kEndByteMarker); |
| 82 } | 98 } |
| 83 | 99 |
| 84 template<typename T> | 100 template<typename T> |
| 85 T Read(uint8_t end_byte_marker) { | 101 T Read(uint8_t end_byte_marker) { |
| 86 uint8_t b = ReadByte(); | 102 uint8_t b = ReadByte(); |
| 87 if (b > kMaxUnsignedDataPerByte) { | 103 if (b > kMaxUnsignedDataPerByte) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 uint8_t* current_; | 247 uint8_t* current_; |
| 232 intptr_t current_size_; | 248 intptr_t current_size_; |
| 233 ReAlloc alloc_; | 249 ReAlloc alloc_; |
| 234 | 250 |
| 235 DISALLOW_COPY_AND_ASSIGN(WriteStream); | 251 DISALLOW_COPY_AND_ASSIGN(WriteStream); |
| 236 }; | 252 }; |
| 237 | 253 |
| 238 } // namespace dart | 254 } // namespace dart |
| 239 | 255 |
| 240 #endif // VM_DATASTREAM_H_ | 256 #endif // VM_DATASTREAM_H_ |
| OLD | NEW |