[haskell-llvm] Constructing the array of argument types
Henning Thielemann
lemming at henning-thielemann.de
Thu Nov 22 21:02:17 GMT 2012
On Thu, 22 Nov 2012, José Romildo Malaquias wrote:
> Hello.
>
> The low level LLVM bindings to Haskell (module LLVM.FFI.Core) has the
> function
>
> functionType
> :: TypeRef -- return type
> -> Ptr TypeRef -- array of argument types
> -> CUInt -- number of elements in array
> -> CInt -- non-zero if function is varargs
> -> TypeRef
>
> to create a LLVM function type.
>
> Supposing that my toy compiler uses the following type to represent
> types internally:
>
> data Type = INTEGER | LOGIC
>
> How can a list of formal parameter types reprented as a list of type
>
> [Type]
>
> can be converted to the low level array (expected by the above function)
> of type
>
> Ptr TypeRef
>
> ?
With LLVMIntType you can obtain TypeRefs and with
Foreign.Marshal.Array.withArray you can put them into a temporary C array.
More information about the Haskell-llvm
mailing list