Skip to content

Commit 1957af0

Browse files
Cleanup
- renamed module - fixed warnings in different feature configurations
1 parent 5aa07fc commit 1957af0

File tree

19 files changed

+62
-176
lines changed

19 files changed

+62
-176
lines changed

crates/cli/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ categories.workspace = true
1414
exclude.workspace = true
1515

1616
[dependencies]
17-
wasmi = { workspace = true, default-features = false, features = [
18-
"wat",
19-
"serialization",
20-
"deserialization",
21-
"parser",
22-
] }
17+
wasmi = { workspace = true, features = ["wat"] }
2318
wasmi_wasi = { workspace = true }
2419
anyhow = "1"
2520
clap = { version = "4", features = ["derive"] }

crates/cli/src/args.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,7 @@ use std::{
88
};
99
use wasmi_wasi::{ambient_authority, Dir, TcpListener, WasiCtx, WasiCtxBuilder};
1010

11-
#[derive(Parser, Debug)]
12-
#[clap(author, version, about, long_about = None, trailing_var_arg = true)]
13-
pub enum Cli {
14-
Args(Args),
15-
Serialize(SerializeArgs),
16-
}
17-
18-
#[derive(Parser, Debug)]
19-
pub struct SerializeArgs {
20-
/// The file containing the WebAssembly module to serialize.
21-
#[clap(value_name = "MODULE", value_hint = clap::ValueHint::FilePath)]
22-
pub module: PathBuf,
23-
/// The output file for the serialized module (or '-' for stdout).
24-
#[clap(long, value_name = "OUTPUT", value_hint = clap::ValueHint::FilePath)]
25-
pub output: Option<PathBuf>,
26-
}
27-
11+
/// A CLI flag value key-value argument.
2812
#[derive(Debug, Clone)]
2913
struct KeyValue {
3014
key: String,

crates/cli/src/main.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::{
2-
args::{Args, Cli},
2+
args::Args,
33
display::{DisplayExportedFuncs, DisplayFuncType, DisplaySequence, DisplayValue},
4-
serialize::serialize,
54
};
65
use anyhow::{anyhow, bail, Error, Result};
76
use clap::Parser;
@@ -12,22 +11,13 @@ use wasmi::{Func, FuncType, Val};
1211
mod args;
1312
mod context;
1413
mod display;
15-
mod serialize;
1614
mod utils;
1715

1816
#[cfg(test)]
1917
mod tests;
2018

2119
fn main() -> Result<()> {
22-
let cli = Cli::parse();
23-
24-
match cli {
25-
Cli::Args(args) => run(args),
26-
Cli::Serialize(args) => serialize(args),
27-
}
28-
}
29-
30-
fn run(args: Args) -> Result<()> {
20+
let args = Args::parse();
3121
let wasm_file = args.wasm_file();
3222
let wasi_ctx = args.wasi_context()?;
3323
let mut ctx = Context::new(wasm_file, wasi_ctx, args.fuel(), args.compilation_mode())?;

crates/cli/src/serialize.rs

Lines changed: 0 additions & 46 deletions
This file was deleted.

crates/ir/src/enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn size_of() {
315315
assert_eq!(::core::mem::align_of::<Instruction>(), 4);
316316
}
317317

318-
#[cfg(all(test, any(feature = "serialization", feature = "deserialization")))]
318+
#[cfg(all(test, feature = "serialization", feature = "deserialization"))]
319319
mod serde_tests {
320320
use super::*;
321321

crates/wasmi/src/engine/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ impl Engine {
425425
}
426426

427427
/// Returns all Wasmi IR instructions for the given EngineFunc.
428+
#[cfg(feature = "serialization")]
428429
pub(crate) fn get_instructions(
429430
&self,
430431
func: crate::engine::EngineFunc,
@@ -436,6 +437,7 @@ impl Engine {
436437
}
437438

438439
/// Returns a reference to the compiled function data for the given EngineFunc.
440+
#[cfg(feature = "serialization")]
439441
pub(crate) fn get_compiled_func(
440442
&self,
441443
func: crate::engine::EngineFunc,

crates/wasmi/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ mod foreach_tuple;
9393
#[cfg(all(test, feature = "parser"))]
9494
pub mod tests;
9595

96-
pub mod serialization;
96+
#[cfg(any(feature = "serialization", feature = "deserialization"))]
97+
pub mod preparsed;
9798

9899
pub(crate) mod engine;
99100
mod error;

crates/wasmi/src/module/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ impl ModuleHeaderBuilder {
378378

379379
impl ModuleBuilder {
380380
/// Sets the data segments for the module, replacing any previously set segments.
381+
#[cfg(feature = "deserialization")]
381382
pub fn set_data_segments(&mut self, data_segments: super::data::DataSegments) {
382383
self.data_segments = super::data::DataSegmentsBuilder::from_data_segments(data_segments);
383384
}

crates/wasmi/src/module/data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl AsRef<[u8]> for PassiveDataSegmentBytes {
6363
}
6464
}
6565

66+
#[cfg(feature = "deserialization")]
6667
impl PassiveDataSegmentBytes {
6768
pub(crate) fn from_vec(vec: Vec<u8>) -> Self {
6869
Self {

crates/wasmi/src/module/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,19 +532,16 @@ impl Module {
532532
self.inner.custom_sections.iter()
533533
}
534534

535-
/// Returns the start function index if present, as a u32.
536-
pub(crate) fn start_func_index(&self) -> Option<u32> {
537-
self.module_header().start.map(export::FuncIdx::into_u32)
538-
}
539-
540535
/// Returns an iterator over all data segments as InitDataSegment, including their bytes.
536+
#[cfg(feature = "serialization")]
541537
pub(crate) fn all_init_data_segments(
542538
&self,
543539
) -> impl Iterator<Item = crate::module::InitDataSegment<'_>> {
544540
self.inner.data_segments.into_iter()
545541
}
546542

547543
/// Returns an iterator over all element segments.
544+
#[cfg(feature = "serialization")]
548545
pub(crate) fn element_segments(&self) -> impl Iterator<Item = &ElementSegment> {
549546
self.module_header().element_segments.iter()
550547
}

0 commit comments

Comments
 (0)