| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // original file's stream and the new file's stream. This is completely | 207 // original file's stream and the new file's stream. This is completely |
| 208 // uninteresting to users, but it is handy for seeing how much each which | 208 // uninteresting to users, but it is handy for seeing how much each which |
| 209 // streams are contributing to the final file size. Adjustment is optional. | 209 // streams are contributing to the final file size. Adjustment is optional. |
| 210 void DisassembleAdjustDiff(const base::FilePath& model_file, | 210 void DisassembleAdjustDiff(const base::FilePath& model_file, |
| 211 const base::FilePath& program_file, | 211 const base::FilePath& program_file, |
| 212 const base::FilePath& output_file_root, | 212 const base::FilePath& output_file_root, |
| 213 bool adjust) { | 213 bool adjust) { |
| 214 BufferedFileReader model_buffer(model_file, "old"); | 214 BufferedFileReader model_buffer(model_file, "old"); |
| 215 BufferedFileReader program_buffer(program_file, "new"); | 215 BufferedFileReader program_buffer(program_file, "new"); |
| 216 | 216 |
| 217 auto parser = adjust ? courgette::ParseDetectedExecutableWithAnnotation |
| 218 : courgette::ParseDetectedExecutable; |
| 219 |
| 217 std::unique_ptr<courgette::AssemblyProgram> model; | 220 std::unique_ptr<courgette::AssemblyProgram> model; |
| 218 const courgette::Status parse_model_status = | 221 const courgette::Status parse_model_status = |
| 219 courgette::ParseDetectedExecutable(model_buffer.data(), | 222 parser(model_buffer.data(), model_buffer.length(), &model); |
| 220 model_buffer.length(), &model); | |
| 221 if (parse_model_status != courgette::C_OK) | 223 if (parse_model_status != courgette::C_OK) |
| 222 Problem("Can't parse model input (code = %d).", parse_model_status); | 224 Problem("Can't parse model input (code = %d).", parse_model_status); |
| 223 | 225 |
| 224 std::unique_ptr<courgette::AssemblyProgram> program; | 226 std::unique_ptr<courgette::AssemblyProgram> program; |
| 225 const courgette::Status parse_program_status = | 227 const courgette::Status parse_program_status = |
| 226 courgette::ParseDetectedExecutable(program_buffer.data(), | 228 parser(program_buffer.data(), program_buffer.length(), &program); |
| 227 program_buffer.length(), &program); | |
| 228 if (parse_program_status != courgette::C_OK) | 229 if (parse_program_status != courgette::C_OK) |
| 229 Problem("Can't parse program input (code = %d).", parse_program_status); | 230 Problem("Can't parse program input (code = %d).", parse_program_status); |
| 230 | 231 |
| 231 if (adjust) { | 232 if (adjust) { |
| 232 const courgette::Status adjust_status = Adjust(*model, program.get()); | 233 const courgette::Status adjust_status = Adjust(*model, program.get()); |
| 233 if (adjust_status != courgette::C_OK) | 234 if (adjust_status != courgette::C_OK) |
| 234 Problem("Can't adjust program."); | 235 Problem("Can't adjust program."); |
| 235 } | 236 } |
| 236 | 237 |
| 237 std::unique_ptr<courgette::EncodedProgram> encoded_program; | 238 std::unique_ptr<courgette::EncodedProgram> encoded_program; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 515 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
| 515 DisassembleAdjustDiff(values[0], values[1], values[2], | 516 DisassembleAdjustDiff(values[0], values[1], values[2], |
| 516 cmd_spread_1_adjusted); | 517 cmd_spread_1_adjusted); |
| 517 } else { | 518 } else { |
| 518 UsageProblem("No operation specified"); | 519 UsageProblem("No operation specified"); |
| 519 } | 520 } |
| 520 } | 521 } |
| 521 | 522 |
| 522 return 0; | 523 return 0; |
| 523 } | 524 } |
| OLD | NEW |