validate and interprete bulk memory instructions

This commit is contained in:
Ilya Rezvov
2022-06-12 21:12:19 -06:00
parent 2bf6e88072
commit 5256d5063f
5 changed files with 72 additions and 5 deletions
+2 -1
View File
@@ -906,10 +906,11 @@ memory_limits_export_import1 :: { Maybe Ident -> [ModuleField] }
| 'data' datastring ')' ')' {
\ident ->
let m = fromIntegral $ LBS.length $2 in
let lim = if m `mod` 0x10000 == 0 then m `div` 0x10000 else m `div` 0x10000 + 1 in
-- TODO: unhardcode memory index
let memIdx = fromMaybe (Index 0) $ Named `fmap` ident in
[
MFMem $ Memory [] ident $ Limit m $ Just m,
MFMem $ Memory [] ident $ Limit lim $ Just lim,
MFData $ DataSegment Nothing (ActiveData memIdx [PlainInstr $ I32Const 0]) $2
]
}