Don't look up properties in import shims

This'll match more closely what wasm eventually does natively, which is
importing these functions directly and not allowing changing them over time.

Closes #25
This commit is contained in:
Alex Crichton
2018-02-14 12:51:58 -08:00
parent 20bcc83b96
commit be368a6570
2 changed files with 89 additions and 4 deletions

View File

@ -955,18 +955,24 @@ impl<'a, 'b> SubContext<'a, 'b> {
}
let invoc_args = invoc_args.join(", ");
let name = &import.function.name;
let function_name = &import.function.name;
let invoc = match import.class {
Some(ref class) if import.method => {
format!("{}.prototype.{}.call({})", class, name, invoc_args)
self.cx.globals.push_str(&format!("
const {}_target = {}.prototype.{};
", name, class, function_name));
format!("{}_target.call({})", name, invoc_args)
}
Some(ref class) if import.js_new => {
format!("new {}({})", class, invoc_args)
}
Some(ref class) => {
format!("{}.{}({})", class, name, invoc_args)
self.cx.globals.push_str(&format!("
const {}_target = {}.{};
", name, class, function_name));
format!("{}_target({})", name, invoc_args)
}
None => format!("{}({})", name, invoc_args),
None => format!("{}({})", function_name, invoc_args),
};
let invoc = match import.function.ret {
Some(shared::TYPE_NUMBER) => format!("return {};", invoc),