1 {-# LANGUAGE TypeFamilies, StandaloneDeriving, FlexibleInstances, FlexibleContexts, UndecidableInstances #-}
2 -- | This module declares `high-level' data types for Java classes, methods etc.
3 module JVM.Common where
5 import Codec.Binary.UTF8.String hiding (encode, decode)
8 import qualified Data.ByteString.Lazy as B
11 import qualified Data.Map as M
15 instance IsString B.ByteString where
16 fromString s = B.pack $ map (fromIntegral . ord) $ encodeString s
18 toCharList :: B.ByteString -> [Int]
19 toCharList bstr = map fromIntegral $ B.unpack bstr
21 poolSize :: Pool stage -> Int
24 (!) :: (Ord k) => M.Map k a -> k -> a
27 showListIx :: (Show a) => [a] -> String
28 showListIx list = unlines $ zipWith s [1..] list
29 where s i x = show i ++ ":\t" ++ show x
31 byteString :: (Binary t) => t -> B.ByteString
32 byteString x = runPut (put x)