mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Rename a variable & fix a bug calling functions that return via stack memory
This commit is contained in:
parent
1b97675f1f
commit
f242aade86
1 changed files with 23 additions and 7 deletions
|
@ -399,19 +399,35 @@ impl<'a> WasmBackend<'a> {
|
||||||
arguments,
|
arguments,
|
||||||
}) => match call_type {
|
}) => match call_type {
|
||||||
CallType::ByName { name: func_sym, .. } => {
|
CallType::ByName { name: func_sym, .. } => {
|
||||||
|
// TODO: See if we can make this more efficient
|
||||||
|
// Recreating the same WasmLayout again, rather than passing it down,
|
||||||
|
// to match signature of Backend::build_expr
|
||||||
|
let wasm_layout = WasmLayout::new(layout);
|
||||||
|
|
||||||
|
let mut wasm_args_tmp: Vec<Symbol>;
|
||||||
|
let (wasm_args, has_return_val) = match wasm_layout {
|
||||||
|
WasmLayout::StackMemory { .. } => {
|
||||||
|
wasm_args_tmp = Vec::with_capacity(arguments.len() + 1); // TODO: bumpalo
|
||||||
|
wasm_args_tmp.push(*sym);
|
||||||
|
wasm_args_tmp.extend_from_slice(*arguments);
|
||||||
|
(wasm_args_tmp.as_slice(), false)
|
||||||
|
}
|
||||||
|
_ => (*arguments, true),
|
||||||
|
};
|
||||||
|
|
||||||
self.storage
|
self.storage
|
||||||
.load_symbols(&mut self.code_builder, *arguments);
|
.load_symbols(&mut self.code_builder, wasm_args);
|
||||||
|
|
||||||
let function_location = self.proc_symbol_map.get(func_sym).ok_or(format!(
|
let function_location = self.proc_symbol_map.get(func_sym).ok_or(format!(
|
||||||
"Cannot find function {:?} called from {:?}",
|
"Cannot find function {:?} called from {:?}",
|
||||||
func_sym, sym
|
func_sym, sym
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
// TODO: Recreating the same WasmLayout as in the Let, for Backend compatibility
|
self.code_builder.add_call(
|
||||||
let wasm_layout = WasmLayout::new(layout);
|
function_location.body,
|
||||||
let push = wasm_layout.stack_memory() == 0;
|
wasm_args.len(),
|
||||||
let pops = arguments.len();
|
has_return_val,
|
||||||
self.code_builder
|
);
|
||||||
.add_call(function_location.body, pops, push);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue