Skip to content

Commit cf85b34

Browse files
committed
fix various issues
1 parent 450881e commit cf85b34

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

crates/tinywasm/src/func.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ impl crate::coro::CoroState<Vec<WasmValue>, &mut Store> for SuspendedFunc {
215215
}
216216
}
217217

218+
/// A typed suspended function.
219+
/// Only returned value(s) are typed, yielded value and resume argument types are impossible to know
218220
#[cfg_attr(not(feature = "async"), allow(unused))]
219221
pub struct SuspendedFuncTyped<R> {
222+
/// The underlying untyped suspended function
220223
pub func: SuspendedFunc,
221224
pub(crate) _marker: core::marker::PhantomData<R>,
222225
}

crates/tinywasm/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ pub(crate) mod log {
9393
mod error;
9494
#[cfg(not(feature = "async"))]
9595
#[allow(unused)]
96-
use coro::{CoroState, CoroStateResumeResult, PotentialCoroCallResult, SuspendReason};
96+
use {
97+
coro::{CoroState, CoroStateResumeResult, PotentialCoroCallResult, SuspendReason},
98+
func::{SuspendedFunc, SuspendedFuncTyped},
99+
};
97100
#[cfg(feature = "async")]
98101
pub use {
99102
coro::{CoroState, CoroStateResumeResult, PotentialCoroCallResult, SuspendReason},
103+
func::{SuspendedFunc, SuspendedFuncTyped},
100104
module::IncompleteModule,
101105
};
102106

103107
pub use error::*;
104-
pub use func::{FuncHandle, FuncHandleTyped, SuspendedFunc};
108+
pub use func::{FuncHandle, FuncHandleTyped};
105109
pub use imports::*;
106110
pub use instance::ModuleInstance;
107111
pub use module::Module;

crates/tinywasm/src/store/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ mod memory;
1414
mod suspend_conditions;
1515
mod table;
1616

17+
#[cfg(feature = "async")]
1718
pub use suspend_conditions::*;
19+
1820
pub(crate) use {data::*, element::*, function::*, global::*, memory::*, table::*};
1921

2022
// global store id counter
@@ -40,6 +42,7 @@ pub struct Store {
4042
// and (less obviously) to host functions called from store - for calling wasm callbacks and propagating this config to them
4143
// (or just complying with suspend conditions themselves)
4244
// alternatively it could be passed to function handles and passend into function context
45+
#[cfg(feature = "async")]
4346
pub(crate) suspend_cond: SuspendConditions,
4447
}
4548

@@ -96,6 +99,7 @@ impl Default for Store {
9699
module_instances: Vec::new(),
97100
data: StoreData::default(),
98101
runtime: Runtime::Default,
102+
#[cfg(feature = "async")]
99103
suspend_cond: SuspendConditions::default(),
100104
}
101105
}
@@ -492,6 +496,7 @@ fn get_pair_mut<T>(slice: &mut [T], i: usize, j: usize) -> Option<(&mut T, &mut
492496
}
493497

494498
// suspend_conditions-related functions
499+
#[cfg(feature = "async")]
495500
impl Store {
496501
/// sets suspend conditions for store
497502
pub fn set_suspend_conditions(&mut self, val: SuspendConditions) {

crates/tinywasm/src/store/suspend_conditions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "async")]
2+
13
use crate::store::Store;
24
use alloc::boxed::Box;
35
use core::fmt::Debug;

crates/tinywasm/tests/testsuite/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::hash::Hasher;
22
use std::panic::{self, AssertUnwindSafe};
33

44
use eyre::{bail, eyre, Result};
5+
#[cfg(feature = "test_async")]
56
use tinywasm::{CoroState, SuspendConditions, SuspendReason};
67
use tinywasm_types::{ExternRef, FuncRef, ModuleInstanceAddr, TinyWasmModule, ValType, WasmValue};
78
use wasm_testsuite::wast;
@@ -15,6 +16,7 @@ pub fn try_downcast_panic(panic: Box<dyn std::any::Any + Send>) -> String {
1516
}
1617

1718
// due to imprecision it's not exact
19+
#[cfg(feature = "test_async")]
1820
fn make_sometimes_breaking_cb(probability: f64) -> impl FnMut(&tinywasm::Store) -> std::ops::ControlFlow<(), ()> {
1921
let mut counter = 0 as u64;
2022
let mut hasher = std::hash::DefaultHasher::new();

0 commit comments

Comments
 (0)