mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 06:35:40 +00:00
Merge branch 'feature/wasi' of github.com:wasmerio/wasmer into feature/wasi
This commit is contained in:
commit
4df5f02444
@ -204,7 +204,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
|
|
||||||
// TODO: refactor this
|
// TODO: refactor this
|
||||||
#[cfg(not(feature = "wasi"))]
|
#[cfg(not(feature = "wasi"))]
|
||||||
let (_abi, import_object, _em_globals) = if wasmer_emscripten::is_emscripten_module(&module) {
|
let (abi, import_object, _em_globals) = if wasmer_emscripten::is_emscripten_module(&module) {
|
||||||
let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module);
|
let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module);
|
||||||
(
|
(
|
||||||
InstanceABI::Emscripten,
|
InstanceABI::Emscripten,
|
||||||
@ -220,7 +220,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "wasi")]
|
#[cfg(feature = "wasi")]
|
||||||
let (_abi, import_object) = if wasmer_wasi::is_wasi_module(&module) {
|
let (abi, import_object) = if wasmer_wasi::is_wasi_module(&module) {
|
||||||
(
|
(
|
||||||
InstanceABI::WASI,
|
InstanceABI::WASI,
|
||||||
wasmer_wasi::generate_import_object(
|
wasmer_wasi::generate_import_object(
|
||||||
@ -249,6 +249,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
webassembly::run_instance(
|
webassembly::run_instance(
|
||||||
&module,
|
&module,
|
||||||
&mut instance,
|
&mut instance,
|
||||||
|
abi,
|
||||||
options.path.to_str().unwrap(),
|
options.path.to_str().unwrap(),
|
||||||
options.args.iter().map(|arg| arg.as_str()).collect(),
|
options.args.iter().map(|arg| arg.as_str()).collect(),
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ use wasmer_runtime::{
|
|||||||
use wasmer_runtime_core::backend::CompilerConfig;
|
use wasmer_runtime_core::backend::CompilerConfig;
|
||||||
use wasmer_runtime_core::types::Value;
|
use wasmer_runtime_core::types::Value;
|
||||||
|
|
||||||
use wasmer_emscripten::{is_emscripten_module, run_emscripten_instance};
|
use wasmer_emscripten::run_emscripten_instance;
|
||||||
|
|
||||||
pub struct ResultObject {
|
pub struct ResultObject {
|
||||||
/// A webassembly::Module object representing the compiled WebAssembly module.
|
/// A webassembly::Module object representing the compiled WebAssembly module.
|
||||||
@ -93,18 +93,24 @@ pub fn compile_with_config(
|
|||||||
pub fn run_instance(
|
pub fn run_instance(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
instance: &mut Instance,
|
instance: &mut Instance,
|
||||||
|
abi: InstanceABI,
|
||||||
path: &str,
|
path: &str,
|
||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
) -> CallResult<()> {
|
) -> CallResult<()> {
|
||||||
if is_emscripten_module(module) {
|
match abi {
|
||||||
|
InstanceABI::Emscripten => {
|
||||||
run_emscripten_instance(module, instance, path, args)?;
|
run_emscripten_instance(module, instance, path, args)?;
|
||||||
} else {
|
}
|
||||||
|
InstanceABI::WASI => {
|
||||||
|
instance.call("_start", &[])?;
|
||||||
|
}
|
||||||
|
InstanceABI::None => {
|
||||||
let args: Vec<Value> = args
|
let args: Vec<Value> = args
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| Value::I32(x.parse().unwrap()))
|
.map(|x| Value::I32(x.parse().unwrap()))
|
||||||
.collect();
|
.collect();
|
||||||
instance.call("main", &args)?;
|
instance.call("main", &args)?;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user