fix errors
This commit is contained in:
parent
e530001a05
commit
b4cb7fa12c
|
@ -50,7 +50,10 @@ impl HashTableHeader {
|
|||
}
|
||||
|
||||
pub fn tabsize(&self) -> usize {
|
||||
let tmp: usize = 4 + usize::try_from(self.nbuckets).unwrap() + 8 * usize::try_from(self.nchains).unwrap() + 2 * usize::from(self.nblf);
|
||||
let tmp: usize = 4
|
||||
+ usize::try_from(self.nbuckets).unwrap()
|
||||
+ 8 * usize::try_from(self.nchains).unwrap()
|
||||
+ 2 * usize::from(self.nblf);
|
||||
4 * tmp
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ fn typ_to_txt(typ: u32) -> String {
|
|||
use yglnk_core::IntEnum;
|
||||
match yglnk_core::Type::from_int(typ) {
|
||||
Ok(x) => format!("{:?}", x),
|
||||
Err(_) => format!("{:08x}", x),
|
||||
Err(_) => format!("{:08x}", typ),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,23 +40,43 @@ fn main() {
|
|||
let cli = <Cli as clap::Parser>::parse();
|
||||
|
||||
let fh = std::fs::File::open(&cli.file).expect("unable to open specified file");
|
||||
let data = unsafe { memmap2::MmapOptions::new().map(&fh)? };
|
||||
let data = unsafe { memmap2::MmapOptions::new().map(&fh).expect("unable to mmap specified file") };
|
||||
let data = &data[..];
|
||||
|
||||
match &cli.command {
|
||||
Command::Linear => {
|
||||
let ltr = yglnk_core::LinearTableRef::parse(data, cli.location).expect("unable to parse table header");
|
||||
let ltr = yglnk_core::LinearTableRef::parse(data, cli.location)
|
||||
.expect("unable to parse table header");
|
||||
println!("name\ttyp\tlocation\tmeta\trest");
|
||||
for i in ltr {
|
||||
println!("{:?}\t{}\t{:08x}\t{:08x}\t{:x}", ltr.name, typ_to_txt(ltr.typ), ltr.location, ltr.meta, ltr.rest);
|
||||
println!(
|
||||
"{:?}\t{}\t{:08x}\t{:08x}\t",
|
||||
i.name,
|
||||
typ_to_txt(i.typ),
|
||||
i.location,
|
||||
i.meta,
|
||||
);
|
||||
for j in i.rest {
|
||||
print!("{:02x}", j);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
},
|
||||
}
|
||||
Command::Hash => {
|
||||
let ht = yglnk_core::HashTableRef::parse(data, cli.location).expect("unable to parse table header");
|
||||
let ht = yglnk_core::HashTableRef::parse(data, cli.location)
|
||||
.expect("unable to parse table header");
|
||||
println!("hash\tname\ttyp\tL\tR");
|
||||
for (hash, name, typ, val_l, val_r) in ht.iter() {
|
||||
println!("{:016x}\t{:?}\t{}\t{:016x}\t{:016x}", hash, name, typ_to_txt(typ), val_l, val_r);
|
||||
println!(
|
||||
"{:016x}\t{:?}\t{}\t{:016x}\t{:016x}",
|
||||
hash,
|
||||
name,
|
||||
typ_to_txt(typ),
|
||||
val_l,
|
||||
val_r
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
Command::X2dhc => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ The reason this table doesn't allow more data per entry is that performance hing
|
|||
|
||||
```
|
||||
2dt header := xybits[1b] reserved[15b]
|
||||
2dt entry := meta[8b] location[4b] length[4b]
|
||||
2dt entry := meta[8b] location[8b]
|
||||
```
|
||||
|
||||
# Examples
|
||||
|
|
Loading…
Reference in a new issue