MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / command

Method command

crates/wasmtime/src/runtime/linker.rs:930–982  ·  view source on GitHub ↗
(
        &mut self,
        mut store: impl AsContextMut<Data = T>,
        module_name: &str,
        module: &Module,
        mk_func: impl Fn(&mut StoreContextMut<T>, &FuncType, String, InstancePr

Source from the content-addressed store, hash-verified

928 }
929
930 fn command(
931 &mut self,
932 mut store: impl AsContextMut<Data = T>,
933 module_name: &str,
934 module: &Module,
935 mk_func: impl Fn(&mut StoreContextMut<T>, &FuncType, String, InstancePre<T>) -> Func,
936 ) -> Result<&mut Self>
937 where
938 T: 'static,
939 {
940 let mut store = store.as_context_mut();
941 for export in module.exports() {
942 if let Some(func_ty) = export.ty().func() {
943 let instance_pre = self.instantiate_pre(module)?;
944 let export_name = export.name().to_owned();
945 let func = mk_func(&mut store, func_ty, export_name, instance_pre);
946 let key = self.import_key(module_name, Some(export.name()))?;
947 self.insert(key, Definition::new(store.0, func.into()))?;
948 } else if export.name() == "memory" && export.ty().memory().is_some() {
949 // Allow an exported "memory" memory for now.
950 } else if export.name() == "__indirect_function_table" && export.ty().table().is_some()
951 {
952 // Allow an exported "__indirect_function_table" table for now.
953 } else if export.name() == "table" && export.ty().table().is_some() {
954 // Allow an exported "table" table for now.
955 } else if export.name() == "__data_end" && export.ty().global().is_some() {
956 // Allow an exported "__data_end" memory for compatibility with toolchains
957 // which use --export-dynamic, which unfortunately doesn't work the way
958 // we want it to.
959 warn!("command module exporting '__data_end' is deprecated");
960 } else if export.name() == "__heap_base" && export.ty().global().is_some() {
961 // Allow an exported "__data_end" memory for compatibility with toolchains
962 // which use --export-dynamic, which unfortunately doesn't work the way
963 // we want it to.
964 warn!("command module exporting '__heap_base' is deprecated");
965 } else if export.name() == "__dso_handle" && export.ty().global().is_some() {
966 // Allow an exported "__dso_handle" memory for compatibility with toolchains
967 // which use --export-dynamic, which unfortunately doesn't work the way
968 // we want it to.
969 warn!("command module exporting '__dso_handle' is deprecated")
970 } else if export.name() == "__rtti_base" && export.ty().global().is_some() {
971 // Allow an exported "__rtti_base" memory for compatibility with
972 // AssemblyScript.
973 warn!(
974 "command module exporting '__rtti_base' is deprecated; pass `--runtime half` to the AssemblyScript compiler"
975 );
976 } else if !self.allow_unknown_exports {
977 bail!("command export '{}' is not a function", export.name());
978 }
979 }
980
981 Ok(self)
982 }
983
984 /// Aliases one item's name as another.
985 ///

Callers 2

moduleMethod · 0.80
module_asyncMethod · 0.80

Calls 14

OkFunction · 0.85
import_keyMethod · 0.80
globalMethod · 0.80
newFunction · 0.50
as_context_mutMethod · 0.45
exportsMethod · 0.45
funcMethod · 0.45
tyMethod · 0.45
instantiate_preMethod · 0.45
nameMethod · 0.45
insertMethod · 0.45
is_someMethod · 0.45

Tested by

no test coverage detected