types: oops, we don't want the index at this point (MethodInfo)
authorBernhard Urban <lewurm@gmail.com>
Sun, 22 Apr 2012 23:14:45 +0000 (01:14 +0200)
committerBernhard Urban <lewurm@gmail.com>
Sun, 22 Apr 2012 23:14:45 +0000 (01:14 +0200)
it would be valid just for one certain class anyway... and we don't need it really

Mate.hs
Mate/MethodPool.hs
Mate/Types.hs
Mate/Utilities.hs

diff --git a/Mate.hs b/Mate.hs
index 05754bed7277a7242a159e9415710c10ab650f5e..35182cc866fa59a9ea582e3d36645b27695679f4 100644 (file)
--- a/Mate.hs
+++ b/Mate.hs
@@ -32,12 +32,11 @@ main = do
       case hmap of
         Just hmap' -> do
           let methods = classMethods cls; methods :: [Method Resolved]
-          let idx = findIndex (\x -> (methodName x) == "main") methods
-          case idx of
-            Just idx' -> do
-              let (Just m) = find (\x -> (methodName x) == "main") methods
+          let method = find (\x -> (methodName x) == "main") methods
+          case method of
+            Just m -> do
               let bclspath = B.pack $ map (fromIntegral . ord) (replace ".class" "" clspath)
-              entry <- compileBB hmap' (MethodInfo "main" bclspath (methodSignature m) (fromIntegral idx'))
+              entry <- compileBB hmap' (MethodInfo "main" bclspath (methodSignature m))
               printf "executing `main' now:\n"
               executeFuncPtr entry
             Nothing -> error "main not found"
index 762e787f609dc8b76bd675e0821aebbc755bc6fe..1a9d360678c46edc9c209ee7e3f31bf69b76497a 100644 (file)
@@ -12,7 +12,6 @@ import Foreign.Ptr
 import Foreign.C.Types
 import Foreign.StablePtr
 
-import JVM.ClassFile
 import JVM.Converter
 
 import Harpy
@@ -36,16 +35,13 @@ getMethodEntry signal_from ptr_mmap ptr_cmap = do
   cmap <- ptr2cmap ptr_cmap
 
   let w32_from = fromIntegral signal_from
-  let mi@(MethodInfo method cm _ cpidx) = cmap M.! w32_from
+  let mi@(MethodInfo method cm _) = cmap M.! w32_from
   -- TODO(bernhard): replace parsing with some kind of classpool
   cls <- parseClassFile $ toString $ cm `B.append` ".class"
   case M.lookup mi mmap of
     Nothing -> do
       printf "getMethodEntry(from 0x%08x): no method \"%s\" found. compile it\n" w32_from (show mi)
-      -- TODO(bernhard): maybe we have to load the class first?
-      --                 (Or better in X86CodeGen?)
-      let (CMethod _ nt) = (constsPool cls) M.! cpidx
-      hmap <- parseMethod cls (ntName nt)
+      hmap <- parseMethod cls method
       printMapBB hmap
       case hmap of
         Just hmap' -> do
index 95ae4e4b9167e10dc76c8e82ebf62ff2e177a15b..cf4bc7834a51c8c296ac58ccc4db77c175238b19 100644 (file)
@@ -35,12 +35,11 @@ type MMap = M.Map MethodInfo Word32
 data MethodInfo = MethodInfo {
   methName :: B.ByteString,
   cName :: B.ByteString,
-  mSignature :: MethodSignature,
-  cpIndex :: Word16 }
+  mSignature :: MethodSignature}
 
 instance Eq MethodInfo where
-  (MethodInfo m_a c_a s_a i_a) == (MethodInfo m_b c_b s_b i_b) =
-    (m_a == m_b) && (c_a == c_b) && (s_a == s_b) && (i_a == i_b)
+  (MethodInfo m_a c_a s_a) == (MethodInfo m_b c_b s_b) =
+    (m_a == m_b) && (c_a == c_b) && (s_a == s_b)
 
 -- TODO(bernhard): not really efficient. also, outsource that to hs-java
 instance Ord MethodSignature where
@@ -51,19 +50,17 @@ instance Ord MethodSignature where
     cmp_args = (show args_a) `compare` (show args_b)
 
 instance Ord MethodInfo where
-  compare (MethodInfo m_a c_a s_a i_a) (MethodInfo m_b c_b s_b i_b)
+  compare (MethodInfo m_a c_a s_a) (MethodInfo m_b c_b s_b)
     | cmp_m /= EQ = cmp_m
     | cmp_c /= EQ = cmp_c
-    | cmp_s /= EQ = cmp_s
-    | otherwise = i_a `compare` i_b
+    | otherwise = s_a `compare` s_b
     where
     cmp_m = m_a `compare` m_b
     cmp_c = c_a `compare` c_b
-    cmp_s = s_a `compare` s_b
 
 instance Show MethodInfo where
-  show (MethodInfo method c sig idx) =
-    (toString c) ++ "." ++ (toString method) ++ "." ++ (show sig) ++ "@" ++ (show idx)
+  show (MethodInfo method c sig) =
+    (toString c) ++ "." ++ (toString method) ++ "." ++ (show sig)
 
 
 toString :: B.ByteString -> String
index 7002d19a9708526094ec6e6b0f9295093a20df3a..54d32d30db2bf7fcd4d46a468ae0727c835f2dc8 100644 (file)
@@ -20,7 +20,7 @@ lookupMethod name cls = look (classMethods cls)
       | otherwise  = look fs
 
 buildMethodID :: Class Resolved -> Word16 -> MethodInfo
-buildMethodID cls idx = MethodInfo (ntName nt) rc (ntSignature nt) idx
+buildMethodID cls idx = MethodInfo (ntName nt) rc (ntSignature nt)
   where
   (CMethod rc nt) = (constsPool cls) M.! idx