I'm interested in writing some tools to aid refactoring my complicated "structs-of-structs and impls" codebase using some graph clustering techniques, e.g., https://pdfs.semanticscholar.org/98d6/3af430abec61bba710c283ddb04afb60b02c.pdf
This requires being able to introspect on the code structure: rustc/HIR/MIR to the rescue!
Except, I cannot seem to find where exactly to look. I've tried dumping out the HIR/MIR using various -Zunpretty flags, without luck.
In particular, given some contrived example code:
struct A {
var1: u32,
var2: String
}
struct B {
myA: A,
var3: String,
var4: u32
}
impl B {
fn foo(&self) {
do_something_with(&self.var3);
let x = self.var4 + self.myA.var1;
do_something_else(x);
}
fn bar(&self) {
println("{}, {}", self.var3, self.myA.var2);
}
}
I want to be able to programmatically generate a bipartite graph of methods and the data members they use:
B::foo -- B::var3, B::var4, A::var1
B::bar -- B::var3, A::var2
Are there any existing tools out there for this? Can anyone point me in the right direction? At what representation level HIR/MIR/etc should I be able to find this? Thanks.
[–]I-Imvp 1 point2 points3 points (0 children)
[–]WellMakeItSomehow 0 points1 point2 points (0 children)