ByteCodeGen: Generate machine-code sequences for foreign import
\begin{code}
-module ByteCodeFFI ( moan64, newExec ) where
+module ByteCodeFFI ( moan64 ) where
import Outputable
import System.IO
import Foreign
-import Foreign.C
moan64 :: String -> SDoc -> a
moan64 msg pp_rep
)
`seq`
pprPanic msg pp_rep
-
-newExec :: Storable a => [a] -> IO (FunPtr ())
-newExec code
- = alloca $ \pcode -> do
- ptr <- _allocateExec (fromIntegral $ codeSize undefined code) pcode
- pokeArray ptr code
- code <- peek pcode
- return (castPtrToFunPtr code)
- where
- codeSize :: Storable a => a -> [a] -> Int
- codeSize dummy array = sizeOf(dummy) * length array
-
-foreign import ccall unsafe "allocateExec"
- _allocateExec :: CUInt -> Ptr (Ptr a) -> IO (Ptr a)
\end{code}