@@ -4,6 +4,7 @@ module Java.ClassFormat.Encoding where
44import Data.Char
55import Data.Word
66import Data.Maybe
7+ import Data.Tuple
78import Data.Monoid
89import Data.Prickler
910import qualified Data.Vector as V
@@ -75,43 +76,14 @@ attribute cpool = taggedSized con2 word32be (EliminatorWrapper . elim_Attribute)
7576 attr = fmap Con2 . flip M. lookup tagMap
7677
7778 tagMap :: M. Map BL. ByteString Word16
78- tagMap = M. fromList . mapMaybe (\ (i, x) -> fmap ( flip (,) i) (x ^? _Utf8)) . zip [1 .. ] . V. toList $ cpool
79+ tagMap = M. fromList . mapMaybe (_1 ( ^? _Utf8) $ ) . flip zip [1 .. ] . V. toList $ cpool
7980
8081-- attribute = undefined
8182
8283entity attribute = untagged elim_Entity . alt Entity $ word16be :> con2 :> con2 :> gvector word16be attribute :> Nil
8384codeAttribute attribute = untagged elim_CodeAttribute . alt CodeAttribute $ word16be :> word16be :> byteString word32be :> gvector word16be exception :> gvector word16be attribute :> Nil
8485
8586
86-
87-
88- {-
89- data Attribute
90- = ConstantValue Con2
91- | Code !CodeAttribute
92- | StackMapTable
93- | Exceptions !(V.Vector Con2)
94- | InnerClasses !(V.Vector InnerClass)
95- | EnclosingMethod !Con2 !Con2
96- | Synthetic -- empty
97- | Signature !Con2
98- | SourceFile !Con2
99- | SourceDebugExtension !B.ByteString
100- | LineNumberTable !(U.Vector (Word16, Word16))
101- | LocalVariableTable !(V.Vector LocalVariable)
102- | LocalVariableTypeTable !(V.Vector LocalVariable)
103- | Deprecated -- empty
104- | RuntimeVisibleAnnotations !(V.Vector Annotation)
105- | RuntimeInvisibleAnnotations !(V.Vector Annotation)
106- | RuntimeVisibleParameterAnnotations !(V.Vector (V.Vector Annotation))
107- | RuntimeInvisibleParameterAnnotations !(V.Vector (V.Vector Annotation))
108- | AnnotationDefault !Value
109- | BootstrapMethods
110- | Custom B.ByteString
111- -}
112-
113-
114-
11587referenceKind = tagged word8 (EliminatorWrapper . elim_ReferenceKind)
11688 $ 1 # alt Ref_getField Nil
11789 :> 2 # alt Ref_getStatic Nil
@@ -175,7 +147,7 @@ klass :: Prickler Class
175147klass = skip (expect 0xcafebabe word32be) basicClass
176148
177149test = do
178- x <- BL. readFile " /Users/copumpkin/Sandbox/Scala/tinker/target/scala-2.10/classes/tinker/optimized/Main$.class"
150+ x <- BL. readFile " /Users/copumpkin/Sandbox/Scala/tinker/target/scala-2.10/classes/tinker/optimized/Main$$anon$1 .class"
179151 putStrLn (ppShow $ runGet (get klass) x)
180152
181153
0 commit comments