Open meithecatte opened 1 year ago
oooh, that's interesting. i've typically used U8Reader
and Reader<Addr, Word>
in places that are generic over Arch
(and so, Arch's address and word types). so in those cases, this looks more like:
{other stuff elided}
let addr: A::Address = reader.total_offset();
// do _something_ with addr - index a hashmap, call `AddressBase::to_linear`, ...
so in fact i'd never seen the full name written out like that!
the fact that U8Reader
doesn't have a hint about the item type is kind of intentional - my hope has been for the reader type to be interchangeable when you might switch between ISAs (think interleaved aarch32/thumb code, for example). that's really why it's not U8Reader<Address, Word>
.
the x86 decoders, at least, have InstDecoder::decode_slice
that more looks like the case you're working with. then you'd have to use yaxpeax_arch::LengthedInstruction
and inst.len()
to get lengths, but it's a little less... verbose.
i've been idly wondering if there's a nice way to fit this in interfaces defined by yaxpeax-arch
, and i'm not super sure?
rustc demands this monstrosity of a type annotation:
This is because
let addr: u64 = reader.total_offset()
contains no hints as to whatItem
should be inReader<u64, Item>
. Moreover this can vary per callsite, so there's no way to hint it once and then forget it.Am I missing something?