OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 #include "courgette/encoded_program.h" | 5 #include "courgette/encoded_program.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 const int kStreamAbs32Addresses = 5; | 26 const int kStreamAbs32Addresses = 5; |
27 const int kStreamRel32Addresses = 6; | 27 const int kStreamRel32Addresses = 6; |
28 const int kStreamCopyCounts = 7; | 28 const int kStreamCopyCounts = 7; |
29 const int kStreamOriginAddresses = kStreamMisc; | 29 const int kStreamOriginAddresses = kStreamMisc; |
30 | 30 |
31 const int kStreamLimit = 9; | 31 const int kStreamLimit = 9; |
32 | 32 |
33 // Constructor is here rather than in the header. Although the constructor | 33 // Constructor is here rather than in the header. Although the constructor |
34 // appears to do nothing it is fact quite large because of the implict calls to | 34 // appears to do nothing it is fact quite large because of the implict calls to |
35 // field constructors. Ditto for the destructor. | 35 // field constructors. Ditto for the destructor. |
36 EncodedProgram::EncodedProgram() {} | 36 EncodedProgram::EncodedProgram() : image_base_(0) {} |
37 EncodedProgram::~EncodedProgram() {} | 37 EncodedProgram::~EncodedProgram() {} |
38 | 38 |
39 // Serializes a vector of integral values using Varint32 coding. | 39 // Serializes a vector of integral values using Varint32 coding. |
40 template<typename T> | 40 template<typename T> |
41 void WriteVector(const std::vector<T>& items, SinkStream* buffer) { | 41 void WriteVector(const std::vector<T>& items, SinkStream* buffer) { |
42 size_t count = items.size(); | 42 size_t count = items.size(); |
43 buffer->WriteVarint32(count); | 43 buffer->WriteVarint32(count); |
44 for (size_t i = 0; i < count; ++i) { | 44 for (size_t i = 0; i < count; ++i) { |
45 COMPILE_ASSERT(sizeof(T) <= sizeof(uint32), T_must_fit_in_uint32); | 45 COMPILE_ASSERT(sizeof(T) <= sizeof(uint32), T_must_fit_in_uint32); |
46 buffer->WriteVarint32(static_cast<uint32>(items[i])); | 46 buffer->WriteVarint32(static_cast<uint32>(items[i])); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 if (assembled) | 556 if (assembled) |
557 return C_OK; | 557 return C_OK; |
558 return C_ASSEMBLY_FAILED; | 558 return C_ASSEMBLY_FAILED; |
559 } | 559 } |
560 | 560 |
561 void DeleteEncodedProgram(EncodedProgram* encoded) { | 561 void DeleteEncodedProgram(EncodedProgram* encoded) { |
562 delete encoded; | 562 delete encoded; |
563 } | 563 } |
564 | 564 |
565 } // end namespace | 565 } // end namespace |
OLD | NEW |