Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: todos in datagraph and nodeop replacement bug #92

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 46 additions & 65 deletions rapx/src/analysis/core/dataflow/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,97 +38,78 @@ impl GraphNode {
) -> String {
let mut attr = String::new();
let mut dot = String::new();
match self.op {
//label=xxx
NodeOp::Nop => {
if is_marker {
if is_marker {
// only Nop and Const can be marker node and they only have one op
assert!(self.ops.len() == 1);
match self.ops[0] {
NodeOp::Nop => {
write!(attr, "label=\"\" style=dashed ").unwrap();
} else {
write!(attr, "label=\"<f0> {:?}\" ", local).unwrap();
}
}
NodeOp::Const(ref name) => {
write!(
attr,
"label=\"<f0> {}\" style=dashed ",
escaped_string(name.clone())
)
.unwrap();
}
NodeOp::Call(def_id) => {
let func_name = tcx.def_path_str(def_id);
if is_marker {
NodeOp::Const(ref name) => {
write!(
attr,
"label=\"fn {}\" style=dashed ",
escaped_string(func_name)
"label=\"<f0> {}\" style=dashed ",
escaped_string(name.clone())
)
.unwrap();
} else {
}
_ => {
panic!("Wrong arm!");
}
}
}
write!(attr, "label=\"<f0> {:?} ", local).unwrap();
let mut seq = 1;
self.ops.iter().for_each(|op| {
match op {
//label=xxx
NodeOp::Nop => {}
NodeOp::Const(..) => {}
NodeOp::Call(def_id) => {
let func_name = tcx.def_path_str(def_id);
write!(
attr,
"label=\"<f0> {:?} | <f1> fn {}\" ",
local,
"| <f{}> ({})fn {} ",
seq,
seq - 1,
escaped_string(func_name)
)
.unwrap();
}
}
NodeOp::Aggregate(agg_kind) => match agg_kind {
AggKind::Adt(def_id) => {
let agg_name = format!("{}::{{..}}", tcx.def_path_str(def_id));
if is_marker {
write!(
attr,
"label=\"Agg {}\" style=dashed ",
escaped_string(agg_name)
)
.unwrap();
} else {
NodeOp::Aggregate(agg_kind) => match agg_kind {
AggKind::Adt(def_id) => {
let agg_name = format!("{}::{{..}}", tcx.def_path_str(def_id));
write!(
attr,
"label=\"<f0> {:?} | <f1> Agg {}\" ",
local,
"| <f{}> ({})Agg {} ",
seq,
seq - 1,
escaped_string(agg_name)
)
.unwrap();
}
}
AggKind::Closure(def_id) => {
let agg_name = tcx.def_path_str(def_id);
if is_marker {
write!(
attr,
"label=\"Clos {}\" style=dashed ",
escaped_string(agg_name)
)
.unwrap();
} else {
AggKind::Closure(def_id) => {
let agg_name = tcx.def_path_str(def_id);
write!(
attr,
"label=\"<f0> {:?} | <f1> Clos {}\" ",
local,
"| <f{}> ({})Clos {} ",
seq,
seq - 1,
escaped_string(agg_name)
)
.unwrap();
}
}
_ => {
if is_marker {
write!(attr, "label=\"{:?}\" style=dashed ", agg_kind).unwrap();
} else {
write!(attr, "label=\"<f0> {:?} | {:?}\" ", local, agg_kind).unwrap();
_ => {
write!(attr, "| <f{}> ({}){:?} ", seq, seq - 1, agg_kind).unwrap();
}
},
_ => {
write!(attr, "| <f{}> ({}){:?} ", seq, seq - 1, op).unwrap();
}
},
_ => {
if is_marker {
write!(attr, "label=\"<f1> {:?}\" style=dashed ", self.op).unwrap();
} else {
write!(attr, "label=\"<f0> {:?} | <f1> {:?}\" ", local, self.op).unwrap();
}
}
};
};
seq += 1;
});
write!(attr, "\"").unwrap();
match color {
//color=xxx
None => {}
Expand Down
Loading