| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 void WriteBytes(const uint8_t* addr, intptr_t len) { | 381 void WriteBytes(const uint8_t* addr, intptr_t len) { |
| 382 if ((end_ - current_) < len) { | 382 if ((end_ - current_) < len) { |
| 383 Resize(len); | 383 Resize(len); |
| 384 } | 384 } |
| 385 ASSERT((end_ - current_) >= len); | 385 ASSERT((end_ - current_) >= len); |
| 386 memmove(current_, addr, len); | 386 memmove(current_, addr, len); |
| 387 current_ += len; | 387 current_ += len; |
| 388 } | 388 } |
| 389 | 389 |
| 390 void WriteWord(uword value) { |
| 391 const intptr_t len = sizeof(uword); |
| 392 if ((end_ - current_) < len) { |
| 393 Resize(len); |
| 394 } |
| 395 ASSERT((end_ - current_) >= len); |
| 396 *reinterpret_cast<uword*>(current_) = value; |
| 397 current_ += len; |
| 398 } |
| 399 |
| 390 void Print(const char* format, ...) { | 400 void Print(const char* format, ...) { |
| 391 va_list args; | 401 va_list args; |
| 392 va_start(args, format); | 402 va_start(args, format); |
| 393 VPrint(format, args); | 403 VPrint(format, args); |
| 394 } | 404 } |
| 395 | 405 |
| 396 private: | 406 private: |
| 397 template<typename T> | 407 template<typename T> |
| 398 void Write(T value) { | 408 void Write(T value) { |
| 399 T v = value; | 409 T v = value; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 intptr_t current_size_; | 472 intptr_t current_size_; |
| 463 ReAlloc alloc_; | 473 ReAlloc alloc_; |
| 464 intptr_t initial_size_; | 474 intptr_t initial_size_; |
| 465 | 475 |
| 466 DISALLOW_COPY_AND_ASSIGN(WriteStream); | 476 DISALLOW_COPY_AND_ASSIGN(WriteStream); |
| 467 }; | 477 }; |
| 468 | 478 |
| 469 } // namespace dart | 479 } // namespace dart |
| 470 | 480 |
| 471 #endif // VM_DATASTREAM_H_ | 481 #endif // VM_DATASTREAM_H_ |
| OLD | NEW |