Skip to content

Commit

Permalink
Collapse jump to jump
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 4, 2023
1 parent 063ab36 commit d38abb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion valuescript_compiler/src/optimization/simplify_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ fn simplify_jumps_fn(fn_: &mut Function) {
// Instead of jumping to `end`, just end
substitutions.insert(i, FnLine::Instruction(Instruction::End));
}
FnLine::Instruction(_) => {} // TODO: Collapse jump to jump
FnLine::Instruction(Instruction::Jmp(label_ref)) => {
// Instead of jumping to another jump, jump directly to where that one goes
substitutions.insert(i, FnLine::Instruction(Instruction::Jmp(label_ref.clone())));
}
FnLine::Instruction(_) => {}
FnLine::Label(_) | FnLine::Empty | FnLine::Comment(_) | FnLine::Release(_) => {
panic!("Jump to non-instruction")
}
Expand Down

0 comments on commit d38abb7

Please sign in to comment.