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

Unified Diff: courgette/assembly_program.cc

Issue 2457133002: [Courgette] Refactor: Add AssemblyProgram::DispatchInstructionLabels() to hide InstructionVector us… (Closed)
Patch Set: Rename 'Dispatch' to 'Handle'. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/assembly_program.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/assembly_program.cc
diff --git a/courgette/assembly_program.cc b/courgette/assembly_program.cc
index f20ed67ea3fa3e6a462f7d99e49153b7eec3d22c..d36556fc67ad4e90496a551ad5f7b32f51a6bedf 100644
--- a/courgette/assembly_program.cc
+++ b/courgette/assembly_program.cc
@@ -217,28 +217,15 @@ Label* AssemblyProgram::FindRel32Label(RVA rva) {
return rel32_label_manager_.Find(rva);
}
-Label* AssemblyProgram::InstructionAbs32Label(
- const Instruction* instruction) const {
- if (instruction->op() == ABS32)
- return static_cast<const InstructionWithLabel*>(instruction)->label();
- return NULL;
-}
-
-Label* AssemblyProgram::InstructionAbs64Label(
- const Instruction* instruction) const {
- if (instruction->op() == ABS64)
- return static_cast<const InstructionWithLabel*>(instruction)->label();
- return NULL;
-}
-
-Label* AssemblyProgram::InstructionRel32Label(
- const Instruction* instruction) const {
- if (instruction->op() == REL32 || instruction->op() == REL32ARM) {
- Label* label =
- static_cast<const InstructionWithLabel*>(instruction)->label();
- return label;
+void AssemblyProgram::HandleInstructionLabels(
+ const AssemblyProgram::LabelHandlerMap& handler_map) const {
+ for (const Instruction* instruction : instructions_) {
+ LabelHandlerMap::const_iterator it = handler_map.find(instruction->op());
+ if (it != handler_map.end()) {
+ it->second.Run(
+ static_cast<const InstructionWithLabel*>(instruction)->label());
+ }
}
- return NULL;
}
CheckBool AssemblyProgram::Emit(ScopedInstruction instruction) {
« no previous file with comments | « courgette/assembly_program.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698