go-llvm/llgo — pull request #131 by axw (2014-04-03 03:11:40+00:00)
Title: Implement closures

- Functions are still passed around as *i8, but they are now stored as **i8 and loaded before called. This mimics gccgo, which passes functions around as *__go_descriptor. Global functions are special cased to avoid the unnecessary load from global.
- MakeClosure is implemented, which simply allocates a structure {fnptr, binding1, binding2...} and stores the function and bindings within.
- Before calls to non-global functions, llgo emits a call to __go_set_closure with the **i8 value. This is ignored by non-closure functions.
- Functions with free vars (i.e. closures) make a call to __go_get_closure and extract bindings from within.