[haskell-llvm] Constructing the array of argument types
Nathan Howell
nathan.d.howell at gmail.com
Thu Nov 22 21:07:16 GMT 2012
Err, no (map typeRef) required, since [Type] == [FFI.TypeRef]
On Thu, Nov 22, 2012 at 1:04 PM, Nathan Howell <nathan.d.howell at gmail.com>wrote:
> Foreign.Marshal.Array.withArrayLen can be used, so given a (xs :: [Type])
> you can get a [TypeRef] and then convert it to a native C array like so:
>
> fty <- withArrayLen (map typeRef xs) $ \ argsLen argsPtr -> return $
> functionType retTy argsPtr argsLen 0
>
>
>
> On Thu, Nov 22, 2012 at 12:28 PM, José Romildo Malaquias <
> j.romildo at gmail.com> 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
>>
>> ?
>>
>> Romildo
>>
>> _______________________________________________
>> Haskell-llvm mailing list
>> Haskell-llvm at projects.haskell.org
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-llvm
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/haskell-llvm/attachments/20121122/ff7f0a42/attachment.htm>
More information about the Haskell-llvm
mailing list