Skip to content

Commit

Permalink
feature: add miden-package crate with Package type to represent
Browse files Browse the repository at this point in the history
compiled Miden program/library.
  • Loading branch information
greenhat committed Oct 28, 2024
1 parent dc41735 commit 3fb46fa
Show file tree
Hide file tree
Showing 11 changed files with 731 additions and 34 deletions.
128 changes: 94 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"assembly",
"core",
"miden",
"package",
"processor",
"prover",
"stdlib",
Expand Down
5 changes: 5 additions & 0 deletions assembly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ doctest = false
default = ["std"]
std = ["aho-corasick/std", "miette/fancy", "miette/std", "thiserror/std", "vm-core/std"]
testing = ["dep:regex"]
serde = [
"dep:serde",
"smallvec/serde",
]

[dependencies]
aho-corasick = { version = "1.1", default-features = false }
Expand All @@ -37,6 +41,7 @@ unicode-width = { version = "0.1", features = ["no_std"] }
vm-core = { package = "miden-core", path = "../core", version = "0.10", default-features = false, features = [
"diagnostics",
] }
serde = { version = "1.0.208", features = ["alloc", "rc", "serde_derive"], optional = true }

[dev-dependencies]
pretty_assertions = "1.4"
Expand Down
35 changes: 35 additions & 0 deletions assembly/src/ast/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,38 @@ impl FromStr for Ident {
Ok(Self { span: SourceSpan::default(), name })
}
}

#[cfg(feature = "serde")]
impl serde::Serialize for Ident {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
self.as_str().serialize(serializer)
}
}

#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for Ident {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct IdentVisitor;
impl<'de> serde::de::Visitor<'de> for IdentVisitor {
type Value = Ident;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("ident")
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
Ok(Ident::new_unchecked(Span::unknown(Arc::from(v))))
}
}
deserializer.deserialize_str(IdentVisitor)
}
}
Loading

0 comments on commit 3fb46fa

Please sign in to comment.