Skip to content

Commit 4fb8fc8

Browse files
author
Arnaud Riess
committed
feat: add 'heck' dependency and refactor module name conversion to use ToUpperCamelCase
1 parent 473adc5 commit 4fb8fc8

4 files changed

Lines changed: 5 additions & 12 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ members = [
99
[workspace.dependencies]
1010
anyhow = "1"
1111
clap = { version = "4", features = ["derive"] }
12+
heck = "0.5"
1213
wasmparser = "0.227"
1314
wat = "1.220"
1415
kani-verifier = "0.57"

crates/herkos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ categories = ["wasm", "development-tools::build-utils"]
1414
wasmparser = { workspace = true }
1515
anyhow = { workspace = true }
1616
clap = { workspace = true }
17+
heck = { workspace = true }
1718

1819
[dev-dependencies]
1920
wat = { workspace = true }

crates/herkos/src/codegen/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use crate::backend::Backend;
1010
use crate::ir::*;
1111
use anyhow::{Context, Result};
12+
use heck::ToUpperCamelCase;
1213

1314
// ─── Helper functions ───────────────────────────────────────────────────────
1415

@@ -18,18 +19,7 @@ use anyhow::{Context, Result};
1819
/// - "env" → "EnvImports"
1920
/// - "wasi_snapshot_preview1" → "WasiSnapshotPreview1Imports"
2021
fn module_name_to_trait_name(module_name: &str) -> String {
21-
// Convert to PascalCase and append "Imports"
22-
let pascal = module_name
23-
.split('_')
24-
.map(|part| {
25-
let mut chars = part.chars();
26-
match chars.next() {
27-
None => String::new(),
28-
Some(first) => first.to_uppercase().chain(chars).collect(),
29-
}
30-
})
31-
.collect::<String>();
32-
format!("{pascal}Imports")
22+
format!("{}Imports", module_name.to_upper_camel_case())
3323
}
3424

3525
/// Group function imports by module name.

0 commit comments

Comments
 (0)