Skip to content

Commit bc09f1b

Browse files
committed
Merge branch 'feat/reduce-julia-v-testing' into feat/use-rust-wasmtime
2 parents 8aecbbe + 227c78a commit bc09f1b

File tree

30 files changed

+1361
-1332
lines changed

30 files changed

+1361
-1332
lines changed

Cargo.lock

Lines changed: 13 additions & 3 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
@@ -122,6 +122,7 @@ pecos-qis-selene = { version = "0.1.1", path = "crates/pecos-qis-selene" }
122122
pecos-qis-core = { version = "0.1.1", path = "crates/pecos-qis-core" }
123123
pecos-hugr-qis = { version = "0.1.1", path = "crates/pecos-hugr-qis" }
124124
pecos-rslib = { version = "0.1.1", path = "python/pecos-rslib/rust" }
125+
pecos-wasm = { version = "0.1.1", path = "crates/pecos-wasm" }
125126
pecos-build-utils = { version = "0.1.1", path = "crates/pecos-build-utils" }
126127
pecos-llvm-utils = { version = "0.1.1", path = "crates/pecos-llvm-utils" }
127128

crates/pecos-phir-json/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ description = "PHIR-JSON (PECOS High-level Intermediate Representation JSON form
1515
default = ["v0_1", "wasm"]
1616
v0_1 = []
1717
all-versions = ["v0_1"]
18-
wasm = ["wasmtime", "wat", "parking_lot"]
18+
wasm = ["pecos-wasm/wasm", "wat"]
1919

2020
[dependencies]
2121
log.workspace = true
@@ -25,9 +25,8 @@ pecos-core.workspace = true
2525
pecos-engines.workspace = true
2626
pecos-phir.workspace = true
2727
pecos-programs.workspace = true
28-
wasmtime = { workspace = true, optional = true }
28+
pecos-wasm = { workspace = true, optional = true }
2929
wat = { workspace = true, optional = true }
30-
parking_lot = { workspace = true, optional = true }
3130

3231
[dev-dependencies]
3332
# Testing
Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,7 @@
1-
use pecos_core::errors::PecosError;
2-
use std::any::Any;
3-
use std::fmt::Debug;
1+
// Re-export from pecos-wasm crate
2+
#[cfg(feature = "wasm")]
3+
pub use pecos_wasm::{DummyForeignObject, ForeignObject};
44

5-
/// Trait for foreign object implementations
6-
pub trait ForeignObject: Debug + Send + Sync {
7-
/// Clone the foreign object
8-
fn clone_box(&self) -> Box<dyn ForeignObject>;
9-
/// Initialize object before running a series of simulations
10-
///
11-
/// # Errors
12-
/// Returns an error if initialization fails.
13-
fn init(&mut self) -> Result<(), PecosError>;
14-
15-
/// Create new instance/internal state
16-
///
17-
/// # Errors
18-
/// Returns an error if instance creation fails.
19-
fn new_instance(&mut self) -> Result<(), PecosError>;
20-
21-
/// Get a list of function names available from the object
22-
fn get_funcs(&self) -> Vec<String>;
23-
24-
/// Execute a function given a list of arguments
25-
///
26-
/// # Errors
27-
/// Returns an error if the function does not exist or execution fails.
28-
fn exec(&mut self, func_name: &str, args: &[i64]) -> Result<Vec<i64>, PecosError>;
29-
30-
/// Cleanup resources
31-
fn teardown(&mut self) {}
32-
33-
/// Get as Any for downcasting
34-
fn as_any(&self) -> &dyn Any;
35-
36-
/// Get as Any for downcasting (mutable)
37-
fn as_any_mut(&mut self) -> &mut dyn Any;
38-
}
39-
40-
/// Dummy foreign object for when no foreign object is needed
41-
#[derive(Debug, Clone)]
42-
pub struct DummyForeignObject {}
43-
44-
impl DummyForeignObject {
45-
/// Create a new dummy foreign object
46-
#[must_use]
47-
pub fn new() -> Self {
48-
Self {}
49-
}
50-
}
51-
52-
impl Default for DummyForeignObject {
53-
fn default() -> Self {
54-
Self::new()
55-
}
56-
}
57-
58-
impl ForeignObject for DummyForeignObject {
59-
fn clone_box(&self) -> Box<dyn ForeignObject> {
60-
Box::new(Self::default())
61-
}
62-
63-
fn init(&mut self) -> Result<(), PecosError> {
64-
Ok(())
65-
}
66-
67-
fn new_instance(&mut self) -> Result<(), PecosError> {
68-
Ok(())
69-
}
70-
71-
fn get_funcs(&self) -> Vec<String> {
72-
vec![]
73-
}
74-
75-
fn exec(&mut self, func_name: &str, _args: &[i64]) -> Result<Vec<i64>, PecosError> {
76-
Err(PecosError::Input(format!(
77-
"Dummy foreign object cannot execute function: {func_name}"
78-
)))
79-
}
80-
81-
fn as_any(&self) -> &dyn Any {
82-
self
83-
}
84-
85-
fn as_any_mut(&mut self) -> &mut dyn Any {
86-
self
87-
}
88-
}
5+
// For when wasm feature is disabled, provide minimal trait
6+
#[cfg(not(feature = "wasm"))]
7+
pub use pecos_wasm::{DummyForeignObject, ForeignObject};

0 commit comments

Comments
 (0)