allocNewArray cls =
i1 ANEWARRAY (CClass cls)
-invokeVirtual :: Generator e g => B.ByteString -> NameType Method -> g e ()
+invokeVirtual :: Generator e g => B.ByteString -> NameType (Method Direct) -> g e ()
invokeVirtual cls sig =
i1 INVOKEVIRTUAL (CMethod cls sig)
-invokeStatic :: Generator e g => B.ByteString -> NameType Method -> g e ()
+invokeStatic :: Generator e g => B.ByteString -> NameType (Method Direct) -> g e ()
invokeStatic cls sig =
i1 INVOKESTATIC (CMethod cls sig)
-invokeSpecial :: Generator e g => B.ByteString -> NameType Method -> g e ()
+invokeSpecial :: Generator e g => B.ByteString -> NameType (Method Direct) -> g e ()
invokeSpecial cls sig =
i1 INVOKESPECIAL (CMethod cls sig)
-getStaticField :: Generator e g => B.ByteString -> NameType Field -> g e ()
+getStaticField :: Generator e g => B.ByteString -> NameType (Field Direct) -> g e ()
getStaticField cls sig =
i1 GETSTATIC (CField cls sig)
-> [ArgumentSignature] -- ^ Signatures of method arguments
-> ReturnSignature -- ^ Method return signature
-> g e () -- ^ Generator for method code
- -> g e (NameType Method)
+ -> g e (NameType (Method Direct))
newMethod flags name args ret gen = do
let sig = MethodSignature args ret
startMethod flags name sig
-- | Get class field signature from current ClassPath
getClassField :: (Throws ENotFound e, Throws ENotLoaded e)
- => String -> B.ByteString -> GenerateIO e (NameType Field)
+ => String -> B.ByteString -> GenerateIO e (NameType (Field Direct))
getClassField clsName fldName = do
cls <- getClass clsName
case lookupField fldName cls of
-- | Get class method signature from current ClassPath
getClassMethod :: (Throws ENotFound e, Throws ENotLoaded e)
- => String -> B.ByteString -> GenerateIO e (NameType Method)
+ => String -> B.ByteString -> GenerateIO e (NameType (Method Direct))
getClassMethod clsName mName = do
cls <- getClass clsName
case lookupMethod mName cls of
=> HasSignature a where
type Signature a
-instance HasSignature Field where
- type Signature Field = FieldSignature
+instance HasSignature (Field Direct) where
+ type Signature (Field Direct) = FieldSignature
-instance HasSignature Method where
- type Signature Method = MethodSignature
+instance HasSignature (Method Direct) where
+ type Signature (Method Direct) = MethodSignature
-- | Name and signature pair. Used for methods and fields.
data NameType a = NameType {
-- | Constant pool item
data Constant stage =
CClass (Link stage B.ByteString)
- | CField (Link stage B.ByteString) (Link stage (NameType Field))
- | CMethod (Link stage B.ByteString) (Link stage (NameType Method))
- | CIfaceMethod (Link stage B.ByteString) (Link stage (NameType Method))
+ | CField (Link stage B.ByteString) (Link stage (NameType (Field stage)))
+ | CMethod (Link stage B.ByteString) (Link stage (NameType (Method stage)))
+ | CIfaceMethod (Link stage B.ByteString) (Link stage (NameType (Method stage)))
| CString (Link stage B.ByteString)
| CInteger Word32
| CFloat Float
| fieldName f == name = Just f
| otherwise = look fs
-fieldNameType :: Field Direct -> NameType Field
+fieldNameType :: Field Direct -> NameType (Field Direct)
fieldNameType f = NameType (fieldName f) (fieldSignature f)
instance Binary (Field File) where
deriving instance Show (Method File)
deriving instance Show (Method Direct)
-methodNameType :: Method Direct -> NameType Method
+methodNameType :: Method Direct -> NameType (Method Direct)
methodNameType m = NameType (methodName m) (methodSignature m)
lookupMethod :: B.ByteString -> Class Direct -> Maybe (Method Direct)
printStreamClass :: FieldType
printStreamClass = ObjectType printStream
-println :: NameType Method
+println :: NameType (Method Direct)
println = NameType "println" $ MethodSignature [Java.Lang.stringClass] ReturnsVoid
-out :: NameType Field
+out :: NameType (Field Direct)
out = NameType "out" printStreamClass
-printf :: NameType Method
+printf :: NameType (Method Direct)
printf =
NameType "printf" $ MethodSignature [Java.Lang.stringClass,
Array Nothing Java.Lang.objectClass] (Returns printStreamClass)
system = "java/lang/System"
-- | java.lang.Object.<init>() method
-objectInit :: NameType Method
+objectInit :: NameType (Method Direct)
objectInit = NameType "<init>" $ MethodSignature [] ReturnsVoid
-- | java.lang.Integer.valueOf() method
-valueOfInteger :: NameType Method
+valueOfInteger :: NameType (Method Direct)
valueOfInteger = NameType "valueOf" $ MethodSignature [IntType] (Returns Java.Lang.integerClass)