Skip to content

Commit 27a18d5

Browse files
committed
stuff
1 parent 845c37d commit 27a18d5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

jingle_sleigh/src/varnode/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
pub mod display;
2+
mod pod;
23

34
use crate::space::SharedSpaceInfo;
45
use crate::SpaceType;
56
use std::fmt::Debug;
67
use std::hash::Hash;
78
use std::ops::Range;
9+
use crate::varnode::pod::PodVarNode;
810

911
/// A [`VarNode`] is `SLEIGH`'s generalization of an address. It describes a sized-location in
1012
/// a given memory space.
@@ -41,6 +43,9 @@ impl VarNode {
4143
let other = other.offset..(other.offset + other.size as u64);
4244
self_range.start <= other.start && self_range.end >= other.end
4345
}
46+
pub fn to_pod(&self) -> PodVarNode{
47+
self.into()
48+
}
4449
}
4550

4651
impl From<&VarNode> for Range<u64> {

jingle_sleigh/src/varnode/pod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use crate::context::SleighContext;
2+
use crate::VarNode;
3+
4+
/// A "plain-old-data" version of a [VarNode], suitable for passing between threads
5+
/// and serialization/deserialization tasks.
6+
pub struct PodVarNode{
7+
space_index: usize,
8+
size: usize,
9+
offset: u64,
10+
}
11+
12+
impl From<&VarNode> for PodVarNode {
13+
fn from(value: &VarNode) -> Self {
14+
Self{
15+
size: value.size,
16+
offset: value.offset,
17+
space_index: value.space.index
18+
}
19+
}
20+
}
21+
22+
impl From<VarNode> for PodVarNode {
23+
fn from(value: VarNode) -> Self {
24+
(&value).into()
25+
}
26+
}
27+
28+
impl PodVarNode{
29+
pub fn to_varnode(self, ctx: &SleighContext) -> VarNode{
30+
todo!("Hmmm, might need to think this through more")
31+
}
32+
}

0 commit comments

Comments
 (0)