parse memory instructions

This commit is contained in:
Ilya Rezvov
2023-08-21 21:11:39 -06:00
parent 2d4ad42549
commit 46f95dd11d
7 changed files with 73 additions and 30 deletions
+4 -4
View File
@@ -399,8 +399,8 @@ instance Serialize (Instruction Natural) where
put (I64Store8 memArg) = putWord8 0x3C >> put memArg
put (I64Store16 memArg) = putWord8 0x3D >> put memArg
put (I64Store32 memArg) = putWord8 0x3E >> put memArg
put CurrentMemory = putWord8 0x3F >> putWord8 0x00
put GrowMemory = putWord8 0x40 >> putWord8 0x00
put MemorySize = putWord8 0x3F >> putWord8 0x00
put MemoryGrow = putWord8 0x40 >> putWord8 0x00
-- Numeric instructions
put (I32Const val) = putWord8 0x41 >> putSLEB128 (asInt32 val)
put (I64Const val) = putWord8 0x42 >> putSLEB128 (asInt64 val)
@@ -600,8 +600,8 @@ instance Serialize (Instruction Natural) where
0x3C -> I64Store8 <$> get
0x3D -> I64Store16 <$> get
0x3E -> I64Store32 <$> get
0x3F -> byteGuard 0x00 >> (return $ CurrentMemory)
0x40 -> byteGuard 0x00 >> (return $ GrowMemory)
0x3F -> byteGuard 0x00 >> (return $ MemorySize)
0x40 -> byteGuard 0x00 >> (return $ MemoryGrow)
-- Numeric instructions
0x41 -> I32Const <$> getSLEB128 32
0x42 -> I64Const <$> getSLEB128 64