;; ret-> (return statement)
(define impc:ir:compiler:ret
(lambda (ast types . hint?)
;; (println 'ast: ast)
;; (println 'types: types)
;; (println 'hint?: hint?)
;; (println 'ping: (assoc-strcmp (caddr ast) types))
;; (println 'return-> (cadr (assoc-strcmp (cadr ast) types)))
(let* ((hinttype? (cadr (cdr (assoc-strcmp (cadr ast) types))))
(str (impc:ir:compiler (caddr ast) types hinttype?)) ;(if (null? hint?) hinttype? (car hint?))))
(val (impc:ir:gname))
(os (make-string 0)))
(emit str os)
(if (impc:ir:void? (cadr (impc:ir:gname)))
(emit "ret void\n" os)
(let ((type (cadr (cdr (assoc-strcmp (cadr ast) types)))))
;(println 'type: type)
(if (and (not (equal? (impc:ir:get-type-from-str (cadr (impc:ir:gname))) type))
(not (equal? (cadr ast) (caddr ast)))) ;; this line is a weird catch for outer let??
(emit (impc:ir:gname "retval" (impc:ir:get-type-str type)) " = bitcast " (cadr val) " " (car val) " to " (impc:ir:get-type-str type) "\n" os))
(emit "ret " (cadr (impc:ir:gname)) " " (car (impc:ir:gname)) "\n" os)))
;;(println 'os2: os)
(impc:ir:strip-space os))))