codegen: handle exceptions of a method
[mate.git] / Mate / ClassPool.hs
index 8b1cb4107c7f1c7216c30ef7327582ba21324c75..245b1a4d13aa0c22b8a81d1dd69b8638931cf64f 100644 (file)
@@ -150,16 +150,14 @@ readClass path = do
                   where val = fromIntegral (mmap M.! key) :: NativeWord
             printfCp $ printf "%s\n" header
             mapM_ printValue (M.keys mmap)
-      if mateDEBUG
-        then do
-          let strpath = toString path
-          hexDumpMap ("staticmap @ " ++ strpath) staticmap
-          hexDumpMap ("fieldmap @ " ++ strpath) fieldmap
-          hexDumpMap ("methodmap @ " ++ strpath) methodmap
-          hexDumpMap ("interfacemap @ " ++ strpath) immap
-          printfCp $ printf "mbase:   0x%08x\n" mbase
-          printfCp $ printf "iftable: 0x%08x\n" wn_iftable
-        else return ()
+      when mateDEBUG $ do
+        let strpath = toString path
+        hexDumpMap ("staticmap @ " ++ strpath) staticmap
+        hexDumpMap ("fieldmap @ " ++ strpath) fieldmap
+        hexDumpMap ("methodmap @ " ++ strpath) methodmap
+        hexDumpMap ("interfacemap @ " ++ strpath) immap
+        printfCp $ printf "mbase:   0x%08x\n" mbase
+        printfCp $ printf "iftable: 0x%08x\n" wn_iftable
       virtual_map <- getVirtualMap
       setVirtualMap $ M.insert mbase path virtual_map
 
@@ -277,10 +275,11 @@ loadAndInitClass path = do
     Just m -> do
       rawmethod <- parseMethod (ciFile ci) "<clinit>" $ MethodSignature [] ReturnsVoid
       let mi = MethodInfo "<clinit>" path (methodSignature m)
-      entry <- compileBB rawmethod mi
+      -- TODO(bernhard): test exception handling in static initalizer
+      entry <- compileBB mi rawmethod mi
       addMethodRef entry mi [path]
       printfCp $ printf "executing static initializer from %s now\n" (toString path)
-      executeFuncPtr entry
+      executeFuncPtr $ fst entry
       printfCp $ printf "static initializer from %s done\n" (toString path)
     Nothing -> return ()