impc:ir:compile:make-closure   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmir.xtm

Implementation

(define impc:ir:compile:make-closure
  (lambda (ast types)
    ;;(println 'ast: ast)
    (let* ((os (make-string 0))
           (name (list-ref ast 2))
           (allocate-mem? (list-ref ast 1))
           (rettype (list-ref ast 3))
           (result '())
           (env (list-ref ast 4))
           (args (list-ref ast 5))
           (code (list-ref ast 6)))
      ;;(println 'making-closure--------------------------------------> )
      ;;(println 'name: name)
      ;;(println 'allocate: allocate-mem?)
      ;;(println 'rettype: rettype)
      ;;(println 'env: env)
      ;;(println 'args: args)
      ;;(println 'code: code)
      ;; first we make the function code
      ;; define fastcc function with return type
      (emit  "define dllexport fastcc " (impc:ir:get-type-str rettype) " @" name "(" os)
                                        ;(if (not (null? env)) (emit "i8* %_impenv" os))
      (emit "i8* %_impz," os)
      (emit "i8* %_impenv" os)
      (if (not (null? args)) (emit  ", " (impc:ir:make-arglist-str args #t) os))
      ;; close off function opening
      (emit ") nounwind {\n" os)
      (emit "entry:\n" os)
      ;;(emit "; setup zone\n" os)
      ;;(emit "%_zone = bitcast i8* %_impz to %mzone*\n" os)


Back to Index

Similar Entries