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

feat: expose pretty printing helper for mast nodes #1441

Merged
merged 2 commits into from
Aug 10, 2024
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

#### Enhancements

- Exposed some pretty printing internals for `MastNode`
- Made `KernelLibrary` impl `Clone` and `AsRef<Library>`

## 0.10.0 (2024-08-06)

#### Features
Expand Down
8 changes: 8 additions & 0 deletions assembly/src/library/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,20 @@ impl Export {
/// - All exported procedures must be exported directly from the kernel namespace (i.e., `#sys`).
/// - There must be at least one exported procedure.
/// - The number of exported procedures cannot exceed [Kernel::MAX_NUM_PROCEDURES] (i.e., 256).
#[derive(Clone)]
pub struct KernelLibrary {
kernel: Kernel,
kernel_info: ModuleInfo,
library: Library,
}

impl AsRef<Library> for KernelLibrary {
#[inline(always)]
fn as_ref(&self) -> &Library {
&self.library
}
}

impl KernelLibrary {
/// Returns the inner [`MastForest`].
pub fn mast_forest(&self) -> &MastForest {
Expand Down
5 changes: 1 addition & 4 deletions core/src/mast/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ impl MastNode {
matches!(self, Self::Block(_))
}

pub(crate) fn to_pretty_print<'a>(
&'a self,
mast_forest: &'a MastForest,
) -> impl PrettyPrint + 'a {
pub fn to_pretty_print<'a>(&'a self, mast_forest: &'a MastForest) -> impl PrettyPrint + 'a {
match self {
MastNode::Block(basic_block_node) => {
MastNodePrettyPrint::new(Box::new(basic_block_node))
Expand Down
Loading