java-classfile/src/Language/Java/Classfile/Attributes.hs
2025-07-13 11:54:33 +02:00

29 lines
1,022 B
Haskell

-- | Attributes that can be attached to a lot of things in classfiles.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DeriveGeneric #-}
module Language.Java.Classfile.Attributes (Attributes(..), Attribute(..)) where
import Data.Array.IArray (Array)
import Data.Word (Word16, Word32)
import Language.Java.Classfile.Extractable (Extractable)
import Language.Java.Classfile.ConstantPool.References (Utf8Reference)
import Language.Java.Classfile.Extractable.SizedBytes (SizedBytes)
import GHC.Generics ( Generic, Generically(..) )
-- | Generic Attribute array used everywhere.
--
-- Will not respect Attribute location restrictions, does not attempt to parse anything specific.
newtype Attributes = Attributes (Array Word16 Attribute)
deriving stock (Show)
deriving newtype Extractable
-- | Unknown Attribute
data Attribute = Attribute
{ name :: Utf8Reference
, info :: SizedBytes Word32
}
deriving stock (Show, Generic)
deriving Extractable via Generically Attribute