| OLD | NEW |
| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 uint32 len = static_cast<BytesInstruction*>(instruction)->len(); |
| 425 |
| 425 if (!encoded->AddCopy(len, byte_values)) | 426 if (!encoded->AddCopy(len, byte_values)) |
| 426 return NULL; | 427 return NULL; |
| 427 break; | 428 break; |
| 428 } | 429 } |
| 429 case REL32: { | 430 case REL32: { |
| 430 Label* label = static_cast<InstructionWithLabel*>(instruction)->label(); | 431 Label* label = static_cast<InstructionWithLabel*>(instruction)->label(); |
| 431 if (!encoded->AddRel32(label->index_)) | 432 if (!encoded->AddRel32(label->index_)) |
| 432 return NULL; | 433 return NULL; |
| 433 break; | 434 break; |
| 434 } | 435 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 EncodedProgram *encoded = program->Encode(); | 574 EncodedProgram *encoded = program->Encode(); |
| 574 if (encoded) { | 575 if (encoded) { |
| 575 *output = encoded; | 576 *output = encoded; |
| 576 return C_OK; | 577 return C_OK; |
| 577 } else { | 578 } else { |
| 578 return C_GENERAL_ERROR; | 579 return C_GENERAL_ERROR; |
| 579 } | 580 } |
| 580 } | 581 } |
| 581 | 582 |
| 582 } // namespace courgette | 583 } // namespace courgette |
| OLD | NEW |