Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: courgette/assembly_program.cc

Issue 613893002: Fix more MSVC warnings, courgette/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/assembly_program.h" 5 #include "courgette/assembly_program.h"
6 6
7 #include <memory.h> 7 #include <memory.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Emits a single byte. 83 // Emits a single byte.
84 class ByteInstruction : public Instruction { 84 class ByteInstruction : public Instruction {
85 public: 85 public:
86 explicit ByteInstruction(uint8 value) : Instruction(DEFBYTE, value) {} 86 explicit ByteInstruction(uint8 value) : Instruction(DEFBYTE, value) {}
87 uint8 byte_value() const { return info_; } 87 uint8 byte_value() const { return info_; }
88 }; 88 };
89 89
90 // Emits a single byte. 90 // Emits a single byte.
91 class BytesInstruction : public Instruction { 91 class BytesInstruction : public Instruction {
92 public: 92 public:
93 BytesInstruction(const uint8* values, uint32 len) 93 BytesInstruction(const uint8* values, size_t len)
Peter Kasting 2014/09/30 00:08:01 These changes follow from the API change to EmitBy
94 : Instruction(DEFBYTES, 0), 94 : Instruction(DEFBYTES, 0),
95 values_(values), 95 values_(values),
96 len_(len) {} 96 len_(len) {}
97 const uint8* byte_values() const { return values_; } 97 const uint8* byte_values() const { return values_; }
98 uint32 len() const { return len_; } 98 size_t len() const { return len_; }
99 99
100 private: 100 private:
101 const uint8* values_; 101 const uint8* values_;
102 uint32 len_; 102 size_t len_;
103 }; 103 };
104 104
105 // A ABS32 to REL32 instruction emits a reference to a label's address. 105 // A ABS32 to REL32 instruction emits a reference to a label's address.
106 class InstructionWithLabel : public Instruction { 106 class InstructionWithLabel : public Instruction {
107 public: 107 public:
108 InstructionWithLabel(OP op, Label* label) 108 InstructionWithLabel(OP op, Label* label)
109 : Instruction(op, 0), label_(label) { 109 : Instruction(op, 0), label_(label) {
110 if (label == NULL) NOTREACHED(); 110 if (label == NULL) NOTREACHED();
111 } 111 }
112 Label* label() const { return label_; } 112 Label* label() const { return label_; }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 CheckBool AssemblyProgram::EmitOriginInstruction(RVA rva) { 173 CheckBool AssemblyProgram::EmitOriginInstruction(RVA rva) {
174 return Emit(new(std::nothrow) OriginInstruction(rva)); 174 return Emit(new(std::nothrow) OriginInstruction(rva));
175 } 175 }
176 176
177 CheckBool AssemblyProgram::EmitByteInstruction(uint8 byte) { 177 CheckBool AssemblyProgram::EmitByteInstruction(uint8 byte) {
178 return Emit(GetByteInstruction(byte)); 178 return Emit(GetByteInstruction(byte));
179 } 179 }
180 180
181 CheckBool AssemblyProgram::EmitBytesInstruction(const uint8* values, 181 CheckBool AssemblyProgram::EmitBytesInstruction(const uint8* values,
182 uint32 len) { 182 size_t len) {
183 return Emit(new(std::nothrow) BytesInstruction(values, len)); 183 return Emit(new(std::nothrow) BytesInstruction(values, len));
184 } 184 }
185 185
186 CheckBool AssemblyProgram::EmitRel32(Label* label) { 186 CheckBool AssemblyProgram::EmitRel32(Label* label) {
187 return Emit(new(std::nothrow) InstructionWithLabel(REL32, label)); 187 return Emit(new(std::nothrow) InstructionWithLabel(REL32, label));
188 } 188 }
189 189
190 CheckBool AssemblyProgram::EmitRel32ARM(uint16 op, Label* label, 190 CheckBool AssemblyProgram::EmitRel32ARM(uint16 op, Label* label,
191 const uint8* arm_op, uint16 op_size) { 191 const uint8* arm_op, uint16 op_size) {
192 return Emit(new(std::nothrow) InstructionWithLabelARM(REL32ARM, op, label, 192 return Emit(new(std::nothrow) InstructionWithLabelARM(REL32ARM, op, label,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 case DEFBYTE: { 415 case DEFBYTE: {
416 uint8 b = static_cast<ByteInstruction*>(instruction)->byte_value(); 416 uint8 b = static_cast<ByteInstruction*>(instruction)->byte_value();
417 if (!encoded->AddCopy(1, &b)) 417 if (!encoded->AddCopy(1, &b))
418 return NULL; 418 return NULL;
419 break; 419 break;
420 } 420 }
421 case DEFBYTES: { 421 case DEFBYTES: {
422 const uint8* byte_values = 422 const uint8* byte_values =
423 static_cast<BytesInstruction*>(instruction)->byte_values(); 423 static_cast<BytesInstruction*>(instruction)->byte_values();
424 uint32 len = static_cast<BytesInstruction*>(instruction)->len(); 424 size_t len = static_cast<BytesInstruction*>(instruction)->len();
425 425
426 if (!encoded->AddCopy(len, byte_values)) 426 if (!encoded->AddCopy(len, byte_values))
427 return NULL; 427 return NULL;
428 break; 428 break;
429 } 429 }
430 case REL32: { 430 case REL32: {
431 Label* label = static_cast<InstructionWithLabel*>(instruction)->label(); 431 Label* label = static_cast<InstructionWithLabel*>(instruction)->label();
432 if (!encoded->AddRel32(label->index_)) 432 if (!encoded->AddRel32(label->index_))
433 return NULL; 433 return NULL;
434 break; 434 break;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 EncodedProgram *encoded = program->Encode(); 574 EncodedProgram *encoded = program->Encode();
575 if (encoded) { 575 if (encoded) {
576 *output = encoded; 576 *output = encoded;
577 return C_OK; 577 return C_OK;
578 } else { 578 } else {
579 return C_GENERAL_ERROR; 579 return C_GENERAL_ERROR;
580 } 580 }
581 } 581 }
582 582
583 } // namespace courgette 583 } // namespace courgette
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698