impc:ti:minimize-gen-type-finalize-x   scheme


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

Implementation

(define impc:ti:minimize-gen-type-finalize-x
  (lambda (typevars lst)
    ;; (println 'finalize: lst)
    (let* ((newl1 (car lst))
           (newl2 (cdr lst))
           (mem '())
           (res (map (lambda (x y)
                       ;; (println 'x x 'y y)
                       (if (member x mem)
                           #f
                           (if (equal? x y)
                               #f
                               (begin
                                 (set! mem (cons x mem))
                                 y))))
                     newl1
                     newl2))
           (ret (cl:remove-if (lambda (x) (not x)) res))
           (chk1 (if (> (length typevars) (length ret))
                     (begin (set! typevars (cl:remove-duplicates typevars))
                            #f)
                     #t))
           (errchk (if (<> (length ret) (length typevars))
                       (begin (impc:compiler:print-compiler-error "Type Vars and Ret should be same length in Minimize Finalize X"
                                                                  (list ret typevars))
                              #f)
                       #t))
           (pairs (map (lambda (x y) (cons x y)) ret typevars))
           (ps (cl:remove-duplicates pairs))
           (result (map (lambda (p) (car p)) ps)))
      ;; (println '>> 'new1 newl1 'new2 newl2 'res res 'mem mem 'ret ret 'typevars typevars 'result result)
      (if (null? result)
          result
          (map (lambda (x) (impc:ir:pretty-print-type x)) result)))))


Back to Index