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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "courgette/courgette.h" | 17 #include "courgette/courgette.h" |
17 #include "courgette/encoded_program.h" | 18 #include "courgette/encoded_program.h" |
18 | 19 |
19 namespace courgette { | 20 namespace courgette { |
20 | 21 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 ++index; | 355 ++index; |
355 ++fill_infill_count; | 356 ++fill_infill_count; |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
359 VLOG(1) << " fill forward " << fill_forward_count | 360 VLOG(1) << " fill forward " << fill_forward_count |
360 << " backward " << fill_backward_count | 361 << " backward " << fill_backward_count |
361 << " infill " << fill_infill_count; | 362 << " infill " << fill_infill_count; |
362 } | 363 } |
363 | 364 |
364 scoped_ptr<EncodedProgram> AssemblyProgram::Encode() const { | 365 std::unique_ptr<EncodedProgram> AssemblyProgram::Encode() const { |
365 scoped_ptr<EncodedProgram> encoded(new EncodedProgram()); | 366 std::unique_ptr<EncodedProgram> encoded(new EncodedProgram()); |
366 | 367 |
367 encoded->set_image_base(image_base_); | 368 encoded->set_image_base(image_base_); |
368 | 369 |
369 if (!encoded->DefineLabels(abs32_labels_, rel32_labels_)) | 370 if (!encoded->DefineLabels(abs32_labels_, rel32_labels_)) |
370 return nullptr; | 371 return nullptr; |
371 | 372 |
372 for (size_t i = 0; i < instructions_.size(); ++i) { | 373 for (size_t i = 0; i < instructions_.size(); ++i) { |
373 Instruction* instruction = instructions_[i]; | 374 Instruction* instruction = instructions_[i]; |
374 | 375 |
375 switch (instruction->op()) { | 376 switch (instruction->op()) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 ++it; | 521 ++it; |
521 } | 522 } |
522 } | 523 } |
523 | 524 |
524 return true; | 525 return true; |
525 } | 526 } |
526 | 527 |
527 //////////////////////////////////////////////////////////////////////////////// | 528 //////////////////////////////////////////////////////////////////////////////// |
528 | 529 |
529 Status Encode(const AssemblyProgram& program, | 530 Status Encode(const AssemblyProgram& program, |
530 scoped_ptr<EncodedProgram>* output) { | 531 std::unique_ptr<EncodedProgram>* output) { |
531 // Explicitly release any memory associated with the output before encoding. | 532 // Explicitly release any memory associated with the output before encoding. |
532 output->reset(); | 533 output->reset(); |
533 | 534 |
534 *output = program.Encode(); | 535 *output = program.Encode(); |
535 return (*output) ? C_OK : C_GENERAL_ERROR; | 536 return (*output) ? C_OK : C_GENERAL_ERROR; |
536 } | 537 } |
537 | 538 |
538 } // namespace courgette | 539 } // namespace courgette |
OLD | NEW |