feat[classfile]: stages the entire file
This commit is contained in:
parent
500bfa349e
commit
f309c5f92c
7 changed files with 117 additions and 57 deletions
|
@ -6,21 +6,32 @@
|
|||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE StandaloneKindSignatures #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
module Language.Java.Classfile.Fields (Fields(..)) where
|
||||
import Data.Array.IArray (Array)
|
||||
import Data.Word (Word16)
|
||||
import Language.Java.Classfile.Extractable (Extractable)
|
||||
import GHC.Generics ( Generically, Generic, Generically(..) )
|
||||
import Language.Java.Classfile.Flags (Flags, FlagMask (..))
|
||||
import Language.Java.Classfile.ConstantPool.References (Utf8Reference)
|
||||
import Language.Java.Classfile.ConstantPool.References (Utf8)
|
||||
import Language.Java.Classfile.Attributes (Attributes)
|
||||
import Pretty.Serialize (PrettySerialize)
|
||||
import Language.Java.Classfile.Stage (Stage)
|
||||
import Data.Kind (Type)
|
||||
import Data.Typeable (Typeable)
|
||||
|
||||
-- | Word16-Array of Fields.
|
||||
|
||||
newtype Fields = Fields (Array Word16 Field)
|
||||
deriving stock Show
|
||||
deriving newtype (Extractable, PrettySerialize)
|
||||
type Fields :: Stage -> Type
|
||||
newtype Fields stage = Fields (Array Word16 (Field stage))
|
||||
|
||||
deriving stock instance (Show (Field stage)) => Show (Fields stage)
|
||||
deriving newtype instance (Typeable stage, Extractable (Utf8 stage), Extractable (Attributes stage)) => Extractable (Fields stage)
|
||||
deriving newtype instance (Typeable stage, PrettySerialize (Utf8 stage), PrettySerialize (Attributes stage)) => PrettySerialize (Fields stage)
|
||||
|
||||
-- | All the access flags a field can have
|
||||
|
||||
|
@ -53,11 +64,15 @@ instance FlagMask FieldFlag where
|
|||
|
||||
-- | A singular field of a class.
|
||||
|
||||
data Field = Field
|
||||
type Field :: Stage -> Type
|
||||
data Field stage = Field
|
||||
{ flags :: Flags FieldFlag
|
||||
, name :: Utf8Reference
|
||||
, descriptor :: Utf8Reference
|
||||
, attribute :: Attributes
|
||||
, name :: Utf8 stage
|
||||
, descriptor :: Utf8 stage
|
||||
, attribute :: Attributes stage
|
||||
}
|
||||
deriving stock (Show, Generic)
|
||||
deriving (Extractable, PrettySerialize) via Generically Field
|
||||
deriving stock (Generic)
|
||||
|
||||
deriving stock instance (Show (Utf8 stage), Show (Attributes stage)) => Show (Field stage)
|
||||
deriving via Generically (Field stage) instance (Extractable (Utf8 stage), Extractable (Attributes stage)) => Extractable (Field stage)
|
||||
deriving via Generically (Field stage) instance (PrettySerialize (Utf8 stage), PrettySerialize (Attributes stage)) => PrettySerialize (Field stage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue