Pops the value at the stack top and assigns it to the local at the given index, returning the typed register holding the source value.
(&mut self, index: u32)
| 538 | /// the given index, returning the typed register holding the |
| 539 | /// source value. |
| 540 | pub fn emit_set_local(&mut self, index: u32) -> Result<TypedReg> { |
| 541 | // Materialize any references to the same local index that are in the |
| 542 | // value stack by spilling. |
| 543 | if self.context.stack.contains_latent_local(index) { |
| 544 | self.context.spill(self.masm)?; |
| 545 | } |
| 546 | let src = self.context.pop_to_reg(self.masm, None)?; |
| 547 | // Need to get address of local after `pop_to_reg` since `pop_to_reg` |
| 548 | // will pop the machine stack causing an incorrect address to be |
| 549 | // calculated. |
| 550 | let (ty, addr) = self.context.frame.get_local_address(index, self.masm)?; |
| 551 | self.masm |
| 552 | .store(RegImm::reg(src.reg), addr, ty.try_into()?)?; |
| 553 | |
| 554 | Ok(src) |
| 555 | } |
| 556 | |
| 557 | /// Loads the address of the given global. |
| 558 | pub fn emit_get_global_addr(&mut self, index: GlobalIndex) -> Result<(WasmValType, Reg, u32)> { |
no test coverage detected