Module name (#775)

This commit is contained in:
Yury Delendik
2020-01-09 10:02:33 -06:00
committed by GitHub
parent 61f9b8ade8
commit d651408b5a
8 changed files with 149 additions and 13 deletions

View File

@@ -117,6 +117,7 @@ impl Context {
instantiate(
&mut *self.compiler,
&data,
None,
&mut self.namespace,
Rc::clone(&self.global_exports),
debug_info,
@@ -154,6 +155,7 @@ impl Context {
CompiledModule::new(
&mut *self.compiler,
data,
None,
&mut self.namespace,
Rc::clone(&self.global_exports),
debug_info,

View File

@@ -60,12 +60,13 @@ impl<'data> RawCompiledModule<'data> {
fn new(
compiler: &mut Compiler,
data: &'data [u8],
module_name: Option<String>,
resolver: &mut dyn Resolver,
debug_info: bool,
) -> Result<Self, SetupError> {
let environ = ModuleEnvironment::new(compiler.frontend_config(), compiler.tunables());
let translation = environ
let mut translation = environ
.translate(data)
.map_err(|error| SetupError::Compile(CompileError::Wasm(error)))?;
@@ -75,6 +76,8 @@ impl<'data> RawCompiledModule<'data> {
None
};
translation.module.name = module_name;
let (allocated_functions, jt_offsets, relocations, dbg_image) = compiler.compile(
&translation.module,
translation.module_translation.as_ref().unwrap(),
@@ -152,11 +155,13 @@ impl CompiledModule {
pub fn new<'data>(
compiler: &mut Compiler,
data: &'data [u8],
module_name: Option<String>,
resolver: &mut dyn Resolver,
global_exports: Rc<RefCell<HashMap<String, Option<Export>>>>,
debug_info: bool,
) -> Result<Self, SetupError> {
let raw = RawCompiledModule::<'data>::new(compiler, data, resolver, debug_info)?;
let raw =
RawCompiledModule::<'data>::new(compiler, data, module_name, resolver, debug_info)?;
Ok(Self::from_parts(
raw.module,
@@ -258,11 +263,12 @@ impl OwnedDataInitializer {
pub fn instantiate(
compiler: &mut Compiler,
data: &[u8],
module_name: Option<String>,
resolver: &mut dyn Resolver,
global_exports: Rc<RefCell<HashMap<String, Option<Export>>>>,
debug_info: bool,
) -> Result<InstanceHandle, SetupError> {
let raw = RawCompiledModule::new(compiler, data, resolver, debug_info)?;
let raw = RawCompiledModule::new(compiler, data, module_name, resolver, debug_info)?;
InstanceHandle::new(
Rc::new(raw.module),