h2jvm
Safe HaskellNone
LanguageGHC2021

H2JVM.Builder

Description

Provides a monadic interface for building class files in a high-level format.

Synopsis

Documentation

data ClassBuilder (m :: k) a Source #

The class builder effect for constructing a ClassFile statefully.

Instances

Instances details
type DispatchOf (ClassBuilder :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in H2JVM.Builder

type DispatchOf (ClassBuilder :: (Type -> Type) -> Type -> Type) = 'Dynamic

addAccessFlag :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => ClassAccessFlag -> Eff r () Source #

Add an access flag modifier to the class being built.

setName :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => QualifiedClassName -> Eff r () Source #

Set the fully qualified name of the class being built.

getName :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => Eff r QualifiedClassName Source #

Retrieve the current fully qualified name of the class being built.

setVersion :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => JVMVersion -> Eff r () Source #

Set the target JVM version of the class being built.

setSuperClass :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => QualifiedClassName -> Eff r () Source #

Set the superclass name of the class being built.

addInterface :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => QualifiedClassName -> Eff r () Source #

Add an implemented interface to the class being built.

addField :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => ClassFileField -> Eff r () Source #

Add a field definition to the class being built.

addMethod :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => ClassFileMethod -> Eff r () Source #

Add a method definition to the class being built.

addMethodWithCode :: forall (r :: [Effect]) a. ((ClassBuilder :: (Type -> Type) -> Type -> Type) :> r, Error StackMapError :> r, HasCallStack) => Text -> [MethodAccessFlag] -> MethodDescriptor -> Eff ((CodeBuilder :: (Type -> Type) -> Type -> Type) ': r) a -> Eff r a Source #

Add a method definition to the class being built, whose body is the result of some CodeBuilder monad. This is essentially a convenience function to: 1. Run the CodeBuilder 2. Calculate the StackMapTable etc. 3. Setup the ClassFileMethod and CodeAttributeData 4. Add the method to this ClassBuilder.

addMethodWithCode_ :: forall (r :: [Effect]) a. ((ClassBuilder :: (Type -> Type) -> Type -> Type) :> r, Error StackMapError :> r, HasCallStack) => Text -> [MethodAccessFlag] -> MethodDescriptor -> Eff ((CodeBuilder :: (Type -> Type) -> Type -> Type) ': r) a -> Eff r () Source #

Like addMethodWithCode, but ignoring the result of the function.

addAttribute :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => ClassFileAttribute -> Eff r () Source #

Add a class file attribute to the class being built.

addBootstrapMethod :: forall (r :: [Effect]). (ClassBuilder :: (Type -> Type) -> Type -> Type) :> r => BootstrapMethod -> Eff r () Source #

Add a bootstrap method for invokedynamic calls.

runClassBuilder :: forall (r :: [(Type -> Type) -> Type -> Type]) a. QualifiedClassName -> JVMVersion -> Eff ((ClassBuilder :: (Type -> Type) -> Type -> Type) ': r) a -> Eff r (ClassFile, a) Source #

Run a class builder effect, returning the completed ClassFile along with the result of the action Any unset attributes in the class will be mempty or equivalent, except name and version which must be present.