javaclass (empty) → 0.0.1
raw patch · 24 files changed
+3147/−0 lines, 24 filesdep +QuickCheckdep +basedep +bytestringbuild-type:Customsetup-changed
Dependencies added: QuickCheck, base, bytestring, directory, doctest, filepath, greplicate, lens, semigroupoids, semigroups, tagged, template-haskell, tickle
Files
- LICENSE +27/−0
- Setup.lhs +44/−0
- changelog +4/−0
- javaclass.cabal +95/−0
- src/Language/Java/Class.hs +28/−0
- src/Language/Java/Class/Attribute.hs +109/−0
- src/Language/Java/Class/Attributes.hs +102/−0
- src/Language/Java/Class/Cafebabe.hs +70/−0
- src/Language/Java/Class/ClassFile.hs +501/−0
- src/Language/Java/Class/ConstantPool.hs +230/−0
- src/Language/Java/Class/ConstantPoolInfo.hs +764/−0
- src/Language/Java/Class/Field.hs +207/−0
- src/Language/Java/Class/FieldAccessFlags.hs +58/−0
- src/Language/Java/Class/Fields.hs +130/−0
- src/Language/Java/Class/Interfaces.hs +85/−0
- src/Language/Java/Class/Method.hs +211/−0
- src/Language/Java/Class/MethodAccessFlags.hs +58/−0
- src/Language/Java/Class/Methods.hs +136/−0
- src/Language/Java/Class/SuperClass.hs +57/−0
- src/Language/Java/Class/ThisAccessFlags.hs +57/−0
- src/Language/Java/Class/ThisClass.hs +57/−0
- src/Language/Java/Class/Version.hs +84/−0
- test/doctests.hs +32/−0
- todo.md +1/−0
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright 2016 NICTA Pty Ltd+All rights reserved.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+list of conditions, the following disclaimer and the following SHA-512 checksum.++2. Redistributions in binary form must reproduce the above copyright notice,+this list of conditions, the following disclaimer and the following SHA-512+checksum in the documentation and/or other materials provided with the+distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.++THIS SOFTWARE IS PROVIDED WITH A SHA-512 CHECKSUM.+ecdfdf543fd166b13b76b11e0b010e00d693028771880ffd8f9252ae0b8ac42bddf8eb7a23c21c86a3b50039d642ad9eeb7e8a0e82f6a345f60feb4a54808362
+ Setup.lhs view
@@ -0,0 +1,44 @@+#!/usr/bin/env runhaskell+\begin{code}+{-# OPTIONS_GHC -Wall #-}+module Main (main) where++import Data.List ( nub )+import Data.Version ( showVersion )+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )+import Distribution.Simple.BuildPaths ( autogenModulesDir )+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )+import Distribution.Verbosity ( Verbosity )+import System.FilePath ( (</>) )++main :: IO ()+main = defaultMainWithHooks simpleUserHooks+ { buildHook = \pkg lbi hooks flags -> do+ generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi+ buildHook simpleUserHooks pkg lbi hooks flags+ }++generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()+generateBuildModule verbosity pkg lbi = do+ let dir = autogenModulesDir lbi+ createDirectoryIfMissingVerbose verbosity True dir+ withLibLBI pkg lbi $ \_ libcfg -> do+ withTestLBI pkg lbi $ \suite suitecfg -> do+ rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines+ [ "module Build_" ++ testName suite ++ " where"+ , "deps :: [String]"+ , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))+ ]+ where+ formatdeps = map (formatone . snd)+ formatone p = case packageName p of+ PackageName n -> n ++ "-" ++ showVersion (packageVersion p)++testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys++\end{code}
+ changelog view
@@ -0,0 +1,4 @@+0.0.1++* Initial release+
+ javaclass.cabal view
@@ -0,0 +1,95 @@+name: javaclass+version: 0.0.1+license: OtherLicense+license-file: LICENSE+author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>+maintainer: Tony Morris+copyright: Copyright (C) 2016 NICTA Limited+synopsis: Java class files+category: Data+description:+ <<http://i.imgur.com/Ns5hntl.jpg>>+ .+ Java class files+ https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html+homepage: https://github.com/NICTA/javaclass+bug-reports: https://github.com/NICTA/javaclass/issues+cabal-version: >= 1.10+build-type: Custom+extra-source-files: changelog, todo.md++source-repository head+ type: git+ location: git@github.com:NICTA/javaclass.git++flag small_base+ description: Choose the new, split-up base package.++library+ default-language:+ Haskell2010++ build-depends:+ base < 5 && >= 4.8+ , semigroups >= 0.8 && < 1.0+ , semigroupoids >= 4.2 && < 6+ , lens >= 4.3.3 && < 5+ , bytestring >= 0.10 && < 0.11+ , tickle >= 0.0.6 && < 0.1+ , tagged >= 0.8 && < 0.9+ , greplicate >= 0.0.2 && < 0.1+ + ghc-options:+ -Wall++ default-extensions:+ + NoImplicitPrelude++ hs-source-dirs:+ src++ exposed-modules:+ Language.Java.Class+ Language.Java.Class.Attribute+ Language.Java.Class.Attributes+ Language.Java.Class.Cafebabe+ Language.Java.Class.ClassFile+ Language.Java.Class.ConstantPool+ Language.Java.Class.ConstantPoolInfo+ Language.Java.Class.FieldAccessFlags+ Language.Java.Class.Field+ Language.Java.Class.Fields+ Language.Java.Class.Interfaces+ Language.Java.Class.MethodAccessFlags+ Language.Java.Class.Method+ Language.Java.Class.Methods+ Language.Java.Class.SuperClass+ Language.Java.Class.ThisAccessFlags+ Language.Java.Class.ThisClass+ Language.Java.Class.Version++test-suite doctests+ type:+ exitcode-stdio-1.0++ main-is:+ doctests.hs++ default-language:+ Haskell2010++ build-depends:+ base < 5 && >= 3+ , doctest >= 0.9.7+ , filepath >= 1.3+ , directory >= 1.1+ , QuickCheck >= 2.0+ , template-haskell >= 2.8++ ghc-options:+ -Wall+ -threaded++ hs-source-dirs:+ test
+ src/Language/Java/Class.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}++module Language.Java.Class(+ module C+) where++import Language.Java.Class.Attribute as C+import Language.Java.Class.Attributes as C+import Language.Java.Class.Cafebabe as C+import Language.Java.Class.ClassFile as C+import Language.Java.Class.ConstantPool as C+import Language.Java.Class.ConstantPoolInfo as C+import Language.Java.Class.FieldAccessFlags as C+import Language.Java.Class.Field as C+import Language.Java.Class.Fields as C+import Language.Java.Class.Interfaces as C+import Language.Java.Class.MethodAccessFlags as C+import Language.Java.Class.Method as C+import Language.Java.Class.Methods as C+import Language.Java.Class.SuperClass as C+import Language.Java.Class.ThisAccessFlags as C+import Language.Java.Class.ThisClass as C+import Language.Java.Class.Version as C+
+ src/Language/Java/Class/Attribute.hs view
@@ -0,0 +1,109 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Attribute(+ Attribute(..)+, AttributeError(..)+, AsAttributeNameIndexUnexpectedEof(..)+, attributeNameIndexUnexpectedEof+, AsAttributeLengthUnexpectedEof(..)+, attributeLengthUnexpectedEof+, AsAttributeUnexpectedEof(..)+, attribute+) where++import Control.Applicative(Applicative)+import Control.Lens(AsEmpty, Cons, Optic', Choice, prism', ( # ))+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!-), word32be, word16be, word8)+import Data.Word(Word8, Word16, Word32)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7 4.7. Attributes>+data Attribute a =+ Attribute+ Word16 -- attribute_name_index+ Word32 -- attribute_length+ (a Word8)++deriving instance Eq (a Word8) => Eq (Attribute a)+deriving instance Ord (a Word8) => Ord (Attribute a)+deriving instance Show (a Word8) => Show (Attribute a)++data AttributeError =+ AttributeNameIndexUnexpectedEof+ | AttributeLengthUnexpectedEof+ | AttributeUnexpectedEof Word32+ deriving (Eq, Ord, Show)++class AsAttributeNameIndexUnexpectedEof p f s where+ _AttributeNameIndexUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsAttributeNameIndexUnexpectedEof p f AttributeError where+ _AttributeNameIndexUnexpectedEof =+ prism'+ (\() -> AttributeNameIndexUnexpectedEof)+ (\e -> case e of+ AttributeNameIndexUnexpectedEof -> Just ()+ _ -> Nothing)+ +attributeNameIndexUnexpectedEof ::+ AsAttributeNameIndexUnexpectedEof Tagged Identity t =>+ t+attributeNameIndexUnexpectedEof =+ _AttributeNameIndexUnexpectedEof # ()++class AsAttributeLengthUnexpectedEof p f s where+ _AttributeLengthUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsAttributeLengthUnexpectedEof p f AttributeError where+ _AttributeLengthUnexpectedEof =+ prism'+ (\() -> AttributeLengthUnexpectedEof)+ (\e -> case e of+ AttributeLengthUnexpectedEof -> Just ()+ _ -> Nothing)+ +attributeLengthUnexpectedEof ::+ AsAttributeLengthUnexpectedEof Tagged Identity t =>+ t+attributeLengthUnexpectedEof =+ _AttributeLengthUnexpectedEof # ()++class AsAttributeUnexpectedEof p f s where+ _AttributeUnexpectedEof :: + Optic' p f s Word32++instance (Choice p, Applicative f) => AsAttributeUnexpectedEof p f AttributeError where+ _AttributeUnexpectedEof =+ prism'+ AttributeUnexpectedEof+ (\e -> case e of+ AttributeUnexpectedEof w -> Just w+ _ -> Nothing)+ +attribute ::+ (AsEmpty (a Word8), Cons (a Word8) (a Word8) Word8 Word8,+ AsAttributeNameIndexUnexpectedEof Tagged Identity e,+ AsAttributeLengthUnexpectedEof Tagged Identity e,+ AsAttributeUnexpectedEof Tagged Identity e) =>+ Get e (Attribute a)+attribute =+ do n <- attributeNameIndexUnexpectedEof !- word16be+ l <- attributeLengthUnexpectedEof !- word32be+ a <- replicateO (\x -> _AttributeUnexpectedEof # x !- word8) l+ return (Attribute n l a)
+ src/Language/Java/Class/Attributes.hs view
@@ -0,0 +1,102 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Attributes(+ Attributes(..)+, AttributesError(..)+, AsAttributesInfoUnexpectedEof(..)+, attributesInfoUnexpectedEof+, AsAttributesAttributeError(..)+, attributes+) where++import Control.Applicative(Applicative)+import Control.Category((.))+import Control.Lens+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, word16be, (!!-), (!-))+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute, AttributeError, attribute)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+data Attributes a s =+ Attributes+ Word16+ (s (Attribute a))++deriving instance Eq (s (Attribute a)) => Eq (Attributes a s)+deriving instance Ord (s (Attribute a)) => Ord (Attributes a s)+deriving instance Show (s (Attribute a)) => Show (Attributes a s)++data AttributesError =+ AttributesInfoUnexpectedEof+ | AttributesAttributeError Word16 AttributeError+ deriving (Eq, Ord, Show)++class AsAttributesInfoUnexpectedEof p f s where+ _AttributesInfoUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsAttributesInfoUnexpectedEof p f AttributesError where+ _AttributesInfoUnexpectedEof =+ prism'+ (\() -> AttributesInfoUnexpectedEof)+ (\e -> case e of+ AttributesInfoUnexpectedEof -> Just ()+ _ -> Nothing)++attributesInfoUnexpectedEof ::+ AsAttributesInfoUnexpectedEof Tagged Identity t =>+ t+attributesInfoUnexpectedEof=+ _AttributesInfoUnexpectedEof # ()++class AsAttributesAttributeError p f s where+ _AttributesAttributeError :: + Optic' p f s (Word16, AttributeError)++instance (Choice p, Applicative f) => AsAttributesAttributeError p f AttributesError where+ _AttributesAttributeError =+ prism'+ (\(w, r) -> AttributesAttributeError w r)+ (\e -> case e of+ AttributesAttributeError w r -> Just (w, r)+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f AttributesError where+ _AttributeNameIndexUnexpectedEof =+ _AttributesAttributeError . _2 . _AttributeNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f AttributesError where+ _AttributeLengthUnexpectedEof =+ _AttributesAttributeError . _2 . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f AttributesError where+ _AttributeUnexpectedEof =+ _AttributesAttributeError . _2 . _AttributeUnexpectedEof++attributes ::+ (AsEmpty (a Word8), AsEmpty (s (Attribute a1)),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons+ (s (Attribute a1)) (s (Attribute a1)) (Attribute a) (Attribute a),+ AsAttributesInfoUnexpectedEof Tagged Identity e,+ AsAttributesAttributeError Tagged Identity e) =>+ Get e (Attributes a1 s)+attributes =+ do c <- attributesInfoUnexpectedEof !- word16be+ i <- (_AttributesAttributeError #) !!- replicateO (\n -> ((,) n) !!- attribute) c+ return (Attributes c i)
+ src/Language/Java/Class/Cafebabe.hs view
@@ -0,0 +1,70 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.Cafebabe(+ CafebabeError(..)+, AsCafebabeUnexpectedEof(..)+, cafebabeUnexpectedEof+, AsCafebabeInvalidMagicNumber(..)+, cafebabe+) where++import Control.Applicative(Applicative)+import Control.Lens(Optic', Choice, prism', ( # ))+import Control.Monad(return)+import Data.Eq(Eq((==)))+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Nothing, Just))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!-), word32be, failGet)+import Data.Word(Word32)+import Prelude(Show)++data CafebabeError =+ CafebabeUnexpectedEof+ | CafebabeInvalidMagicNumber Word32+ deriving (Eq, Ord, Show)++class AsCafebabeUnexpectedEof p f s where+ _CafebabeUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsCafebabeUnexpectedEof p f CafebabeError where+ _CafebabeUnexpectedEof =+ prism'+ (\() -> CafebabeUnexpectedEof)+ (\e -> case e of+ CafebabeUnexpectedEof -> Just ()+ CafebabeInvalidMagicNumber _ -> Nothing)++cafebabeUnexpectedEof ::+ AsCafebabeUnexpectedEof Tagged Identity t =>+ t+cafebabeUnexpectedEof =+ _CafebabeUnexpectedEof # ()++class AsCafebabeInvalidMagicNumber p f s where+ _CafebabeInvalidMagicNumber :: + Optic' p f s Word32++instance (Choice p, Applicative f) => AsCafebabeInvalidMagicNumber p f CafebabeError where+ _CafebabeInvalidMagicNumber =+ prism'+ CafebabeInvalidMagicNumber+ (\e -> case e of+ CafebabeUnexpectedEof -> Nothing+ CafebabeInvalidMagicNumber w -> Just w)+ +cafebabe ::+ (AsCafebabeUnexpectedEof Tagged Identity e, AsCafebabeInvalidMagicNumber Tagged Identity e) =>+ Get e ()+cafebabe =+ do c <- cafebabeUnexpectedEof !- word32be + if c == 0xCAFEBABE+ then+ return ()+ else+ failGet (_CafebabeInvalidMagicNumber # c)
+ src/Language/Java/Class/ClassFile.hs view
@@ -0,0 +1,501 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE KindSignatures #-}++module Language.Java.Class.ClassFile(+ ClassFile(..)+, ClassFile'+, ClassFileError(..)+, AsClassFileCafebabeError(..)+, AsClassFileVersionError(..)+, AsClassFileConstantPoolError(..)+, AsClassFileThisAccessFlagsError(..)+, AsClassFileThisClassError(..)+, AsClassFileSuperClassError(..)+, AsClassFileInterfacesError(..)+, AsClassFileFieldsError(..)+, AsClassFileMethodsError(..)+, AsClassFileAttributesError(..)+, AsClassFileUnexpectedInputOnStream(..)+, classFileUnexpectedInputOnStream+, classFile+) where++import Control.Applicative+import Control.Category((.))+import Control.Lens(AsEmpty, Cons, Choice, Optic', prism', ( # ))+import Control.Monad(return)+import Data.Char(Char)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Nothing, Just))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, isEmpty, failGet, (!!-))+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute)+import Language.Java.Class.Attributes(AsAttributesInfoUnexpectedEof(_AttributesInfoUnexpectedEof), AsAttributesAttributeError(_AttributesAttributeError), Attributes, AttributesError, attributes)+import Language.Java.Class.Method(AsMethodNameIndexUnexpectedEof(_MethodNameIndexUnexpectedEof), AsMethodDescriptorIndexUnexpectedEof(_MethodDescriptorIndexUnexpectedEof), AsMethodAttributeCountUnexpectedEof(_MethodAttributeCountUnexpectedEof), AsMethodAttributeUnexpectedEof(_MethodAttributeUnexpectedEof), AsMethodMethodAccessFlagsError(_MethodMethodAccessFlagsError), AsMethodErrorAttributeError(_MethodErrorAttributeError), Method)+import Language.Java.Class.Methods(AsMethodsInfoUnexpectedEof(_MethodsInfoUnexpectedEof), AsMethodsMethodError(_MethodsMethodError), Methods, MethodsError, methods)+import Language.Java.Class.Field(AsFieldFieldAccessFlagsError(_FieldFieldAccessFlagsError), AsFieldNameIndexUnexpectedEof(_FieldNameIndexUnexpectedEof), AsFieldDescriptorIndexUnexpectedEof(_FieldDescriptorIndexUnexpectedEof), AsFieldAttributeCountUnexpectedEof(_FieldAttributeCountUnexpectedEof), AsFieldAttributeError(_FieldAttributeError), AsFieldErrorAttributeError(_FieldErrorAttributeError), Field)+import Language.Java.Class.Fields(AsFieldsFieldInfoUnexpectedEof(_FieldsFieldInfoUnexpectedEof), AsFieldsFieldError(_FieldsFieldError), Fields, FieldsError, fields)+import Language.Java.Class.Interfaces(AsInterfacesCountUnexpectedEof(_InterfacesCountUnexpectedEof), AsInterfacesUnexpectedEof(_InterfacesUnexpectedEof), Interfaces, InterfacesError, interfaces)+import Language.Java.Class.SuperClass(AsSuperClassUnexpectedEof(_SuperClassUnexpectedEof), SuperClass, SuperClassError, superClass)+import Language.Java.Class.ThisClass(AsThisClassUnexpectedEof(_ThisClassUnexpectedEof), ThisClass, ThisClassError, thisClass)+import Language.Java.Class.ThisAccessFlags(AsThisAccessFlagsUnexpectedEof(_ThisAccessFlagsUnexpectedEof), ThisAccessFlags, ThisAccessFlagsError, thisAccessFlags)+import Language.Java.Class.ConstantPoolInfo(AsConstantPoolInfoTagUnexpectedEof(_ConstantPoolInfoTagUnexpectedEof), AsConstantPoolInfoUtf8LengthUnexpectedEof(_ConstantPoolInfoUtf8LengthUnexpectedEof), AsConstantPoolInfoUtf8UnexpectedEof(_ConstantPoolInfoUtf8UnexpectedEof), AsConstantPoolInvalidJavaString(_ConstantPoolInvalidJavaString), AsConstantPoolInfoConstantIntegerUnexpectedEof(_ConstantPoolInfoConstantIntegerUnexpectedEof), AsConstantPoolInfoConstantFloatUnexpectedEof(_ConstantPoolInfoConstantFloatUnexpectedEof), AsConstantPoolInfoConstantLongUnexpectedEof(_ConstantPoolInfoConstantLongUnexpectedEof), AsConstantPoolInfoConstantDoubleUnexpectedEof(_ConstantPoolInfoConstantDoubleUnexpectedEof), AsConstantPoolInfoConstantClassUnexpectedEof(_ConstantPoolInfoConstantClassUnexpectedEof), AsConstantPoolInfoConstantStringUnexpectedEof(_ConstantPoolInfoConstantStringUnexpectedEof), AsConstantPoolInfoFieldRef1UnexpectedEof(_ConstantPoolInfoFieldRef1UnexpectedEof), AsConstantPoolInfoFieldRef2UnexpectedEof(_ConstantPoolInfoFieldRef2UnexpectedEof), AsConstantPoolInfoMethodRef1UnexpectedEof(_ConstantPoolInfoMethodRef1UnexpectedEof), AsConstantPoolInfoMethodRef2UnexpectedEof(_ConstantPoolInfoMethodRef2UnexpectedEof), AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof(_ConstantPoolInfoInterfaceMethodRef1UnexpectedEof), AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof(_ConstantPoolInfoInterfaceMethodRef2UnexpectedEof), AsConstantPoolInfoNameAndType1UnexpectedEof(_ConstantPoolInfoNameAndType1UnexpectedEof), AsConstantPoolInfoNameAndType2UnexpectedEof(_ConstantPoolInfoNameAndType2UnexpectedEof), AsConstantPoolInfoInvalidConstantPoolTag(_ConstantPoolInfoInvalidConstantPoolTag), ConstantPoolInfo)+import Language.Java.Class.MethodAccessFlags(AsMethodAccessFlagsUnexpectedEof(_MethodAccessFlagsUnexpectedEof))+import Language.Java.Class.ConstantPool(AsConstantPoolCountUnexpectedEof(_ConstantPoolCountUnexpectedEof), AsConstantPoolConstantPoolInfoError(_ConstantPoolConstantPoolInfoError), ConstantPool, ConstantPoolError, constantPool)+import Language.Java.Class.Cafebabe(AsCafebabeUnexpectedEof(_CafebabeUnexpectedEof), AsCafebabeInvalidMagicNumber(_CafebabeInvalidMagicNumber), CafebabeError, cafebabe)+import Language.Java.Class.Version(AsVersionMinorUnexpectedEof(_VersionMinorUnexpectedEof), AsVersionMajorUnexpectedEof(_VersionMajorUnexpectedEof), Version, VersionError, version)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure >+data ClassFile p c i a f s m b t d u =+ ClassFile+ Version+ (ConstantPool p c)+ ThisAccessFlags+ ThisClass+ SuperClass+ (Interfaces i)+ (Fields a f s)+ (Methods m b t)+ (Attributes d u)++deriving instance (Eq (ConstantPool p c), Eq (Interfaces i), Eq (Fields a f s), Eq (Methods m b t), Eq (Attributes d u)) => Eq (ClassFile p c i a f s m b t d u)+deriving instance (Ord (ConstantPool p c), Ord (Interfaces i), Ord (Fields a f s), Ord (Methods m b t), Ord (Attributes d u)) => Ord (ClassFile p c i a f s m b t d u)+deriving instance (Show (ConstantPool p c), Show (Interfaces i), Show (Fields a f s), Show (Methods m b t), Show (Attributes d u)) => Show (ClassFile p c i a f s m b t d u)++type ClassFile' x =+ ClassFile x x x x x x x x x x x+ +data ClassFileError c =+ ClassFileCafebabeError CafebabeError+ | ClassFileVersionError VersionError+ | ClassFileConstantPoolError (ConstantPoolError c)+ | ClassFileThisAccessFlagsError ThisAccessFlagsError+ | ClassFileThisClassError ThisClassError+ | ClassFileSuperClassError SuperClassError+ | ClassFileInterfacesError InterfacesError+ | ClassFileFieldsError FieldsError+ | ClassFileMethodsError MethodsError+ | ClassFileAttributesError AttributesError+ | ClassFileUnexpectedInputOnStream++deriving instance Eq (ConstantPoolError c) => Eq (ClassFileError c)+deriving instance Ord (ConstantPoolError c) => Ord (ClassFileError c)+deriving instance Show (ConstantPoolError c) => Show (ClassFileError c)++class AsClassFileCafebabeError p f s where+ _ClassFileCafebabeError :: + Optic' p f s CafebabeError++instance (Choice p, Applicative f) => AsClassFileCafebabeError p f (ClassFileError c) where+ _ClassFileCafebabeError =+ prism'+ ClassFileCafebabeError+ (\e -> case e of+ ClassFileCafebabeError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsCafebabeUnexpectedEof p f (ClassFileError c) where+ _CafebabeUnexpectedEof =+ _ClassFileCafebabeError . _CafebabeUnexpectedEof++instance (Choice p, Applicative f) => AsCafebabeInvalidMagicNumber p f (ClassFileError c) where+ _CafebabeInvalidMagicNumber =+ _ClassFileCafebabeError . _CafebabeInvalidMagicNumber++class AsClassFileVersionError p f s where+ _ClassFileVersionError :: + Optic' p f s VersionError++instance (Choice p, Applicative f) => AsClassFileVersionError p f (ClassFileError c) where+ _ClassFileVersionError =+ prism'+ ClassFileVersionError+ (\e -> case e of+ ClassFileVersionError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsVersionMinorUnexpectedEof p f (ClassFileError c) where+ _VersionMinorUnexpectedEof =+ _ClassFileVersionError . _VersionMinorUnexpectedEof++instance (Choice p, Applicative f) => AsVersionMajorUnexpectedEof p f (ClassFileError c) where+ _VersionMajorUnexpectedEof =+ _ClassFileVersionError . _VersionMajorUnexpectedEof++class AsClassFileConstantPoolError p f s where+ _ClassFileConstantPoolError :: + Optic' p f (s c) (ConstantPoolError c)++instance (Choice p, Applicative f) => AsClassFileConstantPoolError p f ClassFileError where+ _ClassFileConstantPoolError =+ prism'+ ClassFileConstantPoolError+ (\e -> case e of+ ClassFileConstantPoolError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsConstantPoolCountUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolCountUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolCountUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolConstantPoolInfoError p f ClassFileError where+ _ConstantPoolConstantPoolInfoError =+ _ClassFileConstantPoolError . _ConstantPoolConstantPoolInfoError++instance (Choice p, Applicative f) => AsConstantPoolInfoTagUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoTagUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoTagUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8LengthUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoUtf8LengthUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoUtf8LengthUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoUtf8UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoUtf8UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInvalidJavaString p f ClassFileError where+ _ConstantPoolInvalidJavaString =+ _ClassFileConstantPoolError . _ConstantPoolInvalidJavaString++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantIntegerUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantIntegerUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantIntegerUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantFloatUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantFloatUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantFloatUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantLongUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantLongUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantLongUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantDoubleUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantDoubleUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantDoubleUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantClassUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantClassUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantClassUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantStringUnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoConstantStringUnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoConstantStringUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef1UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoFieldRef1UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoFieldRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef2UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoFieldRef2UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoFieldRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef1UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoMethodRef1UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoMethodRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef2UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoMethodRef2UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoMethodRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType1UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoNameAndType1UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoNameAndType1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType2UnexpectedEof p f (ClassFileError c) where+ _ConstantPoolInfoNameAndType2UnexpectedEof =+ _ClassFileConstantPoolError . _ConstantPoolInfoNameAndType2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInvalidConstantPoolTag p f (ClassFileError c) where+ _ConstantPoolInfoInvalidConstantPoolTag =+ _ClassFileConstantPoolError . _ConstantPoolInfoInvalidConstantPoolTag++class AsClassFileThisAccessFlagsError p f s where+ _ClassFileThisAccessFlagsError :: + Optic' p f s ThisAccessFlagsError++instance (Choice p, Applicative f) => AsClassFileThisAccessFlagsError p f (ClassFileError c) where+ _ClassFileThisAccessFlagsError =+ prism'+ ClassFileThisAccessFlagsError+ (\e -> case e of+ ClassFileThisAccessFlagsError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsThisAccessFlagsUnexpectedEof p f (ClassFileError c) where+ _ThisAccessFlagsUnexpectedEof =+ _ClassFileThisAccessFlagsError . _ThisAccessFlagsUnexpectedEof++class AsClassFileThisClassError p f s where+ _ClassFileThisClassError :: + Optic' p f s ThisClassError++instance (Choice p, Applicative f) => AsClassFileThisClassError p f (ClassFileError c) where+ _ClassFileThisClassError =+ prism'+ ClassFileThisClassError+ (\e -> case e of+ ClassFileThisClassError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsThisClassUnexpectedEof p f (ClassFileError c) where+ _ThisClassUnexpectedEof =+ _ClassFileThisClassError . _ThisClassUnexpectedEof++class AsClassFileSuperClassError p f s where+ _ClassFileSuperClassError :: + Optic' p f s SuperClassError++instance (Choice p, Applicative f) => AsClassFileSuperClassError p f (ClassFileError c) where+ _ClassFileSuperClassError =+ prism'+ ClassFileSuperClassError+ (\e -> case e of+ ClassFileSuperClassError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsSuperClassUnexpectedEof p f (ClassFileError c) where+ _SuperClassUnexpectedEof =+ _ClassFileSuperClassError . _SuperClassUnexpectedEof++class AsClassFileInterfacesError p f s where+ _ClassFileInterfacesError :: + Optic' p f s InterfacesError++instance (Choice p, Applicative f) => AsClassFileInterfacesError p f (ClassFileError c) where+ _ClassFileInterfacesError =+ prism'+ ClassFileInterfacesError+ (\e -> case e of+ ClassFileInterfacesError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsInterfacesCountUnexpectedEof p f (ClassFileError c) where+ _InterfacesCountUnexpectedEof =+ _ClassFileInterfacesError . _InterfacesCountUnexpectedEof++instance (Choice p, Applicative f) => AsInterfacesUnexpectedEof p f (ClassFileError c) where+ _InterfacesUnexpectedEof =+ _ClassFileInterfacesError . _InterfacesUnexpectedEof++class AsClassFileFieldsError p f s where+ _ClassFileFieldsError :: + Optic' p f s FieldsError++instance (Choice p, Applicative f) => AsClassFileFieldsError p f (ClassFileError c) where+ _ClassFileFieldsError =+ prism'+ ClassFileFieldsError+ (\e -> case e of+ ClassFileFieldsError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsFieldsFieldInfoUnexpectedEof p f (ClassFileError c) where+ _FieldsFieldInfoUnexpectedEof =+ _ClassFileFieldsError . _FieldsFieldInfoUnexpectedEof++instance (Choice p, Applicative f) => AsFieldsFieldError p f (ClassFileError c) where+ _FieldsFieldError =+ _ClassFileFieldsError . _FieldsFieldError++instance (p ~ (->), Applicative f) => AsFieldFieldAccessFlagsError p f (ClassFileError c) where+ _FieldFieldAccessFlagsError =+ _ClassFileFieldsError . _FieldFieldAccessFlagsError++instance (p ~ (->), Applicative f) => AsFieldNameIndexUnexpectedEof p f (ClassFileError c) where+ _FieldNameIndexUnexpectedEof =+ _ClassFileFieldsError . _FieldNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldDescriptorIndexUnexpectedEof p f (ClassFileError c) where+ _FieldDescriptorIndexUnexpectedEof =+ _ClassFileFieldsError . _FieldDescriptorIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldAttributeCountUnexpectedEof p f (ClassFileError c) where+ _FieldAttributeCountUnexpectedEof =+ _ClassFileFieldsError . _FieldAttributeCountUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldErrorAttributeError p f (ClassFileError c) where+ _FieldErrorAttributeError =+ _ClassFileFieldsError . _FieldErrorAttributeError++instance (p ~ (->), Applicative f) => AsFieldAttributeError p f (ClassFileError c) where+ _FieldAttributeError =+ _ClassFileFieldsError . _FieldAttributeError++class AsClassFileMethodsError p f s where+ _ClassFileMethodsError :: + Optic' p f s MethodsError++instance (Choice p, Applicative f) => AsClassFileMethodsError p f (ClassFileError c) where+ _ClassFileMethodsError =+ prism'+ ClassFileMethodsError+ (\e -> case e of+ ClassFileMethodsError r -> Just r+ _ -> Nothing)++instance (Choice p, Applicative f) => AsMethodsInfoUnexpectedEof p f (ClassFileError c) where+ _MethodsInfoUnexpectedEof =+ _ClassFileMethodsError . _MethodsInfoUnexpectedEof+ +instance (Choice p, Applicative f) => AsMethodsMethodError p f (ClassFileError c) where+ _MethodsMethodError =+ _ClassFileMethodsError . _MethodsMethodError++instance (p ~ (->), Applicative f) => AsMethodNameIndexUnexpectedEof p f (ClassFileError c) where+ _MethodNameIndexUnexpectedEof =+ _ClassFileMethodsError . _MethodNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodDescriptorIndexUnexpectedEof p f (ClassFileError c) where+ _MethodDescriptorIndexUnexpectedEof =+ _ClassFileMethodsError . _MethodDescriptorIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodAttributeCountUnexpectedEof p f (ClassFileError c) where+ _MethodAttributeCountUnexpectedEof =+ _ClassFileMethodsError . _MethodAttributeCountUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodAttributeUnexpectedEof p f (ClassFileError c) where+ _MethodAttributeUnexpectedEof =+ _ClassFileMethodsError . _MethodAttributeUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodErrorAttributeError p f (ClassFileError c) where+ _MethodErrorAttributeError =+ _ClassFileMethodsError . _MethodErrorAttributeError++instance (p ~ (->), Applicative f) => AsMethodMethodAccessFlagsError p f (ClassFileError c) where+ _MethodMethodAccessFlagsError =+ _ClassFileMethodsError . _MethodMethodAccessFlagsError++instance (p ~ (->), Applicative f) => AsMethodAccessFlagsUnexpectedEof p f (ClassFileError c) where+ _MethodAccessFlagsUnexpectedEof =+ _ClassFileMethodsError . _MethodAccessFlagsUnexpectedEof++class AsClassFileAttributesError p f s where+ _ClassFileAttributesError :: + Optic' p f s AttributesError++instance (Choice p, Applicative f) => AsClassFileAttributesError p f (ClassFileError c) where+ _ClassFileAttributesError =+ prism'+ ClassFileAttributesError+ (\e -> case e of+ ClassFileAttributesError r -> Just r+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsAttributesInfoUnexpectedEof p f (ClassFileError c) where+ _AttributesInfoUnexpectedEof =+ _ClassFileAttributesError . _AttributesInfoUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributesAttributeError p f (ClassFileError c) where+ _AttributesAttributeError =+ _ClassFileAttributesError . _AttributesAttributeError++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f (ClassFileError c) where+ _AttributeNameIndexUnexpectedEof =+ _ClassFileAttributesError . _AttributeNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f (ClassFileError c) where+ _AttributeLengthUnexpectedEof =+ _ClassFileAttributesError . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f (ClassFileError c) where+ _AttributeUnexpectedEof =+ _ClassFileAttributesError . _AttributeUnexpectedEof++class AsClassFileUnexpectedInputOnStream p f s where+ _ClassFileUnexpectedInputOnStream :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsClassFileUnexpectedInputOnStream p f (ClassFileError c) where+ _ClassFileUnexpectedInputOnStream =+ prism'+ (\() -> ClassFileUnexpectedInputOnStream)+ (\e -> case e of+ ClassFileUnexpectedInputOnStream -> Just ()+ _ -> Nothing)++classFileUnexpectedInputOnStream ::+ AsClassFileUnexpectedInputOnStream Tagged Identity t =>+ t+classFileUnexpectedInputOnStream =+ _ClassFileUnexpectedInputOnStream # ()++classFile ::+ (AsEmpty (c Word8), AsEmpty (t Char),+ AsEmpty (f (Attribute a1)), AsEmpty (a Word8),+ AsEmpty (m (Attribute a2)), AsEmpty (a3 Word8), AsEmpty (a4 Word8),+ AsEmpty (c1 (ConstantPoolInfo p)), AsEmpty (i Word16),+ AsEmpty (s1 (Field a5 f1)), AsEmpty (t1 (Method m1 b)),+ AsEmpty (u (Attribute d)), Cons (c Word8) (c Word8) Word8 Word8,+ Cons (t Char) (t Char) Char Char,+ Cons+ (f (Attribute a1)) (f (Attribute a1)) (Attribute a) (Attribute a),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons+ (m (Attribute a2))+ (m (Attribute a2))+ (Attribute a3)+ (Attribute a3),+ Cons (a3 Word8) (a3 Word8) Word8 Word8,+ Cons (a4 Word8) (a4 Word8) Word8 Word8,+ Cons+ (c1 (ConstantPoolInfo p))+ (c1 (ConstantPoolInfo p))+ (ConstantPoolInfo t)+ (ConstantPoolInfo t),+ Cons (i Word16) (i Word16) Word16 Word16,+ Cons+ (s1 (Field a5 f1)) (s1 (Field a5 f1)) (Field a1 f) (Field a1 f),+ Cons+ (t1 (Method m1 b)) (t1 (Method m1 b)) (Method m a2) (Method m a2),+ Cons+ (u (Attribute d)) (u (Attribute d)) (Attribute a4) (Attribute a4),+ AsClassFileCafebabeError Tagged Identity (s c),+ AsClassFileVersionError Tagged Identity (s c),+ AsClassFileConstantPoolError Tagged Identity s,+ AsClassFileThisAccessFlagsError Tagged Identity (s c),+ AsClassFileThisClassError Tagged Identity (s c),+ AsClassFileSuperClassError Tagged Identity (s c),+ AsClassFileInterfacesError Tagged Identity (s c),+ AsClassFileFieldsError Tagged Identity (s c),+ AsClassFileMethodsError Tagged Identity (s c),+ AsClassFileAttributesError Tagged Identity (s c),+ AsClassFileUnexpectedInputOnStream Tagged Identity (s c)) =>+ Get (s c) (ClassFile p c1 i a5 f1 s1 m1 b t1 d u)+classFile =+ do (_ClassFileCafebabeError #) !!- cafebabe+ v <- (_ClassFileVersionError #) !!- version+ p <- (_ClassFileConstantPoolError #) !!- constantPool+ a <- (_ClassFileThisAccessFlagsError #) !!- thisAccessFlags+ t <- (_ClassFileThisClassError #) !!- thisClass+ s <- (_ClassFileSuperClassError #) !!- superClass+ i <- (_ClassFileInterfacesError #) !!- interfaces+ f <- (_ClassFileFieldsError #) !!- fields+ m <- (_ClassFileMethodsError #) !!- methods+ b <- (_ClassFileAttributesError #) !!- attributes+ e <- isEmpty+ if e+ then+ return (ClassFile v p a t s i f m b)+ else+ failGet classFileUnexpectedInputOnStream
+ src/Language/Java/Class/ConstantPool.hs view
@@ -0,0 +1,230 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.ConstantPool(+ ConstantPool(..)+, AsConstantPool(..)+, ConstantPoolError(..)+, AsConstantPoolCountUnexpectedEof(..)+, constantPoolCountUnexpectedEof+, AsConstantPoolConstantPoolInfoError(..)+, constantPool+, constantPool'+) where++import Control.Applicative(Applicative, liftA2)+import Control.Category((.), id)+import Control.Lens(Choice, Optic', Cons, AsEmpty, Profunctor, prism', iso, isn't, ( # ))+import Control.Lens.Internal.Prism+import Control.Monad(Monad(return))+import Control.Replicate(replicateN)+import Data.Bool(bool, (&&))+import Data.Char(Char)+import Data.Eq(Eq)+import Data.Functor((<$>), Functor)+import Data.Functor.Identity(Identity)+import Data.Int(Int64)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, word16be, (!-), (!!-))+import Data.Word(Word8, Word16)+import Language.Java.Class.ConstantPoolInfo(AsConstantPoolInfoTagUnexpectedEof(_ConstantPoolInfoTagUnexpectedEof), AsConstantPoolInfoUtf8LengthUnexpectedEof(_ConstantPoolInfoUtf8LengthUnexpectedEof), AsConstantPoolInfoUtf8UnexpectedEof(_ConstantPoolInfoUtf8UnexpectedEof), AsConstantPoolInvalidJavaString(_ConstantPoolInvalidJavaString), AsConstantPoolInfoConstantIntegerUnexpectedEof(_ConstantPoolInfoConstantIntegerUnexpectedEof), AsConstantPoolInfoConstantFloatUnexpectedEof(_ConstantPoolInfoConstantFloatUnexpectedEof), AsConstantPoolInfoConstantLongUnexpectedEof(_ConstantPoolInfoConstantLongUnexpectedEof), AsConstantPoolInfoConstantDoubleUnexpectedEof(_ConstantPoolInfoConstantDoubleUnexpectedEof), AsConstantPoolInfoConstantClassUnexpectedEof(_ConstantPoolInfoConstantClassUnexpectedEof), AsConstantPoolInfoConstantStringUnexpectedEof(_ConstantPoolInfoConstantStringUnexpectedEof), AsConstantPoolInfoFieldRef1UnexpectedEof(_ConstantPoolInfoFieldRef1UnexpectedEof), AsConstantPoolInfoFieldRef2UnexpectedEof(_ConstantPoolInfoFieldRef2UnexpectedEof), AsConstantPoolInfoMethodRef1UnexpectedEof(_ConstantPoolInfoMethodRef1UnexpectedEof), AsConstantPoolInfoMethodRef2UnexpectedEof(_ConstantPoolInfoMethodRef2UnexpectedEof), AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof(_ConstantPoolInfoInterfaceMethodRef1UnexpectedEof), AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof(_ConstantPoolInfoInterfaceMethodRef2UnexpectedEof), AsConstantPoolInfoNameAndType1UnexpectedEof(_ConstantPoolInfoNameAndType1UnexpectedEof), AsConstantPoolInfoNameAndType2UnexpectedEof(_ConstantPoolInfoNameAndType2UnexpectedEof), AsConstantPoolInfoInvalidConstantPoolTag(_ConstantPoolInfoInvalidConstantPoolTag), ConstantPoolInfo, ConstantPoolInfoError, constantPoolInfo, _ConstantDouble, _ConstantLong, AsUtf8, AsConstantLong, AsConstantFloat, AsConstantInteger, AsConstantString, AsInterfaceMethodRef, AsMethodRef, AsFieldRef, AsConstantClass, AsNameAndType, AsConstantDouble)+import Prelude(Show, Num((-)), Double, subtract)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4 4.4. The Constant Pool>+data ConstantPool p c =+ ConstantPool+ Word16+ (c (ConstantPoolInfo p))++deriving instance Eq (c (ConstantPoolInfo p)) => Eq (ConstantPool p c)+deriving instance Ord (c (ConstantPoolInfo p)) => Ord (ConstantPool p c)+deriving instance Show (c (ConstantPoolInfo p)) => Show (ConstantPool p c)++class AsConstantPool p f s where+ _ConstantPool ::+ Optic' p f (s p' c) (Word16, c (ConstantPoolInfo p'))++instance (Profunctor p, Functor f) => AsConstantPool p f ConstantPool where+ _ConstantPool =+ iso+ (\(ConstantPool w i) -> (w, i))+ (\(w, i) -> ConstantPool w i)++data ConstantPoolError c =+ ConstantPoolCountUnexpectedEof+ | ConstantPoolConstantPoolInfoError (ConstantPoolInfoError c)++deriving instance Eq (ConstantPoolInfoError c) => Eq (ConstantPoolError c)+deriving instance Ord (ConstantPoolInfoError c) => Ord (ConstantPoolError c)+deriving instance Show (ConstantPoolInfoError c) => Show (ConstantPoolError c)++class AsConstantPoolCountUnexpectedEof p f s where+ _ConstantPoolCountUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolCountUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolCountUnexpectedEof =+ prism'+ (\() -> ConstantPoolCountUnexpectedEof)+ (\e -> case e of+ ConstantPoolCountUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolCountUnexpectedEof ::+ AsConstantPoolCountUnexpectedEof Tagged Identity t =>+ t+constantPoolCountUnexpectedEof =+ _ConstantPoolCountUnexpectedEof # ()++class AsConstantPoolConstantPoolInfoError p f s where+ _ConstantPoolConstantPoolInfoError :: + Optic' p f (s c) (ConstantPoolInfoError c)++instance (Choice p, Applicative f) => AsConstantPoolConstantPoolInfoError p f ConstantPoolError where+ _ConstantPoolConstantPoolInfoError =+ prism'+ ConstantPoolConstantPoolInfoError+ (\e -> case e of+ ConstantPoolConstantPoolInfoError r -> Just r+ _ -> Nothing)+++instance (Choice p, Applicative f) => AsConstantPoolInfoTagUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoTagUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoTagUnexpectedEof+++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8LengthUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoUtf8LengthUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoUtf8LengthUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoUtf8UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoUtf8UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInvalidJavaString p f ConstantPoolError where+ _ConstantPoolInvalidJavaString =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInvalidJavaString++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantIntegerUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantIntegerUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantIntegerUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantFloatUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantFloatUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantFloatUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantLongUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantLongUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantLongUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantDoubleUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantDoubleUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantDoubleUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantClassUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantClassUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantClassUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantStringUnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoConstantStringUnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoConstantStringUnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef1UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoFieldRef1UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoFieldRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef2UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoFieldRef2UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoFieldRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef1UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoMethodRef1UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoMethodRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef2UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoMethodRef2UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoMethodRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType1UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoNameAndType1UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoNameAndType1UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType2UnexpectedEof p f (ConstantPoolError c) where+ _ConstantPoolInfoNameAndType2UnexpectedEof =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoNameAndType2UnexpectedEof++instance (Choice p, Applicative f) => AsConstantPoolInfoInvalidConstantPoolTag p f (ConstantPoolError c) where+ _ConstantPoolInfoInvalidConstantPoolTag =+ _ConstantPoolConstantPoolInfoError . _ConstantPoolInfoInvalidConstantPoolTag++constantPool ::+ (AsEmpty (c Word8), AsEmpty (q Char),+ AsEmpty (c1 (ConstantPoolInfo p')),+ Cons+ (c Word8)+ (c Word8)+ Word8+ Word8,+ Cons (q Char) (q Char) Char Char,+ Cons+ (c1 (ConstantPoolInfo p'))+ (c1 (ConstantPoolInfo p'))+ (s1 q)+ (s1 q),+ AsUtf8 Tagged Identity s1,+ AsNameAndType Tagged Identity (s1 q),+ AsConstantDouble Tagged Identity (s1 q),+ AsConstantDouble+ (Market Double Double) Identity (s1 q),+ AsConstantLong Tagged Identity (s1 q),+ AsConstantLong+ (Market Int64 Int64)+ Identity+ (s1 q),+ AsConstantFloat Tagged Identity (s1 q),+ AsConstantInteger Tagged Identity (s1 q),+ AsConstantString Tagged Identity (s1 q),+ AsInterfaceMethodRef Tagged Identity (s1 q),+ AsMethodRef Tagged Identity (s1 q),+ AsFieldRef Tagged Identity (s1 q),+ AsConstantClass Tagged Identity (s1 q),+ AsConstantPoolConstantPoolInfoError Tagged Identity s,+ AsConstantPoolCountUnexpectedEof Tagged Identity (s c),+ AsConstantPool Tagged Identity s2) =>+ Get (s c) (s2 p' c1)+constantPool =+ constantPool' constantPoolInfo++constantPool' ::+ (AsEmpty (c1 (ConstantPoolInfo p')),+ Cons (c1 (ConstantPoolInfo p')) (c1 (ConstantPoolInfo p')) a a,+ AsConstantDouble (Market Double Double) Identity a,+ AsConstantLong (Market Int64 Int64) Identity a,+ AsConstantPoolConstantPoolInfoError Tagged Identity s,+ AsConstantPoolCountUnexpectedEof Tagged Identity (s c),+ AsConstantPool Tagged Identity s1) =>+ Get (ConstantPoolInfoError c) a+ -> Get (s c) (s1 p' c1)+constantPool' cpi =+ let jump =+ bool (subtract 1) id . liftA2 (&&) (isn't _ConstantLong) (isn't _ConstantDouble)+ in do constant_pool_count <- constantPoolCountUnexpectedEof !- word16be+ pool <- (_ConstantPoolConstantPoolInfoError #) !!- replicateN (\n -> (\i -> (jump i n, i)) <$> cpi) (constant_pool_count - 1)+ return (_ConstantPool # (constant_pool_count, pool))
+ src/Language/Java/Class/ConstantPoolInfo.hs view
@@ -0,0 +1,764 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.ConstantPoolInfo (+ ConstantPoolInfo(..)+, AsConstantClass(..)+, AsFieldRef(..)+, AsMethodRef(..)+, AsInterfaceMethodRef(..)+, AsConstantString(..)+, AsConstantInteger(..)+, AsConstantFloat(..)+, AsConstantLong(..)+, AsConstantDouble(..)+, AsNameAndType(..)+, AsUtf8(..)+, ConstantPoolInfoError(..)+, AsConstantPoolInfoTagUnexpectedEof(..)+, constantPoolInfoTagUnexpectedEof+, AsConstantPoolInfoUtf8LengthUnexpectedEof(..)+, constantPoolInfoUtf8LengthUnexpectedEof+, AsConstantPoolInfoUtf8UnexpectedEof(..)+, AsConstantPoolInvalidJavaString(..)+, AsConstantPoolInfoConstantIntegerUnexpectedEof(..)+, constantPoolInfoConstantIntegerUnexpectedEof+, AsConstantPoolInfoConstantFloatUnexpectedEof(..)+, constantPoolInfoConstantFloatUnexpectedEof+, AsConstantPoolInfoConstantLongUnexpectedEof(..)+, constantPoolInfoConstantLongUnexpectedEof+, AsConstantPoolInfoConstantDoubleUnexpectedEof(..)+, constantPoolInfoConstantDoubleUnexpectedEof+, AsConstantPoolInfoConstantClassUnexpectedEof(..)+, constantPoolInfoConstantClassUnexpectedEof+, AsConstantPoolInfoConstantStringUnexpectedEof(..)+, constantPoolInfoConstantStringUnexpectedEof+, AsConstantPoolInfoFieldRef1UnexpectedEof(..)+, constantPoolInfoFieldRef1UnexpectedEof+, AsConstantPoolInfoFieldRef2UnexpectedEof(..)+, constantPoolInfoFieldRef2UnexpectedEof+, AsConstantPoolInfoMethodRef1UnexpectedEof(..)+, constantPoolInfoMethodRef1UnexpectedEof+, AsConstantPoolInfoMethodRef2UnexpectedEof(..)+, constantPoolInfoMethodRef2UnexpectedEof+, AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof(..)+, constantPoolInfoInterfaceMethodRef1UnexpectedEof+, AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof(..)+, constantPoolInfoInterfaceMethodRef2UnexpectedEof+, AsConstantPoolInfoNameAndType1UnexpectedEof(..)+, constantPoolInfoNameAndType1UnexpectedEof+, AsConstantPoolInfoNameAndType2UnexpectedEof(..)+, constantPoolInfoNameAndType2UnexpectedEof+, AsConstantPoolInfoInvalidConstantPoolTag(..)+, constantPoolInfo+, constantPoolInfo'+) where++import Control.Applicative(Applicative)+import Control.Category((.))+import Control.Lens(Optic', Choice, Cons, AsEmpty(_Empty), uncons, prism', (<|), ( # ))+import Control.Monad(Monad(return, (>>=)))+import Control.Replicate(replicateO)+import Data.Bifunctor(bimap)+import Data.Bits(Bits, shift, (.&.))+import Data.Bool(bool, (&&))+import Data.Char(Char, chr)+import Data.Eq(Eq((==)))+import Data.Functor.Identity(Identity)+import Data.Int(Int32, Int64)+import Data.Maybe(Maybe(Just, Nothing), fromMaybe)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle((!-), Get, failGet, word8, word16be, int32be, float32be, int64be, float64be)+import Data.Tuple(curry, uncurry)+import Data.Word(Word8, Word16)+import Prelude(Show, Num((+)), Integral, fromIntegral, Float, Double)++-- |+--+-- < Table 4.3. Constant pool tags>+data ConstantPoolInfo p =+ ConstantClass Word16+ | FieldRef Word16 Word16+ | MethodRef Word16 Word16+ | InterfaceMethodRef Word16 Word16+ | ConstantString Word16+ | ConstantInteger Int32+ | ConstantFloat Float+ | ConstantLong Int64+ | ConstantDouble Double+ | NameAndType Word16 Word16+ | Utf8 Word16 (p Char)++deriving instance Eq (p Char) => Eq (ConstantPoolInfo p)+deriving instance Ord (p Char) => Ord (ConstantPoolInfo p)+deriving instance Show (p Char) => Show (ConstantPoolInfo p)++class AsConstantClass p f s where+ _ConstantClass ::+ Optic' p f s Word16++instance (Choice p', Applicative f) => AsConstantClass p' f (ConstantPoolInfo p) where+ _ConstantClass =+ prism'+ ConstantClass+ (\p -> case p of+ ConstantClass w -> Just w+ _ -> Nothing)++class AsFieldRef p f s where+ _FieldRef ::+ Optic' p f s (Word16, Word16)++instance (Choice p', Applicative f) => AsFieldRef p' f (ConstantPoolInfo p) where+ _FieldRef =+ prism'+ (uncurry FieldRef)+ (\p -> case p of+ FieldRef w1 w2 -> Just (w1, w2)+ _ -> Nothing)++class AsMethodRef p f s where+ _MethodRef ::+ Optic' p f s (Word16, Word16)++instance (Choice p', Applicative f) => AsMethodRef p' f (ConstantPoolInfo p) where+ _MethodRef =+ prism'+ (uncurry MethodRef)+ (\p -> case p of+ MethodRef w1 w2 -> Just (w1, w2)+ _ -> Nothing)++class AsInterfaceMethodRef p f s where+ _InterfaceMethodRef ::+ Optic' p f s (Word16, Word16)++instance (Choice p', Applicative f) => AsInterfaceMethodRef p' f (ConstantPoolInfo p) where+ _InterfaceMethodRef =+ prism'+ (uncurry InterfaceMethodRef)+ (\p -> case p of+ InterfaceMethodRef w1 w2 -> Just (w1, w2)+ _ -> Nothing)++class AsConstantString p f s where+ _ConstantString ::+ Optic' p f s Word16++instance (Choice p', Applicative f) => AsConstantString p' f (ConstantPoolInfo p) where+ _ConstantString =+ prism'+ ConstantString+ (\p -> case p of+ ConstantString w -> Just w+ _ -> Nothing)++class AsConstantInteger p f s where+ _ConstantInteger ::+ Optic' p f s Int32++instance (Choice p', Applicative f) => AsConstantInteger p' f (ConstantPoolInfo p) where+ _ConstantInteger =+ prism'+ ConstantInteger+ (\p -> case p of+ ConstantInteger w -> Just w+ _ -> Nothing)++class AsConstantFloat p f s where+ _ConstantFloat ::+ Optic' p f s Float++instance (Choice p', Applicative f) => AsConstantFloat p' f (ConstantPoolInfo p) where+ _ConstantFloat =+ prism'+ ConstantFloat+ (\p -> case p of+ ConstantFloat w -> Just w+ _ -> Nothing)++class AsConstantLong p f s where+ _ConstantLong ::+ Optic' p f s Int64++instance (Choice p', Applicative f) => AsConstantLong p' f (ConstantPoolInfo p) where+ _ConstantLong =+ prism'+ ConstantLong+ (\p -> case p of+ ConstantLong w -> Just w+ _ -> Nothing)++class AsConstantDouble p f s where+ _ConstantDouble ::+ Optic' p f s Double++instance (Choice p', Applicative f) => AsConstantDouble p' f (ConstantPoolInfo p) where+ _ConstantDouble =+ prism'+ ConstantDouble+ (\p -> case p of+ ConstantDouble w -> Just w+ _ -> Nothing)++class AsNameAndType p f s where+ _NameAndType ::+ Optic' p f s (Word16, Word16)++instance (Choice p', Applicative f) => AsNameAndType p' f (ConstantPoolInfo p) where+ _NameAndType =+ prism'+ (uncurry NameAndType)+ (\p -> case p of+ NameAndType w1 w2 -> Just (w1, w2)+ _ -> Nothing)++class AsUtf8 p f s where+ _Utf8 ::+ Optic' p f (s q) (Word16, q Char)++instance (Choice p', Applicative f) => AsUtf8 p' f ConstantPoolInfo where+ _Utf8 =+ prism'+ (uncurry Utf8)+ (\p -> case p of+ Utf8 w1 w2 -> Just (w1, w2)+ _ -> Nothing)++data ConstantPoolInfoError c =+ ConstantPoolInfoTagUnexpectedEof+ | ConstantPoolInfoUtf8LengthUnexpectedEof+ | ConstantPoolInfoUtf8UnexpectedEof Word16+ | ConstantPoolInvalidJavaString (c Word8)+ | ConstantPoolInfoConstantIntegerUnexpectedEof+ | ConstantPoolInfoConstantFloatUnexpectedEof+ | ConstantPoolInfoConstantLongUnexpectedEof+ | ConstantPoolInfoConstantDoubleUnexpectedEof+ | ConstantPoolInfoConstantClassUnexpectedEof+ | ConstantPoolInfoConstantStringUnexpectedEof+ | ConstantPoolInfoFieldRef1UnexpectedEof+ | ConstantPoolInfoFieldRef2UnexpectedEof+ | ConstantPoolInfoMethodRef1UnexpectedEof+ | ConstantPoolInfoMethodRef2UnexpectedEof+ | ConstantPoolInfoInterfaceMethodRef1UnexpectedEof+ | ConstantPoolInfoInterfaceMethodRef2UnexpectedEof+ | ConstantPoolInfoNameAndType1UnexpectedEof+ | ConstantPoolInfoNameAndType2UnexpectedEof+ | ConstantPoolInfoInvalidConstantPoolTag Word8++deriving instance Eq (c Word8) => Eq (ConstantPoolInfoError c)+deriving instance Ord (c Word8) => Ord (ConstantPoolInfoError c)+deriving instance Show (c Word8) => Show (ConstantPoolInfoError c)++class AsConstantPoolInfoTagUnexpectedEof p f s where+ _ConstantPoolInfoTagUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoTagUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoTagUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoTagUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoTagUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoTagUnexpectedEof ::+ AsConstantPoolInfoTagUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoTagUnexpectedEof =+ _ConstantPoolInfoTagUnexpectedEof # ()++class AsConstantPoolInfoUtf8LengthUnexpectedEof p f s where+ _ConstantPoolInfoUtf8LengthUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8LengthUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoUtf8LengthUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoUtf8LengthUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoUtf8LengthUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoUtf8LengthUnexpectedEof ::+ AsConstantPoolInfoUtf8LengthUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoUtf8LengthUnexpectedEof =+ _ConstantPoolInfoUtf8LengthUnexpectedEof # ()++class AsConstantPoolInfoUtf8UnexpectedEof p f s where+ _ConstantPoolInfoUtf8UnexpectedEof :: + Optic' p f s Word16++instance (Choice p, Applicative f) => AsConstantPoolInfoUtf8UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoUtf8UnexpectedEof =+ prism'+ ConstantPoolInfoUtf8UnexpectedEof+ (\e -> case e of+ ConstantPoolInfoUtf8UnexpectedEof w -> Just w+ _ -> Nothing)++class AsConstantPoolInvalidJavaString p f s where+ _ConstantPoolInvalidJavaString :: + Optic' p f (s c) (c Word8)++instance (Choice p, Applicative f) => AsConstantPoolInvalidJavaString p f ConstantPoolInfoError where+ _ConstantPoolInvalidJavaString =+ prism'+ ConstantPoolInvalidJavaString+ (\e -> case e of+ ConstantPoolInvalidJavaString w -> Just w+ _ -> Nothing)++class AsConstantPoolInfoConstantIntegerUnexpectedEof p f s where+ _ConstantPoolInfoConstantIntegerUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantIntegerUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantIntegerUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantIntegerUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantIntegerUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantIntegerUnexpectedEof ::+ AsConstantPoolInfoConstantIntegerUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantIntegerUnexpectedEof =+ _ConstantPoolInfoConstantIntegerUnexpectedEof # ()++class AsConstantPoolInfoConstantFloatUnexpectedEof p f s where+ _ConstantPoolInfoConstantFloatUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantFloatUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantFloatUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantFloatUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantFloatUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantFloatUnexpectedEof ::+ AsConstantPoolInfoConstantFloatUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantFloatUnexpectedEof =+ _ConstantPoolInfoConstantFloatUnexpectedEof # ()++class AsConstantPoolInfoConstantLongUnexpectedEof p f s where+ _ConstantPoolInfoConstantLongUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantLongUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantLongUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantLongUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantLongUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantLongUnexpectedEof ::+ AsConstantPoolInfoConstantLongUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantLongUnexpectedEof =+ _ConstantPoolInfoConstantLongUnexpectedEof # ()++class AsConstantPoolInfoConstantDoubleUnexpectedEof p f s where+ _ConstantPoolInfoConstantDoubleUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantDoubleUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantDoubleUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantDoubleUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantDoubleUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantDoubleUnexpectedEof ::+ AsConstantPoolInfoConstantDoubleUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantDoubleUnexpectedEof =+ _ConstantPoolInfoConstantDoubleUnexpectedEof # ()++class AsConstantPoolInfoConstantClassUnexpectedEof p f s where+ _ConstantPoolInfoConstantClassUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantClassUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantClassUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantClassUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantClassUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantClassUnexpectedEof ::+ AsConstantPoolInfoConstantClassUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantClassUnexpectedEof =+ _ConstantPoolInfoConstantClassUnexpectedEof # ()++class AsConstantPoolInfoConstantStringUnexpectedEof p f s where+ _ConstantPoolInfoConstantStringUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoConstantStringUnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoConstantStringUnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoConstantStringUnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoConstantStringUnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoConstantStringUnexpectedEof ::+ AsConstantPoolInfoConstantStringUnexpectedEof Tagged Identity t =>+ t+constantPoolInfoConstantStringUnexpectedEof =+ _ConstantPoolInfoConstantStringUnexpectedEof # ()++class AsConstantPoolInfoFieldRef1UnexpectedEof p f s where+ _ConstantPoolInfoFieldRef1UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef1UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoFieldRef1UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoFieldRef1UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoFieldRef1UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoFieldRef1UnexpectedEof ::+ AsConstantPoolInfoFieldRef1UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoFieldRef1UnexpectedEof =+ _ConstantPoolInfoFieldRef1UnexpectedEof # ()++class AsConstantPoolInfoFieldRef2UnexpectedEof p f s where+ _ConstantPoolInfoFieldRef2UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoFieldRef2UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoFieldRef2UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoFieldRef2UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoFieldRef2UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoFieldRef2UnexpectedEof ::+ AsConstantPoolInfoFieldRef2UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoFieldRef2UnexpectedEof =+ _ConstantPoolInfoFieldRef2UnexpectedEof # ()++class AsConstantPoolInfoMethodRef1UnexpectedEof p f s where+ _ConstantPoolInfoMethodRef1UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef1UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoMethodRef1UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoMethodRef1UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoMethodRef1UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoMethodRef1UnexpectedEof ::+ AsConstantPoolInfoMethodRef1UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoMethodRef1UnexpectedEof =+ _ConstantPoolInfoMethodRef1UnexpectedEof # ()++class AsConstantPoolInfoMethodRef2UnexpectedEof p f s where+ _ConstantPoolInfoMethodRef2UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoMethodRef2UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoMethodRef2UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoMethodRef2UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoMethodRef2UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoMethodRef2UnexpectedEof ::+ AsConstantPoolInfoMethodRef2UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoMethodRef2UnexpectedEof =+ _ConstantPoolInfoMethodRef2UnexpectedEof # ()++class AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof p f s where+ _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoInterfaceMethodRef1UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoInterfaceMethodRef1UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoInterfaceMethodRef1UnexpectedEof ::+ AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoInterfaceMethodRef1UnexpectedEof =+ _ConstantPoolInfoInterfaceMethodRef1UnexpectedEof # ()++class AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof p f s where+ _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoInterfaceMethodRef2UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoInterfaceMethodRef2UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoInterfaceMethodRef2UnexpectedEof ::+ AsConstantPoolInfoInterfaceMethodRef2UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoInterfaceMethodRef2UnexpectedEof =+ _ConstantPoolInfoInterfaceMethodRef2UnexpectedEof # ()++class AsConstantPoolInfoNameAndType1UnexpectedEof p f s where+ _ConstantPoolInfoNameAndType1UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType1UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoNameAndType1UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoNameAndType1UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoNameAndType1UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoNameAndType1UnexpectedEof ::+ AsConstantPoolInfoNameAndType1UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoNameAndType1UnexpectedEof =+ _ConstantPoolInfoNameAndType1UnexpectedEof # ()++class AsConstantPoolInfoNameAndType2UnexpectedEof p f s where+ _ConstantPoolInfoNameAndType2UnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsConstantPoolInfoNameAndType2UnexpectedEof p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoNameAndType2UnexpectedEof =+ prism'+ (\() -> ConstantPoolInfoNameAndType2UnexpectedEof)+ (\e -> case e of+ ConstantPoolInfoNameAndType2UnexpectedEof -> Just ()+ _ -> Nothing)++constantPoolInfoNameAndType2UnexpectedEof ::+ AsConstantPoolInfoNameAndType2UnexpectedEof Tagged Identity t =>+ t+constantPoolInfoNameAndType2UnexpectedEof =+ _ConstantPoolInfoNameAndType2UnexpectedEof # ()++class AsConstantPoolInfoInvalidConstantPoolTag p f s where+ _ConstantPoolInfoInvalidConstantPoolTag :: + Optic' p f s Word8++instance (Choice p, Applicative f) => AsConstantPoolInfoInvalidConstantPoolTag p f (ConstantPoolInfoError c) where+ _ConstantPoolInfoInvalidConstantPoolTag =+ prism'+ ConstantPoolInfoInvalidConstantPoolTag+ (\e -> case e of+ ConstantPoolInfoInvalidConstantPoolTag w -> Just w+ _ -> Nothing)++getJavaString ::+ (Integral a, Monad m, AsEmpty b, AsEmpty (m b), Cons s s a a,+ Cons b b Char Char, Bits a) =>+ s+ -> m b+getJavaString q =+ let empty :: AsEmpty t => t+ empty = _Empty # ()+ in case uncons q of+ Nothing ->+ return empty+ Just (x, rest) ->+ bool+ (case uncons rest of+ Nothing ->+ empty+ Just (y, rest2) ->+ bool+ (case uncons rest2 of+ Nothing ->+ empty+ Just (z, rest3) ->+ bool+ empty+ (let i = ((fromIntegral x .&. 0x0F) `shift` 12 + (fromIntegral y .&. 0x3F) `shift` 6 + (fromIntegral z .&. 0x3F))+ in getJavaString rest3 >>= return . (chr i <|))+ ((x .&. 0xF0) == 0xE0 && ((y .&. 0xC0) == 0x80) && ((z .&. 0xC0) == 0x80)))+ (let i = (fromIntegral x .&. 0x1F) `shift` 6 + (fromIntegral y .&. 0x3F)+ in getJavaString rest2 >>= return . (chr i <|))+ ((x .&. 0xE0) == 0xC0 && ((y .&. 0xC0) == 0x80)))+ (getJavaString rest >>= return . (chr (fromIntegral x) <|))+ ((x .&. 0x80) == 0)++constantPoolInfo ::+ (AsEmpty (c Word8), AsEmpty (q Char),+ Cons+ (c Word8)+ (c Word8)+ Word8+ Word8,+ Cons (q Char) (q Char) Char Char,+ AsConstantPoolInfoInvalidConstantPoolTag+ Tagged Identity (s c),+ AsConstantPoolInfoNameAndType2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoNameAndType1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoMethodRef2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoMethodRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoFieldRef2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoFieldRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantStringUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantClassUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantDoubleUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantLongUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantFloatUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantIntegerUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInvalidJavaString Tagged Identity s,+ AsConstantPoolInfoUtf8UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoUtf8LengthUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoTagUnexpectedEof+ Tagged Identity (s c),+ AsUtf8 Tagged Identity s1,+ AsNameAndType Tagged Identity (s1 q),+ AsConstantDouble Tagged Identity (s1 q),+ AsConstantLong Tagged Identity (s1 q),+ AsConstantFloat Tagged Identity (s1 q),+ AsConstantInteger Tagged Identity (s1 q),+ AsConstantString Tagged Identity (s1 q),+ AsInterfaceMethodRef Tagged Identity (s1 q),+ AsMethodRef Tagged Identity (s1 q),+ AsFieldRef Tagged Identity (s1 q),+ AsConstantClass Tagged Identity (s1 q)) =>+ Get (s c) (s1 q)+constantPoolInfo =+ constantPoolInfo' (\_ -> Nothing)++constantPoolInfo' ::+ (AsEmpty (c Word8), AsEmpty (q Char),+ Cons+ (c Word8)+ (c Word8)+ Word8+ Word8,+ Cons (q Char) (q Char) Char Char,+ AsConstantPoolInfoInvalidConstantPoolTag+ Tagged Identity (s c),+ AsConstantPoolInfoNameAndType2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoNameAndType1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoInterfaceMethodRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoMethodRef2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoMethodRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoFieldRef2UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoFieldRef1UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantStringUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantClassUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantDoubleUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantLongUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantFloatUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoConstantIntegerUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInvalidJavaString Tagged Identity s,+ AsConstantPoolInfoUtf8UnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoUtf8LengthUnexpectedEof+ Tagged Identity (s c),+ AsConstantPoolInfoTagUnexpectedEof+ Tagged Identity (s c),+ AsUtf8 Tagged Identity s1,+ AsNameAndType Tagged Identity (s1 q),+ AsConstantDouble Tagged Identity (s1 q),+ AsConstantLong Tagged Identity (s1 q),+ AsConstantFloat Tagged Identity (s1 q),+ AsConstantInteger Tagged Identity (s1 q),+ AsConstantString Tagged Identity (s1 q),+ AsInterfaceMethodRef Tagged Identity (s1 q),+ AsMethodRef Tagged Identity (s1 q),+ AsFieldRef Tagged Identity (s1 q),+ AsConstantClass Tagged Identity (s1 q)) =>+ (Word8 -> Maybe (Get (s c) (s1 q))) + -> Get (s c) (s1 q)+constantPoolInfo' f =+ let eset = bimap . return+ two16 t e1 e2 =+ do c <- e1 !- word16be+ n <- e2 !- word16be+ return (t c n) + in do t <- constantPoolInfoTagUnexpectedEof !- word8+ case t of + 1 ->+ do l <- constantPoolInfoUtf8LengthUnexpectedEof !- word16be+ b <- replicateO (\n -> _ConstantPoolInfoUtf8UnexpectedEof # n !- word8) l+ case getJavaString b of+ Nothing -> failGet (_ConstantPoolInvalidJavaString # b)+ Just s -> return (_Utf8 # (l, s))+ 3 ->+ eset constantPoolInfoConstantIntegerUnexpectedEof (_ConstantInteger #) int32be+ 4 ->+ eset constantPoolInfoConstantFloatUnexpectedEof (_ConstantFloat #) float32be+ 5 ->+ eset constantPoolInfoConstantLongUnexpectedEof (_ConstantLong #) int64be+ 6 ->+ eset constantPoolInfoConstantDoubleUnexpectedEof (_ConstantDouble #) float64be+ 7 ->+ eset constantPoolInfoConstantClassUnexpectedEof (_ConstantClass #) word16be+ 8 ->+ eset constantPoolInfoConstantStringUnexpectedEof (_ConstantString #) word16be+ 9 ->+ two16 (curry (_FieldRef #)) constantPoolInfoFieldRef1UnexpectedEof constantPoolInfoFieldRef2UnexpectedEof+ 10 ->+ two16 (curry (_MethodRef #)) constantPoolInfoMethodRef1UnexpectedEof constantPoolInfoMethodRef2UnexpectedEof+ 11 ->+ two16 (curry (_InterfaceMethodRef #)) constantPoolInfoInterfaceMethodRef1UnexpectedEof constantPoolInfoMethodRef2UnexpectedEof+ 12 ->+ two16 (curry (_NameAndType #)) constantPoolInfoNameAndType1UnexpectedEof constantPoolInfoNameAndType2UnexpectedEof+ _ ->+ fromMaybe (failGet (_ConstantPoolInfoInvalidConstantPoolTag # t)) (f t)
+ src/Language/Java/Class/Field.hs view
@@ -0,0 +1,207 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Field(+ Field(..)+, FieldErrorAttributeError(..)+, AsFieldErrorAttributeError(..)+, FieldError(..)+, AsFieldFieldAccessFlagsError(..)+, AsFieldNameIndexUnexpectedEof(..)+, fieldNameIndexUnexpectedEof+, AsFieldDescriptorIndexUnexpectedEof(..)+, fieldDescriptorIndexUnexpectedEof+, AsFieldAttributeCountUnexpectedEof(..)+, fieldAttributeCountUnexpectedEof+, AsFieldAttributeError(..)+, field+) where++import Control.Applicative(Applicative)+import Control.Category((.), id)+import Control.Lens(AsEmpty, Cons, Optic', Choice, Profunctor, prism', ( # ), _2, iso)+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!!-), (!-), word16be)+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute, AttributeError, attribute)+import Language.Java.Class.FieldAccessFlags+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.5 4.5. Fields>+data Field a f =+ Field+ FieldAccessFlags+ Word16 -- name_index+ Word16 -- descriptor_index+ Word16 -- attribute_count+ (f (Attribute a))++deriving instance Eq (f (Attribute a)) => Eq (Field a f)+deriving instance Ord (f (Attribute a)) => Ord (Field a f)+deriving instance Show (f (Attribute a)) => Show (Field a f)++newtype FieldErrorAttributeError =+ FieldErrorAttributeError+ AttributeError+ deriving (Eq, Ord, Show)++class AsFieldErrorAttributeError p f s where+ _FieldErrorAttributeError ::+ Optic' p f s FieldErrorAttributeError++instance AsFieldErrorAttributeError p f FieldErrorAttributeError where+ _FieldErrorAttributeError =+ id++instance (Profunctor p, Functor f) => AsFieldErrorAttributeError p f AttributeError where+ _FieldErrorAttributeError =+ iso+ FieldErrorAttributeError+ (\(FieldErrorAttributeError e) -> e)++instance AsAttributeUnexpectedEof p f FieldErrorAttributeError where+ _AttributeUnexpectedEof =+ _FieldErrorAttributeError . _AttributeUnexpectedEof++instance AsAttributeLengthUnexpectedEof p f FieldErrorAttributeError where + _AttributeLengthUnexpectedEof =+ _FieldErrorAttributeError . _AttributeLengthUnexpectedEof++instance AsAttributeNameIndexUnexpectedEof p f FieldErrorAttributeError where + _AttributeNameIndexUnexpectedEof =+ _FieldErrorAttributeError . _AttributeNameIndexUnexpectedEof++data FieldError =+ FieldFieldAccessFlagsError FieldAccessFlagsError + | FieldNameIndexUnexpectedEof+ | FieldDescriptorIndexUnexpectedEof+ | FieldAttributeCountUnexpectedEof+ | FieldAttributeError Word16 FieldErrorAttributeError+ deriving (Eq, Ord, Show)++class AsFieldFieldAccessFlagsError p f s where+ _FieldFieldAccessFlagsError :: + Optic' p f s FieldAccessFlagsError++instance (Choice p, Applicative f) => AsFieldFieldAccessFlagsError p f FieldError where+ _FieldFieldAccessFlagsError =+ prism'+ FieldFieldAccessFlagsError+ (\e -> case e of+ FieldFieldAccessFlagsError r -> Just r+ _ -> Nothing)+ +class AsFieldNameIndexUnexpectedEof p f s where+ _FieldNameIndexUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsFieldNameIndexUnexpectedEof p f FieldError where+ _FieldNameIndexUnexpectedEof =+ prism'+ (\() -> FieldNameIndexUnexpectedEof)+ (\e -> case e of+ FieldNameIndexUnexpectedEof -> Just ()+ _ -> Nothing) + +fieldNameIndexUnexpectedEof ::+ AsFieldNameIndexUnexpectedEof Tagged Identity t =>+ t+fieldNameIndexUnexpectedEof =+ _FieldNameIndexUnexpectedEof # ()+ +class AsFieldDescriptorIndexUnexpectedEof p f s where+ _FieldDescriptorIndexUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsFieldDescriptorIndexUnexpectedEof p f FieldError where+ _FieldDescriptorIndexUnexpectedEof =+ prism'+ (\() -> FieldDescriptorIndexUnexpectedEof)+ (\e -> case e of+ FieldDescriptorIndexUnexpectedEof -> Just ()+ _ -> Nothing) + +fieldDescriptorIndexUnexpectedEof ::+ AsFieldDescriptorIndexUnexpectedEof Tagged Identity t =>+ t+fieldDescriptorIndexUnexpectedEof =+ _FieldDescriptorIndexUnexpectedEof # ()+ +class AsFieldAttributeCountUnexpectedEof p f s where+ _FieldAttributeCountUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsFieldAttributeCountUnexpectedEof p f FieldError where+ _FieldAttributeCountUnexpectedEof =+ prism'+ (\() -> FieldAttributeCountUnexpectedEof)+ (\e -> case e of+ FieldAttributeCountUnexpectedEof -> Just ()+ _ -> Nothing) ++fieldAttributeCountUnexpectedEof ::+ AsFieldAttributeCountUnexpectedEof Tagged Identity t =>+ t+fieldAttributeCountUnexpectedEof =+ _FieldAttributeCountUnexpectedEof # ()+ +class AsFieldAttributeError p f s where+ _FieldAttributeError :: + Optic' p f s (Word16, FieldErrorAttributeError)++instance (Choice p, Applicative f) => AsFieldAttributeError p f FieldError where+ _FieldAttributeError =+ prism'+ (\(w, r) -> FieldAttributeError w r)+ (\e -> case e of+ FieldAttributeError w r -> Just (w, r)+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsFieldErrorAttributeError p f FieldError where+ _FieldErrorAttributeError =+ _FieldAttributeError . _2 . _FieldErrorAttributeError++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f FieldError where+ _AttributeNameIndexUnexpectedEof =+ _FieldAttributeError . _2 . _AttributeNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f FieldError where+ _AttributeLengthUnexpectedEof =+ _FieldAttributeError . _2 . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f FieldError where+ _AttributeUnexpectedEof =+ _FieldAttributeError . _2 . _AttributeUnexpectedEof++field ::+ (AsEmpty (a Word8), AsEmpty (f (Attribute a1)),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons+ (f (Attribute a1)) (f (Attribute a1)) (Attribute a) (Attribute a),+ AsFieldFieldAccessFlagsError Tagged Identity e,+ AsFieldNameIndexUnexpectedEof Tagged Identity e,+ AsFieldDescriptorIndexUnexpectedEof Tagged Identity e,+ AsFieldAttributeCountUnexpectedEof Tagged Identity e,+ AsFieldAttributeError Tagged Identity e) =>+ Get e (Field a1 f)+field =+ do f <- (_FieldFieldAccessFlagsError #) !!- fieldAccessFlags+ n <- fieldNameIndexUnexpectedEof !- word16be+ d <- fieldDescriptorIndexUnexpectedEof !- word16be+ c <- fieldAttributeCountUnexpectedEof !- word16be+ a <- replicateO (\x -> (\w -> _FieldAttributeError # (x, w)) !!- attribute) c+ return (Field f n d c a)
+ src/Language/Java/Class/FieldAccessFlags.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.FieldAccessFlags(+ FieldAccessFlags(..)+, FieldAccessFlagsError(..)+, AsFieldAccessFlagsUnexpectedEof(..)+, fieldAccessFlagsUnexpectedEof+, fieldAccessFlags+) where++import Control.Lens(Optic', Profunctor, iso, ( # ))+import Control.Monad(return)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!-), word16be)+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.5 4.5. Fields>+newtype FieldAccessFlags =+ FieldAccessFlags+ Word16+ deriving (Eq, Ord, Show)++data FieldAccessFlagsError =+ FieldAccessFlagsUnexpectedEof+ deriving (Eq, Ord, Show)++class AsFieldAccessFlagsUnexpectedEof p f s where+ _FieldAccessFlagsUnexpectedEof :: + Optic' p f s ()++instance (Profunctor p, Functor f) => AsFieldAccessFlagsUnexpectedEof p f FieldAccessFlagsError where+ _FieldAccessFlagsUnexpectedEof =+ iso+ (\_ -> ())+ (\() -> FieldAccessFlagsUnexpectedEof)++fieldAccessFlagsUnexpectedEof ::+ AsFieldAccessFlagsUnexpectedEof Tagged Identity t =>+ t+fieldAccessFlagsUnexpectedEof =+ _FieldAccessFlagsUnexpectedEof # ()++fieldAccessFlags ::+ AsFieldAccessFlagsUnexpectedEof Tagged Identity e =>+ Get e FieldAccessFlags+fieldAccessFlags =+ do af <- fieldAccessFlagsUnexpectedEof !- word16be+ return (FieldAccessFlags af)
+ src/Language/Java/Class/Fields.hs view
@@ -0,0 +1,130 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Fields(+ Fields(..)+, FieldsError(..)+, AsFieldsFieldInfoUnexpectedEof(..)+, fieldsFieldInfoUnexpectedEof+, AsFieldsFieldError(..)+, fields+) where++import Control.Applicative(Applicative)+import Control.Category((.))+import Control.Lens(Cons, AsEmpty, Optic', Choice, prism', ( # ), _2)+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!!-), (!-), word16be)+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute)+import Language.Java.Class.Field(AsFieldErrorAttributeError(_FieldErrorAttributeError), AsFieldFieldAccessFlagsError(_FieldFieldAccessFlagsError), AsFieldNameIndexUnexpectedEof(_FieldNameIndexUnexpectedEof), AsFieldDescriptorIndexUnexpectedEof(_FieldDescriptorIndexUnexpectedEof), AsFieldAttributeCountUnexpectedEof(_FieldAttributeCountUnexpectedEof), AsFieldAttributeError(_FieldAttributeError), Field, FieldError, field)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+data Fields a f s =+ Fields+ Word16+ (s (Field a f))++deriving instance Eq (s (Field a f)) => Eq (Fields a f s)+deriving instance Ord (s (Field a f)) => Ord (Fields a f s)+deriving instance Show (s (Field a f)) => Show (Fields a f s)++data FieldsError =+ FieldsFieldInfoUnexpectedEof+ | FieldsFieldError Word16 FieldError+ deriving (Eq, Ord, Show)++class AsFieldsFieldInfoUnexpectedEof p f s where+ _FieldsFieldInfoUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsFieldsFieldInfoUnexpectedEof p f FieldsError where+ _FieldsFieldInfoUnexpectedEof =+ prism'+ (\() -> FieldsFieldInfoUnexpectedEof)+ (\e -> case e of+ FieldsFieldInfoUnexpectedEof -> Just ()+ _ -> Nothing)++fieldsFieldInfoUnexpectedEof ::+ AsFieldsFieldInfoUnexpectedEof Tagged Identity t =>+ t+fieldsFieldInfoUnexpectedEof=+ _FieldsFieldInfoUnexpectedEof # ()++class AsFieldsFieldError p f s where+ _FieldsFieldError :: + Optic' p f s (Word16, FieldError)++instance (Choice p, Applicative f) => AsFieldsFieldError p f FieldsError where+ _FieldsFieldError =+ prism'+ (\(w, r) -> FieldsFieldError w r)+ (\e -> case e of+ FieldsFieldError w r -> Just (w, r)+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsFieldFieldAccessFlagsError p f FieldsError where+ _FieldFieldAccessFlagsError =+ _FieldsFieldError . _2 . _FieldFieldAccessFlagsError++instance (p ~ (->), Applicative f) => AsFieldNameIndexUnexpectedEof p f FieldsError where+ _FieldNameIndexUnexpectedEof =+ _FieldsFieldError . _2 . _FieldNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldDescriptorIndexUnexpectedEof p f FieldsError where+ _FieldDescriptorIndexUnexpectedEof =+ _FieldsFieldError . _2 . _FieldDescriptorIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldAttributeCountUnexpectedEof p f FieldsError where+ _FieldAttributeCountUnexpectedEof =+ _FieldsFieldError . _2 . _FieldAttributeCountUnexpectedEof++instance (p ~ (->), Applicative f) => AsFieldAttributeError p f FieldsError where+ _FieldAttributeError =+ _FieldsFieldError . _2 . _FieldAttributeError++instance (p ~ (->), Applicative f) => AsFieldErrorAttributeError p f FieldsError where+ _FieldErrorAttributeError =+ _FieldsFieldError . _2 . _FieldErrorAttributeError++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f FieldsError where+ _AttributeNameIndexUnexpectedEof =+ _FieldsFieldError . _2 . _AttributeNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f FieldsError where+ _AttributeLengthUnexpectedEof =+ _FieldsFieldError . _2 . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f FieldsError where+ _AttributeUnexpectedEof =+ _FieldsFieldError . _2 . _AttributeUnexpectedEof++fields ::+ (AsEmpty (f (Attribute a1)), AsEmpty (a Word8),+ AsEmpty (s (Field a2 f1)),+ Cons+ (f (Attribute a1)) (f (Attribute a1)) (Attribute a) (Attribute a),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons (s (Field a2 f1)) (s (Field a2 f1)) (Field a1 f) (Field a1 f),+ AsFieldsFieldInfoUnexpectedEof Tagged Identity e,+ AsFieldsFieldError Tagged Identity e) =>+ Get e (Fields a2 f1 s)+fields =+ do c <- fieldsFieldInfoUnexpectedEof !- word16be+ i <- (_FieldsFieldError #) !!- replicateO (\n -> ((,) n) !!- field) c+ return (Fields c i)
+ src/Language/Java/Class/Interfaces.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Interfaces(+ Interfaces(..)+, InterfacesError(..)+, AsInterfacesCountUnexpectedEof(..)+, interfacesCountUnexpectedEof+, AsInterfacesUnexpectedEof(..)+, interfaces+) where++import Control.Applicative(Applicative)+import Control.Lens(Optic', Choice, AsEmpty, Cons, prism', ( # ))+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!-), word16be)+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+data Interfaces i =+ Interfaces+ Word16+ (i Word16)++deriving instance Eq (i Word16) => Eq (Interfaces i)+deriving instance Ord (i Word16) => Ord (Interfaces i)+deriving instance Show (i Word16) => Show (Interfaces i)++data InterfacesError =+ InterfacesCountUnexpectedEof+ | InterfacesUnexpectedEof Word16+ deriving (Eq, Ord, Show)++class AsInterfacesCountUnexpectedEof p f s where+ _InterfacesCountUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsInterfacesCountUnexpectedEof p f InterfacesError where+ _InterfacesCountUnexpectedEof =+ prism'+ (\() -> InterfacesCountUnexpectedEof)+ (\e -> case e of+ InterfacesCountUnexpectedEof -> Just ()+ _ -> Nothing)+ +interfacesCountUnexpectedEof ::+ AsInterfacesCountUnexpectedEof Tagged Identity t =>+ t+interfacesCountUnexpectedEof =+ _InterfacesCountUnexpectedEof # ()++class AsInterfacesUnexpectedEof p f s where+ _InterfacesUnexpectedEof :: + Optic' p f s Word16++instance (Choice p, Applicative f) => AsInterfacesUnexpectedEof p f InterfacesError where+ _InterfacesUnexpectedEof =+ prism'+ InterfacesUnexpectedEof+ (\e -> case e of+ InterfacesUnexpectedEof w -> Just w+ _ -> Nothing)++interfaces ::+ (AsEmpty (i Word16), Cons (i Word16) (i Word16) Word16 Word16,+ AsInterfacesCountUnexpectedEof Tagged Identity e,+ AsInterfacesUnexpectedEof Tagged Identity e) =>+ Get e (Interfaces i)+interfaces =+ do c <- interfacesCountUnexpectedEof !- word16be+ i <- replicateO (\n -> _InterfacesUnexpectedEof # n !- word16be) c+ return (Interfaces c i)
+ src/Language/Java/Class/Method.hs view
@@ -0,0 +1,211 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Method(+ Method(..)+, MethodErrorAttributeError(..)+, AsMethodErrorAttributeError(..)+, MethodError(..)+, AsMethodNameIndexUnexpectedEof(..)+, methodNameIndexUnexpectedEof+, AsMethodDescriptorIndexUnexpectedEof(..)+, methodDescriptorIndexUnexpectedEof+, AsMethodAttributeCountUnexpectedEof(..)+, methodAttributeCountUnexpectedEof+, AsMethodAttributeUnexpectedEof(..)+, AsMethodMethodAccessFlagsError(..)+, method+) where++import Control.Applicative(Applicative)+import Control.Category((.), id)+import Control.Lens(AsEmpty, Cons, Choice, Optic', Profunctor, prism', ( # ), _2, iso)+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Nothing, Just))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!!-), (!-), word16be)+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute, AttributeError, attribute)+import Language.Java.Class.MethodAccessFlags(AsMethodAccessFlagsUnexpectedEof(_MethodAccessFlagsUnexpectedEof), MethodAccessFlags, MethodAccessFlagsError, methodAccessFlags)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6 4.6. Methods>+data Method m a =+ Method+ MethodAccessFlags+ Word16 -- name_index+ Word16 -- descriptor_index+ Word16 -- attribute_count+ (m (Attribute a))+ +deriving instance Eq (m (Attribute a)) => Eq (Method m a)+deriving instance Ord (m (Attribute a)) => Ord (Method m a)+deriving instance Show (m (Attribute a)) => Show (Method m a)++newtype MethodErrorAttributeError =+ MethodErrorAttributeError+ AttributeError+ deriving (Eq, Ord, Show)++class AsMethodErrorAttributeError p f s where+ _MethodErrorAttributeError ::+ Optic' p f s MethodErrorAttributeError++instance AsMethodErrorAttributeError p f MethodErrorAttributeError where+ _MethodErrorAttributeError =+ id++instance (Profunctor p, Functor f) => AsMethodErrorAttributeError p f AttributeError where+ _MethodErrorAttributeError =+ iso+ MethodErrorAttributeError+ (\(MethodErrorAttributeError e) -> e)++instance AsAttributeUnexpectedEof p f MethodErrorAttributeError where+ _AttributeUnexpectedEof =+ _MethodErrorAttributeError . _AttributeUnexpectedEof++instance AsAttributeLengthUnexpectedEof p f MethodErrorAttributeError where + _AttributeLengthUnexpectedEof =+ _MethodErrorAttributeError . _AttributeLengthUnexpectedEof++instance AsAttributeNameIndexUnexpectedEof p f MethodErrorAttributeError where + _AttributeNameIndexUnexpectedEof =+ _MethodErrorAttributeError . _AttributeNameIndexUnexpectedEof++data MethodError =+ MethodNameIndexUnexpectedEof+ | MethodDescriptorIndexUnexpectedEof+ | MethodAttributeCountUnexpectedEof+ | MethodAttributeUnexpectedEof Word16 MethodErrorAttributeError+ | MethodMethodAccessFlagsError MethodAccessFlagsError+ deriving (Eq, Ord, Show)++class AsMethodNameIndexUnexpectedEof p f s where+ _MethodNameIndexUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsMethodNameIndexUnexpectedEof p f MethodError where+ _MethodNameIndexUnexpectedEof =+ prism'+ (\() -> MethodNameIndexUnexpectedEof)+ (\e -> case e of+ MethodNameIndexUnexpectedEof -> Just ()+ _ -> Nothing)++methodNameIndexUnexpectedEof ::+ AsMethodNameIndexUnexpectedEof Tagged Identity t =>+ t+methodNameIndexUnexpectedEof=+ _MethodNameIndexUnexpectedEof # ()++class AsMethodDescriptorIndexUnexpectedEof p f s where+ _MethodDescriptorIndexUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsMethodDescriptorIndexUnexpectedEof p f MethodError where+ _MethodDescriptorIndexUnexpectedEof =+ prism'+ (\() -> MethodDescriptorIndexUnexpectedEof)+ (\e -> case e of+ MethodDescriptorIndexUnexpectedEof -> Just ()+ _ -> Nothing)++methodDescriptorIndexUnexpectedEof ::+ AsMethodDescriptorIndexUnexpectedEof Tagged Identity t =>+ t+methodDescriptorIndexUnexpectedEof=+ _MethodDescriptorIndexUnexpectedEof # ()++class AsMethodAttributeCountUnexpectedEof p f s where+ _MethodAttributeCountUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsMethodAttributeCountUnexpectedEof p f MethodError where+ _MethodAttributeCountUnexpectedEof =+ prism'+ (\() -> MethodAttributeCountUnexpectedEof)+ (\e -> case e of+ MethodAttributeCountUnexpectedEof -> Just ()+ _ -> Nothing)++methodAttributeCountUnexpectedEof ::+ AsMethodAttributeCountUnexpectedEof Tagged Identity t =>+ t+methodAttributeCountUnexpectedEof=+ _MethodAttributeCountUnexpectedEof # ()++class AsMethodAttributeUnexpectedEof p f s where+ _MethodAttributeUnexpectedEof :: + Optic' p f s (Word16, MethodErrorAttributeError)++instance (Choice p, Applicative f) => AsMethodAttributeUnexpectedEof p f MethodError where+ _MethodAttributeUnexpectedEof =+ prism'+ (\(w, r) -> MethodAttributeUnexpectedEof w r)+ (\e -> case e of+ MethodAttributeUnexpectedEof w r -> Just (w, r)+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsMethodErrorAttributeError p f MethodError where+ _MethodErrorAttributeError =+ _MethodAttributeUnexpectedEof . _2 . _MethodErrorAttributeError++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f MethodError where+ _AttributeNameIndexUnexpectedEof =+ _MethodAttributeUnexpectedEof . _2 . _AttributeNameIndexUnexpectedEof+ +instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f MethodError where+ _AttributeLengthUnexpectedEof =+ _MethodAttributeUnexpectedEof . _2 . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f MethodError where+ _AttributeUnexpectedEof =+ _MethodAttributeUnexpectedEof . _2 . _AttributeUnexpectedEof++class AsMethodMethodAccessFlagsError p f s where+ _MethodMethodAccessFlagsError :: + Optic' p f s MethodAccessFlagsError++instance (Choice p, Applicative f) => AsMethodMethodAccessFlagsError p f MethodError where+ _MethodMethodAccessFlagsError =+ prism'+ MethodMethodAccessFlagsError+ (\e -> case e of+ MethodMethodAccessFlagsError r -> Just r+ _ -> Nothing)+ +instance (Choice p, Applicative f) => AsMethodAccessFlagsUnexpectedEof p f MethodError where+ _MethodAccessFlagsUnexpectedEof =+ _MethodMethodAccessFlagsError . _MethodAccessFlagsUnexpectedEof++method ::+ (AsEmpty (a Word8), AsEmpty (m (Attribute a1)),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons+ (m (Attribute a1)) (m (Attribute a1)) (Attribute a) (Attribute a),+ AsMethodMethodAccessFlagsError Tagged Identity e,+ AsMethodAttributeUnexpectedEof Tagged Identity e,+ AsMethodAttributeCountUnexpectedEof Tagged Identity e,+ AsMethodDescriptorIndexUnexpectedEof Tagged Identity e,+ AsMethodNameIndexUnexpectedEof Tagged Identity e) =>+ Get e (Method m a1)+method =+ do f <- (_MethodMethodAccessFlagsError #) !!- methodAccessFlags+ n <- methodNameIndexUnexpectedEof !- word16be+ d <- methodDescriptorIndexUnexpectedEof !- word16be+ c <- methodAttributeCountUnexpectedEof !- word16be+ a <- (_MethodAttributeUnexpectedEof #) !!- replicateO (\x -> ((,) x) !!- attribute) c+ return (Method f n d c a)
+ src/Language/Java/Class/MethodAccessFlags.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.MethodAccessFlags(+ MethodAccessFlags(..)+, MethodAccessFlagsError(..)+, AsMethodAccessFlagsUnexpectedEof(..)+, methodAccessFlagsUnexpectedEof+, methodAccessFlags+) where++import Control.Lens(Optic', Profunctor, iso, ( # ))+import Control.Monad(return)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!-), word16be)+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6 4.6. Methods>+newtype MethodAccessFlags =+ MethodAccessFlags+ Word16+ deriving (Eq, Ord, Show)++data MethodAccessFlagsError =+ MethodAccessFlagsUnexpectedEof+ deriving (Eq, Ord, Show)++class AsMethodAccessFlagsUnexpectedEof p f s where+ _MethodAccessFlagsUnexpectedEof :: + Optic' p f s ()++instance (Profunctor p, Functor f) => AsMethodAccessFlagsUnexpectedEof p f MethodAccessFlagsError where+ _MethodAccessFlagsUnexpectedEof =+ iso+ (\_ -> ())+ (\() -> MethodAccessFlagsUnexpectedEof)++methodAccessFlagsUnexpectedEof ::+ AsMethodAccessFlagsUnexpectedEof Tagged Identity t =>+ t+methodAccessFlagsUnexpectedEof =+ _MethodAccessFlagsUnexpectedEof # ()++methodAccessFlags ::+ AsMethodAccessFlagsUnexpectedEof Tagged Identity e =>+ Get e MethodAccessFlags+methodAccessFlags =+ do af <- methodAccessFlagsUnexpectedEof !- word16be+ return (MethodAccessFlags af)
+ src/Language/Java/Class/Methods.hs view
@@ -0,0 +1,136 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE UndecidableInstances #-}++module Language.Java.Class.Methods(+ Methods(..)+, MethodsError(..)+, AsMethodsInfoUnexpectedEof(..)+, methodsInfoUnexpectedEof+, AsMethodsMethodError(..)+, methods+) where++import Control.Applicative(Applicative)+import Control.Category((.))+import Control.Lens(AsEmpty, Cons, Optic', Choice, prism', ( # ), _2)+import Control.Monad(Monad(return))+import Control.Replicate(replicateO)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Nothing, Just))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, (!!-), (!-), word16be)+import Data.Word(Word8, Word16)+import Language.Java.Class.Attribute(AsAttributeNameIndexUnexpectedEof(_AttributeNameIndexUnexpectedEof), AsAttributeLengthUnexpectedEof(_AttributeLengthUnexpectedEof), AsAttributeUnexpectedEof(_AttributeUnexpectedEof), Attribute)+import Language.Java.Class.Method(AsMethodErrorAttributeError(_MethodErrorAttributeError), AsMethodNameIndexUnexpectedEof(_MethodNameIndexUnexpectedEof), AsMethodDescriptorIndexUnexpectedEof(_MethodDescriptorIndexUnexpectedEof), AsMethodAttributeCountUnexpectedEof(_MethodAttributeCountUnexpectedEof), AsMethodAttributeUnexpectedEof(_MethodAttributeUnexpectedEof), AsMethodMethodAccessFlagsError(_MethodMethodAccessFlagsError), Method, MethodError, method)+import Language.Java.Class.MethodAccessFlags(AsMethodAccessFlagsUnexpectedEof(_MethodAccessFlagsUnexpectedEof))+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+data Methods m a s =+ Methods+ Word16+ (s (Method m a))++deriving instance Eq (s (Method m a)) => Eq (Methods m a s)+deriving instance Ord (s (Method m a)) => Ord (Methods m a s)+deriving instance Show (s (Method m a)) => Show (Methods m a s)++data MethodsError =+ MethodsInfoUnexpectedEof+ | MethodsMethodError Word16 MethodError+ deriving (Eq, Ord, Show)++class AsMethodsInfoUnexpectedEof p f s where+ _MethodsInfoUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsMethodsInfoUnexpectedEof p f MethodsError where+ _MethodsInfoUnexpectedEof =+ prism'+ (\() -> MethodsInfoUnexpectedEof)+ (\e -> case e of+ MethodsInfoUnexpectedEof -> Just ()+ _ -> Nothing)++methodsInfoUnexpectedEof ::+ AsMethodsInfoUnexpectedEof Tagged Identity t =>+ t+methodsInfoUnexpectedEof=+ _MethodsInfoUnexpectedEof # ()++class AsMethodsMethodError p f s where+ _MethodsMethodError :: + Optic' p f s (Word16, MethodError)++instance (Choice p, Applicative f) => AsMethodsMethodError p f MethodsError where+ _MethodsMethodError =+ prism'+ (\(w, r) -> MethodsMethodError w r)+ (\e -> case e of+ MethodsMethodError w r -> Just (w, r)+ _ -> Nothing)++instance (p ~ (->), Applicative f) => AsMethodNameIndexUnexpectedEof p f MethodsError where+ _MethodNameIndexUnexpectedEof =+ _MethodsMethodError . _2 . _MethodNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodDescriptorIndexUnexpectedEof p f MethodsError where+ _MethodDescriptorIndexUnexpectedEof =+ _MethodsMethodError . _2 . _MethodDescriptorIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodAttributeCountUnexpectedEof p f MethodsError where+ _MethodAttributeCountUnexpectedEof =+ _MethodsMethodError . _2 . _MethodAttributeCountUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodAttributeUnexpectedEof p f MethodsError where+ _MethodAttributeUnexpectedEof =+ _MethodsMethodError . _2 . _MethodAttributeUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeNameIndexUnexpectedEof p f MethodsError where+ _AttributeNameIndexUnexpectedEof =+ _MethodsMethodError . _2 . _AttributeNameIndexUnexpectedEof++instance (p ~ (->), Applicative f) => AsAttributeLengthUnexpectedEof p f MethodsError where+ _AttributeLengthUnexpectedEof =+ _MethodsMethodError . _2 . _AttributeLengthUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodErrorAttributeError p f MethodsError where+ _MethodErrorAttributeError =+ _MethodsMethodError . _2 . _MethodErrorAttributeError++instance (p ~ (->), Applicative f) => AsAttributeUnexpectedEof p f MethodsError where+ _AttributeUnexpectedEof =+ _MethodsMethodError . _2 . _AttributeUnexpectedEof++instance (p ~ (->), Applicative f) => AsMethodMethodAccessFlagsError p f MethodsError where+ _MethodMethodAccessFlagsError =+ _MethodsMethodError . _2 . _MethodMethodAccessFlagsError++instance (p ~ (->), Applicative f) => AsMethodAccessFlagsUnexpectedEof p f MethodsError where+ _MethodAccessFlagsUnexpectedEof =+ _MethodsMethodError . _2 . _MethodAccessFlagsUnexpectedEof++methods ::+ (AsEmpty (m (Attribute a1)), AsEmpty (a Word8),+ AsEmpty (s (Method m1 a2)),+ Cons+ (m (Attribute a1)) (m (Attribute a1)) (Attribute a) (Attribute a),+ Cons (a Word8) (a Word8) Word8 Word8,+ Cons+ (s (Method m1 a2)) (s (Method m1 a2)) (Method m a1) (Method m a1),+ AsMethodsInfoUnexpectedEof Tagged Identity e,+ AsMethodsMethodError Tagged Identity e) =>+ Get e (Methods m1 a2 s)+methods =+ do c <- methodsInfoUnexpectedEof !- word16be+ i <- (_MethodsMethodError #) !!- replicateO (\n -> ((,) n) !!- method) c+ return (Methods c i)
+ src/Language/Java/Class/SuperClass.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.SuperClass(+ SuperClass(..)+, SuperClassError(..)+, AsSuperClassUnexpectedEof(..)+, superClassUnexpectedEof+, superClass+) where++import Control.Lens(Optic', Profunctor, iso, ( # ))+import Control.Monad(Monad(return))+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle((!-), Get, word16be)+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+newtype SuperClass =+ SuperClass Word16+ deriving (Eq, Ord, Show)++data SuperClassError =+ SuperClassUnexpectedEof+ deriving (Eq, Ord, Show)++class AsSuperClassUnexpectedEof p f s where+ _SuperClassUnexpectedEof :: + Optic' p f s ()++instance (Profunctor p, Functor f) => AsSuperClassUnexpectedEof p f SuperClassError where+ _SuperClassUnexpectedEof =+ iso+ (\_ -> ())+ (\() -> SuperClassUnexpectedEof)++superClassUnexpectedEof ::+ AsSuperClassUnexpectedEof Tagged Identity t =>+ t+superClassUnexpectedEof =+ _SuperClassUnexpectedEof # ()++superClass ::+ AsSuperClassUnexpectedEof Tagged Identity e =>+ Get e SuperClass+superClass =+ do af <- superClassUnexpectedEof !- word16be+ return (SuperClass af)
+ src/Language/Java/Class/ThisAccessFlags.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.ThisAccessFlags(+ ThisAccessFlags(..)+, ThisAccessFlagsError(..)+, AsThisAccessFlagsUnexpectedEof(..)+, thisAccessFlagsUnexpectedEof+, thisAccessFlags+) where++import Control.Lens(Optic', Profunctor, iso, ( # ))+import Control.Monad(return)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, word16be, (!-))+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+newtype ThisAccessFlags =+ ThisAccessFlags Word16+ deriving (Eq, Ord, Show)++data ThisAccessFlagsError =+ ThisAccessFlagsUnexpectedEof+ deriving (Eq, Ord, Show)++class AsThisAccessFlagsUnexpectedEof p f s where+ _ThisAccessFlagsUnexpectedEof :: + Optic' p f s ()++instance (Profunctor p, Functor f) => AsThisAccessFlagsUnexpectedEof p f ThisAccessFlagsError where+ _ThisAccessFlagsUnexpectedEof =+ iso+ (\_ -> ())+ (\() -> ThisAccessFlagsUnexpectedEof)++thisAccessFlagsUnexpectedEof ::+ AsThisAccessFlagsUnexpectedEof Tagged Identity t =>+ t+thisAccessFlagsUnexpectedEof =+ _ThisAccessFlagsUnexpectedEof # ()++thisAccessFlags ::+ AsThisAccessFlagsUnexpectedEof Tagged Identity e =>+ Get e ThisAccessFlags+thisAccessFlags =+ do af <- thisAccessFlagsUnexpectedEof !- word16be+ return (ThisAccessFlags af)
+ src/Language/Java/Class/ThisClass.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.ThisClass(+ ThisClass(..)+, ThisClassError(..)+, AsThisClassUnexpectedEof(..)+, thisClassUnexpectedEof+, thisClass+) where++import Control.Lens(Optic', Profunctor, iso, ( # ))+import Control.Monad(return)+import Data.Eq(Eq)+import Data.Functor(Functor)+import Data.Functor.Identity(Identity)+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, word16be, (!-))+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+newtype ThisClass =+ ThisClass Word16+ deriving (Eq, Ord, Show)++data ThisClassError =+ ThisClassUnexpectedEof+ deriving (Eq, Ord, Show)++class AsThisClassUnexpectedEof p f s where+ _ThisClassUnexpectedEof :: + Optic' p f s ()++instance (Profunctor p, Functor f) => AsThisClassUnexpectedEof p f ThisClassError where+ _ThisClassUnexpectedEof =+ iso+ (\_ -> ())+ (\() -> ThisClassUnexpectedEof)++thisClassUnexpectedEof ::+ AsThisClassUnexpectedEof Tagged Identity t =>+ t+thisClassUnexpectedEof =+ _ThisClassUnexpectedEof # ()++thisClass ::+ AsThisClassUnexpectedEof Tagged Identity e =>+ Get e ThisClass+thisClass =+ do af <- thisClassUnexpectedEof !- word16be+ return (ThisClass af)
+ src/Language/Java/Class/Version.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Language.Java.Class.Version(+ Version(..)+, VersionError(..)+, AsVersionMinorUnexpectedEof(..)+, versionMinorUnexpectedEof+, AsVersionMajorUnexpectedEof(..)+, versionMajorUnexpectedEof+, version+) where++import Control.Applicative(Applicative)+import Control.Lens(Choice, Optic', prism', ( # ))+import Control.Monad(return)+import Data.Eq(Eq)+import Data.Functor.Identity(Identity)+import Data.Maybe(Maybe(Just, Nothing))+import Data.Ord(Ord)+import Data.Tagged(Tagged)+import Data.Tickle(Get, word16be, (!-))+import Data.Word(Word16)+import Prelude(Show)++-- |+--+-- <https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1 4.1. The ClassFile Structure>+data Version =+ Version+ Word16+ Word16+ deriving (Eq, Ord, Show)++data VersionError =+ VersionMinorUnexpectedEof+ | VersionMajorUnexpectedEof+ deriving (Eq, Ord, Show)++class AsVersionMinorUnexpectedEof p f s where+ _VersionMinorUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsVersionMinorUnexpectedEof p f VersionError where+ _VersionMinorUnexpectedEof =+ prism'+ (\() -> VersionMinorUnexpectedEof)+ (\e -> case e of+ VersionMinorUnexpectedEof -> Just ()+ VersionMajorUnexpectedEof -> Nothing)++versionMinorUnexpectedEof ::+ AsVersionMinorUnexpectedEof Tagged Identity t =>+ t+versionMinorUnexpectedEof =+ _VersionMinorUnexpectedEof # ()++class AsVersionMajorUnexpectedEof p f s where+ _VersionMajorUnexpectedEof :: + Optic' p f s ()++instance (Choice p, Applicative f) => AsVersionMajorUnexpectedEof p f VersionError where+ _VersionMajorUnexpectedEof =+ prism'+ (\() -> VersionMajorUnexpectedEof)+ (\e -> case e of+ VersionMinorUnexpectedEof -> Nothing+ VersionMajorUnexpectedEof -> Just ())++versionMajorUnexpectedEof ::+ AsVersionMajorUnexpectedEof Tagged Identity t =>+ t+versionMajorUnexpectedEof =+ _VersionMajorUnexpectedEof # ()++version ::+ (AsVersionMinorUnexpectedEof Tagged Identity e, AsVersionMajorUnexpectedEof Tagged Identity e) => + Get e Version+version =+ do mn <- versionMinorUnexpectedEof !- word16be+ mj <- versionMajorUnexpectedEof !- word16be+ return (Version mn mj)
+ test/doctests.hs view
@@ -0,0 +1,32 @@+module Main where++import Build_doctests (deps)+import Control.Applicative+import Control.Monad+import Data.List+import System.Directory+import System.FilePath+import Test.DocTest++main ::+ IO ()+main =+ getSources >>= \sources -> doctest $+ "-isrc"+ : "-idist/build/autogen"+ : "-optP-include"+ : "-optPdist/build/autogen/cabal_macros.h"+ : "-hide-all-packages"+ : map ("-package="++) deps ++ sources++getSources :: IO [FilePath]+getSources = filter (isSuffixOf ".hs") <$> go "src"+ where+ go dir = do+ (dirs, files) <- getFilesAndDirectories dir+ (files ++) . concat <$> mapM go dirs++getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])+getFilesAndDirectories dir = do+ c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir+ (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
+ todo.md view
@@ -0,0 +1,1 @@+* `ClassFile` function to support both 1.5 and 1.7.