Skip to content

Commit

Permalink
Use standard memory name for the export
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Jun 11, 2021
1 parent e8bf537 commit 0882e6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,13 +1754,13 @@ impl<'a> Context<'a> {
let add = self.expose_add_to_externref_table(table, alloc)?;
self.global(&format!(
"\
function handleError(f, args) {{
function handleError(f, args) {{
try {{
return f.apply(this, args);
}} catch (e) {{
const idx = {}(e);
wasm.{}(idx);
}}
}}
}}
",
add, store,
Expand Down Expand Up @@ -1791,7 +1791,7 @@ impl<'a> Context<'a> {
}
self.global(
"\
function logError(f, args) {
function logError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
Expand Down Expand Up @@ -3306,6 +3306,9 @@ impl<'a> Context<'a> {
let default_name = format!("__wbindgen_export_{}", self.next_export_idx);
self.next_export_idx += 1;
let name = match id {
walrus::ExportItem::Memory(_) if self.module.memories.iter().count() == 1 => {
"memory".to_owned()
}
walrus::ExportItem::Function(f) => match &self.module.funcs.get(f).name {
Some(s) => to_js_identifier(s),
None => default_name,
Expand Down

0 comments on commit 0882e6c

Please sign in to comment.