impc:ti:nativef-poly-exact-check   scheme


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

Implementation

(define impc:ti:nativef-poly-exact-check
  (lambda (ast vars kts request?)
    ;; (println 'nateivef-poly-exact: ast 'req: request?)
    (if (or (null? request?)
            (regex:match? (sexpr->string request?) "(!|(##))"))  ;; must be generic - exit!
        #f
        (let* ((polyf (string->symbol (car (regex:split (symbol->string (car ast)) "##")))) ;"\\$\\$\\$"))))
               (ftypes (impc:ti:get-polyfunc-candidate-types (symbol->string polyf)))
               (asttype (cons 213 (cons request? (map (lambda (a)
                                                        (impc:ti:type-unify (impc:ti:type-check a vars kts #f) vars))
                                                      (cdr ast))))))
          (if (not ftypes)
              #f
              (begin
                ;; if no return type is ever required
                ;; then we can ignore it for our checks
                (if (and (list? request?)
                         (equal? *impc:ir:notype* (car request?)))
                    (for-each (lambda (ft)
                                (if (equal? (cddr asttype) (cddr ft))
                                    (set! asttype ft)))
                              ftypes))
                (if (and (list? ftypes)
                         (member asttype ftypes))
                    (begin
                      ;; (println 'force-poly (car ast) 'to (list asttype))
                      ;; if exact poly should we force var??
                      (impc:ti:force-var (car ast) vars kts (list asttype))
                      #t)
                    #f)))))))


Back to Index