impc:ti:closure-call-check   scheme


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

Implementation

;; whenever a closure is called we calculate a type for it
;; at the end these possibly multiple views should unify!
(define impc:ti:closure-call-check
  (lambda (ast vars kts request?)
    ;; (println 'cchint 'ast: ast 'vars: vars 'request: request?)
    ;; otherwise we need to try to find a type definition for the closure
    (let* ((ctype (if (assoc-strcmp (car ast) vars)
                      (cdr (assoc-strcmp (car ast) vars))
                      (if (impc:ti:closure-exists? (symbol->string (car ast)))
                          (list (impc:ti:get-closure-type (symbol->string (car ast))))
                          ;; check for globalvar closures
                          (if (and (impc:ti:globalvar-exists? (symbol->string (car ast)))
                                   (impc:ir:closure? (impc:ti:get-globalvar-type (symbol->string (car ast)))))
                              (list (impc:ti:get-globalvar-type (symbol->string (car ast))))
                              (impc:compiler:print-missing-identifier-error (car ast) 'closure)))))
           ;; (llllllll (println 'ctype: ctype))
           ;; get argument expression types
           (res (map (lambda (e t)
                       ;; (println 'e: e 't: t)
                       (let ((res (impc:ti:type-check e vars kts
                                                      (if (symbol? t)
                                                          (impc:ti:symbol-check t vars kts #f)
                                                          t))))
                         ;; if t is a symbol then add res to t
                         (if (and (not (null? res))
                                  (symbol? t))
                             (if (or (and (list? res)
                                          (impc:ir:type? (car res)))
                                     (impc:ir:type? res))
                                 (impc:ti:force-var t vars kts res)
                                        ;(impc:ti:update-var t vars kts res)
                                 (impc:ti:update-var t vars kts res)))
                                        ;(if (symbol? t) (impc:ti:update-var t vars kts res))


Back to Index