impc:ir:compiler:ifret   scheme


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

Implementation

;; if that finishes with ret clauses (i.e. doesn't return a value)
(define impc:ir:compiler:ifret
  (lambda (ast types)
    (let* ((os (make-string 0))
           (elset (if (null? (cdddr ast)) #f #t))
           (num (number->string (llvm:count++))))
                                        ;(println 'ifretast: ast)
      ;; first do compare expression
      (emit (impc:ir:compiler (cadr ast) types) os)
      ;; then break on compare
      (emit (string-append "br i1 " (car (impc:ir:gname)) ", label %then" num ", "
                           (if elset "label %else" "label %then")
                           num "\n") os)
      ;; do then
      (emit  "\nthen" num ":\n" os)
      (emit (impc:ir:compiler (caddr ast) types) os)


Back to Index