From 74451aa848d88d1175e52f5c4dd7234cb84fa7f8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 19 May 2024 14:08:38 +0900 Subject: fix: fNN.reinterpret_iMM --- src/Execution/Runtime.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/Execution') diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 8944ff1..ae76b06 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -695,13 +695,19 @@ final class Runtime private function execInstrNumericF32ReinterpretI32(Instrs\Numeric\F32ReinterpretI32 $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue($v); + $result = unpack('f', pack('l', $v)); + assert($result !== false); + $vAsF32 = $result[1]; + $this->stack->pushValue($vAsF32); } private function execInstrNumericF32ReinterpretI64(Instrs\Numeric\F32ReinterpretI64 $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue($v); + $result = unpack('f', pack('q', $v)); + assert($result !== false); + $vAsF32 = $result[1]; + $this->stack->pushValue($vAsF32); } private function execInstrNumericF32Sqrt(Instrs\Numeric\F32Sqrt $instr): void @@ -875,13 +881,19 @@ final class Runtime private function execInstrNumericF64ReinterpretI32(Instrs\Numeric\F64ReinterpretI32 $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue($v); + $result = unpack('d', pack('l', $v)); + assert($result !== false); + $vAsF64 = $result[1]; + $this->stack->pushValue($vAsF64); } private function execInstrNumericF64ReinterpretI64(Instrs\Numeric\F64ReinterpretI64 $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue($v); + $result = unpack('d', pack('q', $v)); + assert($result !== false); + $vAsF64 = $result[1]; + $this->stack->pushValue($vAsF64); } private function execInstrNumericF64Sqrt(Instrs\Numeric\F64Sqrt $instr): void -- cgit v1.2.3-70-g09d2