[haskell-llvm] Beginner - Anonymous Functions

Henning Thielemann lemming at henning-thielemann.de
Wed Nov 16 14:40:00 GMT 2011


On Wed, 16 Nov 2011, Elliott Pace wrote:

> Thanks for the pointer in the right direction. I had a think and realised I was going
> about it completely the wrong way.
> 
> My current attempt (at sum x y z = x + y + z) is that:
> 
> A function value is a pointer to a pair of pointers. One pointer being the code to
> execute and one pointer being the head of a linked list of arguments which will then be
> walked when the body is finally evaluted (here at sum3).
> 
> Here is my attempt:
> 
> http://paste.ubuntu.com/740212/

Btw. you can assist me and you understanding the code by adding type 
signatures to the createFunction calls. You may even make them top-level 
functions.

What I see is, that alloc2 returns a pointer to a number, that is, sum1' 
must be a pointer to a number. Then you try to 'call' this pointer like a 
function:

69      sum1' <- alloc2 sum1 nullptr

71      sum2' <- call' sum1' x



More information about the Haskell-llvm mailing list