From 14b1554eedad2c726dd39b17564f6e05ba4e7b19 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sun, 20 May 2012 21:49:22 +0200 Subject: [PATCH] classpool: staticfields calculation: bugfix span doesn't do what I believed it does (it aborts on first predicate match) --- Mate/ClassPool.hs | 9 ++++++++- tests/Generics1.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Mate/ClassPool.hs b/Mate/ClassPool.hs index 816c73b..8b3e8a9 100644 --- a/Mate/ClassPool.hs +++ b/Mate/ClassPool.hs @@ -197,7 +197,14 @@ calculateFields :: Class Direct -> Maybe ClassInfo -> IO (FieldMap, FieldMap) calculateFields cf superclass = do -- TODO(bernhard): correct sizes. int only atm - let (sfields, ifields) = span (S.member ACC_STATIC . fieldAccessFlags) (classFields cf) + -- TODO(bernhard): nicer replacement for `myspan' + let (sfields, ifields) = myspan (S.member ACC_STATIC . fieldAccessFlags) (classFields cf) + myspan :: (a -> Bool) -> [a] -> ([a], [a]) + myspan _ [] = ([],[]) + myspan p (x:xs) + | p x = (x:ns, ni) + | otherwise = (ns, x:ni) + where (ns,ni) = myspan p xs staticbase <- mallocClassData $ fromIntegral (length sfields) * 4 let i_sb = fromIntegral $ ptrToIntPtr staticbase diff --git a/tests/Generics1.java b/tests/Generics1.java index 4e3d262..fa093ca 100644 --- a/tests/Generics1.java +++ b/tests/Generics1.java @@ -7,6 +7,7 @@ public class Generics1 implements Cmp { } public static Cmp sb = new Generics1(); + public static int lalelu = 0; public static void main(String []args) { Generics1 foo = new Generics1(); -- 2.25.1