Class file data structure
This commit is contained in:
parent
88604bf544
commit
580e56ebbb
8
.gitignore
vendored
8
.gitignore
vendored
@ -8,6 +8,12 @@ cabal-dev
|
||||
*.chs.h
|
||||
*.dyn_o
|
||||
*.dyn_hi
|
||||
*.java
|
||||
*.class
|
||||
*.local~*
|
||||
src/Parser/JavaParser.hs
|
||||
src/Parser/Parser.hs
|
||||
src/Parser/Lexer.hs
|
||||
.hpc
|
||||
.hsenv
|
||||
.cabal-sandbox/
|
||||
@ -20,4 +26,4 @@ cabal.sandbox.config
|
||||
cabal.project.local
|
||||
cabal.project.local~
|
||||
.HTF/
|
||||
.ghc.environment.*
|
||||
.ghc.environment.*
|
||||
|
2
questions.md
Normal file
2
questions.md
Normal file
@ -0,0 +1,2 @@
|
||||
# Questions
|
||||
- Enum?
|
62
src/ClassFile.hs
Normal file
62
src/ClassFile.hs
Normal file
@ -0,0 +1,62 @@
|
||||
{-
|
||||
ClassFile {
|
||||
u4 magic;
|
||||
u2 minor_version;
|
||||
u2 major_version;
|
||||
u2 constant_pool_count;
|
||||
cp_info constant_pool[constant_pool_count-1];
|
||||
u2 access_flags;
|
||||
u2 this_class;
|
||||
u2 super_class;
|
||||
u2 interfaces_count;
|
||||
u2 interfaces[interfaces_count];
|
||||
u2 fields_count;
|
||||
field_info fields[fields_count];
|
||||
u2 methods_count;
|
||||
method_info methods[methods_count];
|
||||
u2 attributes_count;
|
||||
attribute_info attributes[attributes_count];
|
||||
}
|
||||
|
||||
method_info {
|
||||
u2 access_flags;
|
||||
u2 name_index;
|
||||
u2 descriptor_index;
|
||||
u2 attributes_count;
|
||||
attribute_info attributes[attributes_count];
|
||||
}
|
||||
-}
|
||||
|
||||
|
||||
import Data.Word
|
||||
import Data.Int
|
||||
|
||||
data ConstantInfo = ClassInfo Word16
|
||||
| FieldRefInfo Word16 Word16
|
||||
| MethodRefInfo Word16 Word16
|
||||
| IntegerInfo Int32
|
||||
| Utf8Info [Char]
|
||||
deriving Show
|
||||
|
||||
data Attribute = Attribute Word16 [Word8] deriving Show
|
||||
|
||||
data MemberInfo = MemberInfo {
|
||||
memberAccessFlags :: Word16,
|
||||
memberNameIndex :: Word16,
|
||||
memberDescriptorIndex :: Word16,
|
||||
memberAttributes :: [Attribute]
|
||||
} deriving Show
|
||||
|
||||
data ClassFile = ClassFile {
|
||||
magic :: Word32,
|
||||
minorVersion :: Word16,
|
||||
majorVersion :: Word16,
|
||||
constantPool :: [ConstantInfo],
|
||||
accessFlags :: Word16,
|
||||
thisClass :: Word16,
|
||||
superClass :: Word16,
|
||||
interfaces :: [Word16],
|
||||
fields :: [MemberInfo],
|
||||
methods :: [MemberInfo],
|
||||
attributes :: [Attribute]
|
||||
} deriving Show
|
Loading…
Reference in New Issue
Block a user