Index: courgette/disassembler.cc |
diff --git a/courgette/disassembler.cc b/courgette/disassembler.cc |
index 64ca27400aa06c944df5e9f9291b436b1178add2..e14ff325c652e741d39587ed9abf493d99f724de 100644 |
--- a/courgette/disassembler.cc |
+++ b/courgette/disassembler.cc |
@@ -7,6 +7,7 @@ |
#include "base/logging.h" |
#include "base/memory/ptr_util.h" |
#include "courgette/assembly_program.h" |
+#include "courgette/encoded_program.h" |
namespace courgette { |
@@ -54,8 +55,7 @@ const uint8_t* Disassembler::RVAToPointer(RVA rva) const { |
return FileOffsetToPointer(file_offset); |
} |
-std::unique_ptr<AssemblyProgram> Disassembler::Disassemble( |
- bool annotate_labels) { |
+std::unique_ptr<AssemblyProgram> Disassembler::CreateProgram(bool annotate) { |
if (!ok() || !ExtractAbs32Locations() || !ExtractRel32Locations()) |
return nullptr; |
@@ -64,16 +64,25 @@ std::unique_ptr<AssemblyProgram> Disassembler::Disassemble( |
PrecomputeLabels(program.get()); |
RemoveUnusedRel32Locations(program.get()); |
+ program->DefaultAssignIndexes(); |
- if (!program->GenerateInstructions(GetInstructionGenerator(program.get()), |
- annotate_labels)) { |
- return nullptr; |
+ if (annotate) { |
+ if (!program->AnnotateLabels(GetInstructionGenerator(program.get()))) |
+ return nullptr; |
} |
- program->DefaultAssignIndexes(); |
return program; |
} |
+Status Disassembler::DisassembleAndEncode(AssemblyProgram* program, |
+ EncodedProgram* encoded) { |
+ program->PrepareEncodedProgram(encoded); |
+ return encoded->GenerateInstructions(program->kind(), |
+ GetInstructionGenerator(program)) |
+ ? C_OK |
+ : C_DISASSEMBLY_FAILED; |
+} |
+ |
bool Disassembler::Good() { |
failure_reason_ = nullptr; |
return true; |