mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Update nested if to better structure
This commit is contained in:
parent
f6ca8048da
commit
7df5af246e
1 changed files with 17 additions and 21 deletions
|
@ -1134,29 +1134,25 @@ pub fn surgery(matches: &ArgMatches) -> io::Result<i32> {
|
|||
);
|
||||
}
|
||||
Some(*target_offset as i64)
|
||||
} else if let Ok(sym) = app_obj.symbol_by_index(index) {
|
||||
// TODO: Is there a better way to deal with all this nesting in rust.
|
||||
// I really want the experimental multiple if let statement.
|
||||
// Not one of the apps symbols, check if it is from the roc host.
|
||||
if let Ok(name) = sym.name() {
|
||||
if let Some(address) = md.roc_symbol_vaddresses.get(name) {
|
||||
let vaddr = (*address + md.added_byte_count) as i64;
|
||||
if verbose {
|
||||
println!(
|
||||
"\t\tRelocation targets symbol in host: {} @ {:+x}",
|
||||
name, vaddr
|
||||
);
|
||||
}
|
||||
Some(vaddr)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
app_obj
|
||||
.symbol_by_index(index)
|
||||
.and_then(|sym| sym.name())
|
||||
.ok()
|
||||
.and_then(|name| {
|
||||
md.roc_symbol_vaddresses.get(name).map(|address| {
|
||||
let vaddr = (*address + md.added_byte_count) as i64;
|
||||
if verbose {
|
||||
println!(
|
||||
"\t\tRelocation targets symbol in host: {} @ {:+x}",
|
||||
name, vaddr
|
||||
);
|
||||
}
|
||||
vaddr
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
if let Some(target_offset) = target_offset {
|
||||
let virt_base = section_virtual_offset as usize + rel.0 as usize;
|
||||
let base = section_offset as usize + rel.0 as usize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue