mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Fix & refactor create_storage
This commit is contained in:
parent
32b9f4fb07
commit
47f93bddea
1 changed files with 23 additions and 18 deletions
|
@ -189,11 +189,14 @@ impl<'a> WasmBackend<'a> {
|
||||||
|
|
||||||
let storage = match wasm_layout {
|
let storage = match wasm_layout {
|
||||||
WasmLayout::Primitive(value_type, size) => match kind {
|
WasmLayout::Primitive(value_type, size) => match kind {
|
||||||
LocalKind::Parameter => SymbolStorage::Local {
|
LocalKind::Parameter => {
|
||||||
local_id: next_local_id,
|
self.arg_types.push(*value_type);
|
||||||
value_type: *value_type,
|
SymbolStorage::Local {
|
||||||
size: *size,
|
local_id: next_local_id,
|
||||||
},
|
value_type: *value_type,
|
||||||
|
size: *size,
|
||||||
|
}
|
||||||
|
}
|
||||||
LocalKind::Variable => SymbolStorage::VirtualMachineStack {
|
LocalKind::Variable => SymbolStorage::VirtualMachineStack {
|
||||||
vm_state: VirtualMachineSymbolState::NotYetPushed,
|
vm_state: VirtualMachineSymbolState::NotYetPushed,
|
||||||
value_type: *value_type,
|
value_type: *value_type,
|
||||||
|
@ -201,18 +204,27 @@ impl<'a> WasmBackend<'a> {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
WasmLayout::HeapMemory => SymbolStorage::Local {
|
WasmLayout::HeapMemory => {
|
||||||
local_id: next_local_id,
|
match kind {
|
||||||
value_type: PTR_TYPE,
|
LocalKind::Parameter => self.arg_types.push(PTR_TYPE),
|
||||||
size: PTR_SIZE,
|
LocalKind::Variable => self.locals.push(Local::new(1, PTR_TYPE)),
|
||||||
},
|
}
|
||||||
|
SymbolStorage::Local {
|
||||||
|
local_id: next_local_id,
|
||||||
|
value_type: PTR_TYPE,
|
||||||
|
size: PTR_SIZE,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WasmLayout::StackMemory {
|
WasmLayout::StackMemory {
|
||||||
size,
|
size,
|
||||||
alignment_bytes,
|
alignment_bytes,
|
||||||
} => {
|
} => {
|
||||||
let location = match kind {
|
let location = match kind {
|
||||||
LocalKind::Parameter => StackMemoryLocation::PointerArg(next_local_id),
|
LocalKind::Parameter => {
|
||||||
|
self.arg_types.push(PTR_TYPE);
|
||||||
|
StackMemoryLocation::PointerArg(next_local_id)
|
||||||
|
}
|
||||||
|
|
||||||
LocalKind::Variable => {
|
LocalKind::Variable => {
|
||||||
if self.stack_frame_pointer.is_none() {
|
if self.stack_frame_pointer.is_none() {
|
||||||
|
@ -237,13 +249,6 @@ impl<'a> WasmBackend<'a> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let value_type = wasm_layout.value_type();
|
|
||||||
match (kind, wasm_layout) {
|
|
||||||
(LocalKind::Parameter, _) => self.arg_types.push(value_type),
|
|
||||||
(LocalKind::Variable, WasmLayout::StackMemory { .. }) => (),
|
|
||||||
(LocalKind::Variable, _) => self.locals.push(Local::new(1, value_type)),
|
|
||||||
}
|
|
||||||
|
|
||||||
self.symbol_storage_map.insert(symbol, storage.clone());
|
self.symbol_storage_map.insert(symbol, storage.clone());
|
||||||
|
|
||||||
storage
|
storage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue