MCPcopy Create free account
hub / github.com/chc4/lineiform / decode_stream

Function decode_stream

tangle/src/ir.rs:34–62  ·  view source on GitHub ↗
(data: U)

Source from the content-addressed store, hash-verified

32 use yaxpeax_arch::{Decoder, Reader, ReaderBuilder};
33
34 pub fn decode_stream<
35 'data,
36 A: yaxpeax_arch::Arch,
37 U: ReaderBuilder<A::Address, A::Word>,
38 >(data: U) -> Vec<A::Instruction>
39 where A::Instruction: std::fmt::Display
40 {
41 let mut reader = ReaderBuilder::read_from(data);
42 let mut address: A::Address = reader.total_offset();
43
44 let decoder = A::Decoder::default();
45 let mut decode_res = decoder.decode(&mut reader);
46 let mut res = Vec::new();
47 loop {
48 match decode_res {
49 Ok(inst) => {
50 //println!("{}: {}", address.show(), inst);
51 decode_res = decoder.decode(&mut reader);
52 address = reader.total_offset();
53 res.push(inst);
54 }
55 Err(e) => {
56 //println!("{}: decode error: {}", address.show(), e);
57 break;
58 }
59 }
60 }
61 res
62 }
63}
64
65

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected