feat: interface list
This commit is contained in:
parent
10ca143163
commit
62b537a93f
5 changed files with 45 additions and 8 deletions
|
@ -1,11 +1,20 @@
|
|||
{-# LANGUAGE DerivingStrategies #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
module Language.Java.Classfile.ConstantPool (ConstantPool(..)) where
|
||||
import Data.Word (Word16)
|
||||
import Data.Array.IArray (Array)
|
||||
import Data.Array.IArray (Array, listArray)
|
||||
import Language.Java.Classfile.ConstantPool.Entry (Entry)
|
||||
import Language.Java.Classfile.Extractable (Extractable)
|
||||
import Language.Java.Classfile.Extractable (Extractable (extract))
|
||||
import Language.Java.Classfile.Extract (Extract, traceIndex)
|
||||
import Control.Monad (forM)
|
||||
|
||||
newtype ConstantPool = ConstantPool (Array Word16 Entry)
|
||||
deriving stock (Show)
|
||||
deriving newtype Extractable
|
||||
|
||||
instance Extractable ConstantPool where
|
||||
extract :: Extract ConstantPool
|
||||
extract = do
|
||||
count <- extract @Word16
|
||||
elements <- forM [1..fromIntegral count - 1] $ \ i -> traceIndex i extract
|
||||
pure . ConstantPool $ listArray (1, count - 1) elements
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue