codegen: make closures work with function pointers