CodeException (..),
Code (..),
IMM (..),
- CMP (..)
+ CMP (..),
+ encodeInstructions,
+ encodeMethod,
+ decodeMethod
)
where
| inRange (153, 158) c -> return $ IF (toEnum $ fromIntegral $ c-153)
| inRange (159, 164) c -> IF_ICMP (toEnum $ fromIntegral $ c-159) <$> get
| otherwise -> fail $ "Unknown instruction byte code: " ++ show c
+
+encodeInstructions :: [Instruction] -> B.ByteString
+encodeInstructions code =
+ let p list = forM_ list put
+ in encodeWith p (0 :: Integer) code
+-- | Decode Java method
+decodeMethod :: B.ByteString -> Code
+decodeMethod str = decodeS (0 :: Integer) str
+
+-- | Encode Java method
+encodeMethod :: Code -> B.ByteString
+encodeMethod code = encodeS (0 :: Integer) code
+