Rename BlockFormatter::results
as BlockFormatter::cursor
.
Because it's a `ResultsCursor`, not a `Results`. I find this easier to read and understand.
This commit is contained in:
parent
31e102c509
commit
744eb2f937
@ -96,13 +96,13 @@ fn node_label(&self, block: &Self::Node) -> dot::LabelText<'_> {
|
|||||||
// the value with `None`, move it into the results cursor, move it
|
// the value with `None`, move it into the results cursor, move it
|
||||||
// back out, and return it to the refcell wrapped in `Some`.
|
// back out, and return it to the refcell wrapped in `Some`.
|
||||||
let mut fmt = BlockFormatter {
|
let mut fmt = BlockFormatter {
|
||||||
results: results.take().unwrap().into_results_cursor(self.body),
|
cursor: results.take().unwrap().into_results_cursor(self.body),
|
||||||
style: self.style,
|
style: self.style,
|
||||||
bg: Background::Light,
|
bg: Background::Light,
|
||||||
};
|
};
|
||||||
|
|
||||||
fmt.write_node_label(&mut label, *block).unwrap();
|
fmt.write_node_label(&mut label, *block).unwrap();
|
||||||
Some(fmt.results.into_results())
|
Some(fmt.cursor.into_results())
|
||||||
});
|
});
|
||||||
dot::LabelText::html(String::from_utf8(label).unwrap())
|
dot::LabelText::html(String::from_utf8(label).unwrap())
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ struct BlockFormatter<'mir, 'tcx, A>
|
|||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
results: ResultsCursor<'mir, 'tcx, A>,
|
cursor: ResultsCursor<'mir, 'tcx, A>,
|
||||||
bg: Background,
|
bg: Background,
|
||||||
style: OutputStyle,
|
style: OutputStyle,
|
||||||
}
|
}
|
||||||
@ -219,8 +219,8 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
|
|
||||||
// C: State at start of block
|
// C: State at start of block
|
||||||
self.bg = Background::Light;
|
self.bg = Background::Light;
|
||||||
self.results.seek_to_block_start(block);
|
self.cursor.seek_to_block_start(block);
|
||||||
let block_start_state = self.results.get().clone();
|
let block_start_state = self.cursor.get().clone();
|
||||||
self.write_row_with_full_state(w, "", "(on start)")?;
|
self.write_row_with_full_state(w, "", "(on start)")?;
|
||||||
|
|
||||||
// D + E: Statement and terminator transfer functions
|
// D + E: Statement and terminator transfer functions
|
||||||
@ -228,12 +228,12 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
|
|
||||||
// F: State at end of block
|
// F: State at end of block
|
||||||
|
|
||||||
let terminator = self.results.body()[block].terminator();
|
let terminator = self.cursor.body()[block].terminator();
|
||||||
|
|
||||||
// Write the full dataflow state immediately after the terminator if it differs from the
|
// Write the full dataflow state immediately after the terminator if it differs from the
|
||||||
// state at block entry.
|
// state at block entry.
|
||||||
self.results.seek_to_block_end(block);
|
self.cursor.seek_to_block_end(block);
|
||||||
if self.results.get() != &block_start_state || A::Direction::IS_BACKWARD {
|
if self.cursor.get() != &block_start_state || A::Direction::IS_BACKWARD {
|
||||||
let after_terminator_name = match terminator.kind {
|
let after_terminator_name = match terminator.kind {
|
||||||
mir::TerminatorKind::Call { target: Some(_), .. } => "(on unwind)",
|
mir::TerminatorKind::Call { target: Some(_), .. } => "(on unwind)",
|
||||||
_ => "(on end)",
|
_ => "(on end)",
|
||||||
@ -250,8 +250,8 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
match terminator.kind {
|
match terminator.kind {
|
||||||
mir::TerminatorKind::Call { destination, .. } => {
|
mir::TerminatorKind::Call { destination, .. } => {
|
||||||
self.write_row(w, "", "(on successful return)", |this, w, fmt| {
|
self.write_row(w, "", "(on successful return)", |this, w, fmt| {
|
||||||
let state_on_unwind = this.results.get().clone();
|
let state_on_unwind = this.cursor.get().clone();
|
||||||
this.results.apply_custom_effect(|analysis, state| {
|
this.cursor.apply_custom_effect(|analysis, state| {
|
||||||
analysis.apply_call_return_effect(
|
analysis.apply_call_return_effect(
|
||||||
state,
|
state,
|
||||||
block,
|
block,
|
||||||
@ -265,9 +265,9 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
colspan = this.style.num_state_columns(),
|
colspan = this.style.num_state_columns(),
|
||||||
fmt = fmt,
|
fmt = fmt,
|
||||||
diff = diff_pretty(
|
diff = diff_pretty(
|
||||||
this.results.get(),
|
this.cursor.get(),
|
||||||
&state_on_unwind,
|
&state_on_unwind,
|
||||||
this.results.analysis()
|
this.cursor.analysis()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
@ -275,8 +275,8 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
|
|
||||||
mir::TerminatorKind::Yield { resume, resume_arg, .. } => {
|
mir::TerminatorKind::Yield { resume, resume_arg, .. } => {
|
||||||
self.write_row(w, "", "(on yield resume)", |this, w, fmt| {
|
self.write_row(w, "", "(on yield resume)", |this, w, fmt| {
|
||||||
let state_on_coroutine_drop = this.results.get().clone();
|
let state_on_coroutine_drop = this.cursor.get().clone();
|
||||||
this.results.apply_custom_effect(|analysis, state| {
|
this.cursor.apply_custom_effect(|analysis, state| {
|
||||||
analysis.apply_call_return_effect(
|
analysis.apply_call_return_effect(
|
||||||
state,
|
state,
|
||||||
resume,
|
resume,
|
||||||
@ -290,9 +290,9 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
colspan = this.style.num_state_columns(),
|
colspan = this.style.num_state_columns(),
|
||||||
fmt = fmt,
|
fmt = fmt,
|
||||||
diff = diff_pretty(
|
diff = diff_pretty(
|
||||||
this.results.get(),
|
this.cursor.get(),
|
||||||
&state_on_coroutine_drop,
|
&state_on_coroutine_drop,
|
||||||
this.results.analysis()
|
this.cursor.analysis()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
@ -302,8 +302,8 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
if !targets.is_empty() =>
|
if !targets.is_empty() =>
|
||||||
{
|
{
|
||||||
self.write_row(w, "", "(on successful return)", |this, w, fmt| {
|
self.write_row(w, "", "(on successful return)", |this, w, fmt| {
|
||||||
let state_on_unwind = this.results.get().clone();
|
let state_on_unwind = this.cursor.get().clone();
|
||||||
this.results.apply_custom_effect(|analysis, state| {
|
this.cursor.apply_custom_effect(|analysis, state| {
|
||||||
analysis.apply_call_return_effect(
|
analysis.apply_call_return_effect(
|
||||||
state,
|
state,
|
||||||
block,
|
block,
|
||||||
@ -317,9 +317,9 @@ fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io:
|
|||||||
colspan = this.style.num_state_columns(),
|
colspan = this.style.num_state_columns(),
|
||||||
fmt = fmt,
|
fmt = fmt,
|
||||||
diff = diff_pretty(
|
diff = diff_pretty(
|
||||||
this.results.get(),
|
this.cursor.get(),
|
||||||
&state_on_unwind,
|
&state_on_unwind,
|
||||||
this.results.analysis()
|
this.cursor.analysis()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
@ -407,9 +407,9 @@ fn write_statements_and_terminator(
|
|||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
let diffs = StateDiffCollector::run(
|
let diffs = StateDiffCollector::run(
|
||||||
self.results.body(),
|
self.cursor.body(),
|
||||||
block,
|
block,
|
||||||
self.results.mut_results(),
|
self.cursor.mut_results(),
|
||||||
self.style,
|
self.style,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ fn write_statements_and_terminator(
|
|||||||
if A::Direction::IS_FORWARD { it.next().unwrap() } else { it.next_back().unwrap() }
|
if A::Direction::IS_FORWARD { it.next().unwrap() } else { it.next_back().unwrap() }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i, statement) in self.results.body()[block].statements.iter().enumerate() {
|
for (i, statement) in self.cursor.body()[block].statements.iter().enumerate() {
|
||||||
let statement_str = format!("{statement:?}");
|
let statement_str = format!("{statement:?}");
|
||||||
let index_str = format!("{i}");
|
let index_str = format!("{i}");
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ fn write_statements_and_terminator(
|
|||||||
assert!(diffs_after.is_empty());
|
assert!(diffs_after.is_empty());
|
||||||
assert!(diffs_before.as_ref().map_or(true, ExactSizeIterator::is_empty));
|
assert!(diffs_before.as_ref().map_or(true, ExactSizeIterator::is_empty));
|
||||||
|
|
||||||
let terminator = self.results.body()[block].terminator();
|
let terminator = self.cursor.body()[block].terminator();
|
||||||
let mut terminator_str = String::new();
|
let mut terminator_str = String::new();
|
||||||
terminator.kind.fmt_head(&mut terminator_str).unwrap();
|
terminator.kind.fmt_head(&mut terminator_str).unwrap();
|
||||||
|
|
||||||
@ -492,8 +492,8 @@ fn write_row_with_full_state(
|
|||||||
mir: &str,
|
mir: &str,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
self.write_row(w, i, mir, |this, w, fmt| {
|
self.write_row(w, i, mir, |this, w, fmt| {
|
||||||
let state = this.results.get();
|
let state = this.cursor.get();
|
||||||
let analysis = this.results.analysis();
|
let analysis = this.cursor.analysis();
|
||||||
|
|
||||||
// FIXME: The full state vector can be quite long. It would be nice to split on commas
|
// FIXME: The full state vector can be quite long. It would be nice to split on commas
|
||||||
// and use some text wrapping algorithm.
|
// and use some text wrapping algorithm.
|
||||||
|
Loading…
Reference in New Issue
Block a user