(define impc:ir:compiler:closure-from-getter
(lambda (name)
(if (not (impc:ti:closure-exists? name))
(impc:compiler:print-missing-identifier-error name 'closure)
(let* ((os (make-string 0))
(type (cons (+ *impc:ir:pointer* *impc:ir:pointer* *impc:ir:closure*)
(map (lambda (x) (impc:ir:get-type-from-str x))
(impc:ti:get-closure-arg-types name)))))
(emit (impc:ir:gname "closure" "i8*") " = call i8* @" name "_getter()\n" os)
(emit (string-append (impc:ir:gname "closure" (impc:ir:get-type-str type)) " = bitcast i8* "
(car (impc:ir:gname 1)) " to " (impc:ir:get-type-str type) "\n") os)
(impc:ir:strip-space os)))))