Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eggyal committed Sep 1, 2019
1 parent 0aa19af commit f7d1428
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ impl TryToTokens for ast::ImportFunction {
&self.rust_name,
);

let const_name = encode::lookup_constant_for_fn(&self.rust_name);
let const_name = encode::lookup_constant_for_fn(rust_name);
let id_bytes = gen_id();

let invocation = quote! {
Expand Down
8 changes: 7 additions & 1 deletion crates/backend/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ use crate::Diagnostic;

pub fn lookup_constant_for_fn(ident: &Ident) -> Ident {
Ident::new(
&format!("__WASM_BINDGEN_GENERATED_{}", ident.to_string().to_uppercase()),
&format!(
"__WASM_BINDGEN_GENERATED_{}",
ident
.to_string()
.trim_start_matches(&"r#")
.to_uppercase()
),
Span::call_site()
)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/backend/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ impl<T: Hash> fmt::Display for ShortHash<T> {
env::var("CARGO_PKG_VERSION")
.expect("should have CARGO_PKG_VERSION env var")
.hash(&mut h);

std::time::SystemTime::now().hash(&mut h);

// This may chop off 32 bits on 32-bit platforms, but that's ok, we
// just want something to mix in below anyway.
HASH.store(h.finish() as usize, SeqCst);
Expand Down
21 changes: 15 additions & 6 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,21 @@ impl<'a> Context<'a> {
}

self.expose_export_map();
self.expose_add_heap_object();
self.global(&format!(
"EXPORT_MAP[\"{}\"] = addHeapObject({});\n",
result.into_iter().collect::<String>(),
definition_name,
));
if self.config.anyref {
self.expose_add_to_anyref_table();
self.global(&format!(
"EXPORT_MAP[\"{}\"] = addToAnyrefTable({});\n",
result.into_iter().collect::<String>(),
definition_name,
));
} else {
self.expose_add_heap_object();
self.global(&format!(
"EXPORT_MAP[\"{}\"] = addHeapObject({});\n",
result.into_iter().collect::<String>(),
definition_name,
));
}
}
Ok(())
}
Expand Down

0 comments on commit f7d1428

Please sign in to comment.