Skip to content

Commit bebb108

Browse files
committed
A few minor changes
1 parent 34e095f commit bebb108

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Still very much a work in progress. The pickler stuff will eventually get split out into another library since very little of it is specific to java, but I'm keeping it in here until I'm more satisfied with it.
2+

src/Data/Prickler.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,19 @@ float = error "foo"
248248
double :: Prickler Double
249249
double = error "bar"
250250

251+
delimited :: Integral i => Prickler i -> Prickler a -> Prickler a
252+
delimited (Prickler gi pi) (Prickler ga pa) = Prickler getter putter
253+
where
254+
getter = do
255+
len <- gi
256+
bs <- getLazyByteString (fromIntegral len)
257+
return $ runGet ga bs
258+
259+
putter xs = undefined
260+
261+
all :: G.Vector v a => Prickler a -> Prickler (v a)
262+
all = undefined
263+
251264
byteString :: Integral i => Prickler i -> Prickler BL.ByteString
252265
byteString (Prickler gi pi) = Prickler getter putter
253266
where

src/Java/ClassFormat/Encoding.hs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Java.ClassFormat.Encoding where
44
import Data.Char
55
import Data.Word
66
import Data.Maybe
7+
import Data.Tuple
78
import Data.Monoid
89
import Data.Prickler
910
import 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

8283
entity attribute = untagged elim_Entity . alt Entity $ word16be :> con2 :> con2 :> gvector word16be attribute :> Nil
8384
codeAttribute 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-
11587
referenceKind = tagged word8 (EliminatorWrapper . elim_ReferenceKind)
11688
$ 1 # alt Ref_getField Nil
11789
:> 2 # alt Ref_getStatic Nil
@@ -175,7 +147,7 @@ klass :: Prickler Class
175147
klass = skip (expect 0xcafebabe word32be) basicClass
176148

177149
test = 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

Comments
 (0)