Skip to content

Commit d2f355b

Browse files
committed
mk_graph: remove is_local and add raw_stmts to RenderedBlock
Remove the unused is_local field from RenderedFunction since the local/external distinction is already represented structurally in the GraphBuilder API. Add raw_stmts to RenderedBlock as an escape hatch for renderers that need access to the underlying MIR statements in addition to the pre-rendered strings.
1 parent 9552849 commit d2f355b

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/mk_graph/traverse.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! This module owns the traversal order and graph semantics.
44
extern crate stable_mir;
5-
use stable_mir::mir::{Body, Terminator, TerminatorKind};
5+
use stable_mir::mir::{Body, Statement, Terminator, TerminatorKind};
66

77
use crate::printer::SmirJson;
88
use crate::MonoItemKind;
@@ -29,11 +29,12 @@ pub struct CallEdge {
2929
/// `GraphContext`. Builders are free to format or escape them according
3030
/// to their output format.
3131
///
32-
/// `raw_terminator` is provided as an escape hatch for renderers that
33-
/// need to inspect the underlying MIR structure.
32+
/// `raw_stmts` and `raw_terminator` are escape hatches for renderers
33+
/// that need to inspect the underlying MIR structure.
3434
pub struct RenderedBlock<'a> {
3535
pub idx: usize,
3636
pub stmts: Vec<String>,
37+
pub raw_stmts: &'a [Statement],
3738
pub terminator: String,
3839
pub raw_terminator: &'a Terminator,
3940
pub cfg_edges: Vec<(usize, Option<String>)>,
@@ -48,7 +49,6 @@ pub struct RenderedBlock<'a> {
4849
pub struct RenderedFunction<'a> {
4950
pub id: String,
5051
pub display_name: String,
51-
pub is_local: bool,
5252
pub locals: Vec<(usize, String)>,
5353
pub blocks: Vec<RenderedBlock<'a>>,
5454
pub call_edges: Vec<CallEdge>,
@@ -130,7 +130,6 @@ fn render_function<'a>(
130130
};
131131

132132
let display_name = name_lines(name);
133-
let is_local = body.is_some();
134133

135134
let mut blocks = Vec::new();
136135
let mut call_edges = Vec::new();
@@ -158,6 +157,7 @@ fn render_function<'a>(
158157
blocks.push(RenderedBlock {
159158
idx,
160159
stmts,
160+
raw_stmts: &block.statements,
161161
terminator,
162162
raw_terminator: &block.terminator,
163163
cfg_edges,
@@ -187,7 +187,6 @@ fn render_function<'a>(
187187
RenderedFunction {
188188
id,
189189
display_name,
190-
is_local,
191190
locals,
192191
blocks,
193192
call_edges,

0 commit comments

Comments
 (0)