+-}
+
+
+data MateCtx = MateCtx {
+ ctxMethodMap :: MethodMap,
+ ctxTrapMap :: TrapMap,
+ ctxClassMap :: ClassMap,
+ ctxVirtualMap :: VirtualMap,
+ ctxStringMap :: StringMap,
+ ctxInterfaceMap :: InterfaceMap,
+ ctxInterfaceMethodMap :: InterfaceMethodMap }
+
+emptyMateCtx :: MateCtx
+emptyMateCtx = MateCtx M.empty M.empty M.empty M.empty M.empty M.empty M.empty
+
+mateCtx :: IORef MateCtx
+{-# NOINLINE mateCtx #-}
+mateCtx = unsafePerformIO $ newIORef emptyMateCtx
+
+setMap :: (MateCtx -> MateCtx) -> IO ()
+setMap recordupdate = recordupdate <$> readIORef mateCtx >>= writeIORef mateCtx
+
+setMethodMap :: MethodMap -> IO ()
+setMethodMap m = setMap (\x -> x {ctxMethodMap = m})
+
+getMethodMap :: IO MethodMap
+getMethodMap = ctxMethodMap <$> readIORef mateCtx
+
+setTrapMap :: TrapMap -> IO ()
+setTrapMap m = setMap (\x -> x {ctxTrapMap = m})
+
+getTrapMap :: IO TrapMap
+getTrapMap = ctxTrapMap <$> readIORef mateCtx
+
+setClassMap :: ClassMap -> IO ()
+setClassMap m = setMap (\x -> x {ctxClassMap = m})
+
+getClassMap :: IO ClassMap
+getClassMap = ctxClassMap <$> readIORef mateCtx
+
+setVirtualMap :: VirtualMap -> IO ()
+setVirtualMap m = setMap (\x -> x {ctxVirtualMap = m})
+
+getVirtualMap :: IO VirtualMap
+getVirtualMap = ctxVirtualMap <$> readIORef mateCtx
+
+setStringMap :: StringMap -> IO ()
+setStringMap m = setMap (\x -> x {ctxStringMap = m})
+
+getStringMap :: IO StringMap
+getStringMap = ctxStringMap <$> readIORef mateCtx
+
+setInterfaceMap :: InterfaceMap -> IO ()
+setInterfaceMap m = setMap (\x -> x {ctxInterfaceMap = m})
+
+getInterfaceMap :: IO InterfaceMap
+getInterfaceMap = ctxInterfaceMap <$> readIORef mateCtx
+
+setInterfaceMethodMap :: InterfaceMethodMap -> IO ()
+setInterfaceMethodMap m = setMap (\x -> x {ctxInterfaceMethodMap = m})
+
+getInterfaceMethodMap :: IO InterfaceMethodMap
+getInterfaceMethodMap = ctxInterfaceMethodMap <$> readIORef mateCtx