impc:ti:type-check-bound-lambda   scheme


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

Implementation

;; this is here for whenever we get
;; new 'argument' information about
;; a locally bound lambda which might help
;; us to derive new return type information
(define impc:ti:type-check-bound-lambda
  (lambda (sym vars kts t)
    (if (not (assoc-strcmp sym *impc:ti:bound-lambdas*))
        #f
        (let* ((f (cadr (assoc-strcmp sym *impc:ti:bound-lambdas*)))
               (args (cadr f))
               (body (caddr f))
               (estr (sexpr->string body))
               (recursive? (regex:match? estr (string-append "(" "\\(\\s*" (symbol->string sym) "\\s" ")|(\\(\\s*callback)")))
               (rettype '()))
          (if (not recursive?)
              (begin
                (if (not (null? t))
                    (for-each (lambda (x y)
                                ;; (println 'lambda 'x: x 'y: y)
                                (impc:ti:update-var x vars kts y))
                              args (cddr t)))
                (set! rettype (impc:ti:type-check (caddr (cadr (assoc-strcmp sym *impc:ti:bound-lambdas*)))
                                                  vars kts #f))
                (if (null? t)
                    (let ((argtypes (map (lambda (x)
                                           (cadr (assoc-strcmp x vars)))
                                         args)))
                      ;; (println 'update: sym 'with (cons 213 (cons (car rettype) argtypes)))
                      (impc:ti:update-var sym vars kts (cons 213 (cons(car rettype) argtypes)))))
                (if (impc:ir:type? rettype)
                    rettype
                    #f)))))))


Back to Index