;; adds ##gnum's to all poly types
(define impc:ti:nativef-generics-make-gtypes-unique
(lambda (pt gnum)
(cond ((null? pt) '())
((symbol? pt)
;; (println 'bingo pt)
(cond ((regex:match? (symbol->string pt) "^!") ;; check for !head and !head%b
(let ((kk (string->symbol (string-append (symbol->string pt) "##" (number->string gnum)))))
;; (println 'pt1: pt 'kk: kk)
kk))
;; check for xlist*
((or (if (and (regex:match? (symbol->string pt) "(:|{)")
(assoc-strcmp (string->symbol (car (impc:ti:split-namedtype pt)))
*impc:ti:generictype-cache*))
#t #f)
(assoc-strcmp (string->symbol (impc:ir:get-base-type (symbol->string pt)))
*impc:ti:generictype-cache*))
(let ((kk (string->symbol (string-append (symbol->string pt) "##" (number->string gnum)))))
;; (println 'pt2: pt 'kk: kk)
kk))
;; check for xlist%b*
((and (string-contains? (symbol->string pt) "%") ;; check for
(assoc-strcmp (string->symbol (impc:ir:get-base-type (car (regex:split (symbol->string pt) "%")))) *impc:ti:generictype-cache*))
(let ((kk (string->symbol (string-append (symbol->string pt) "##" (number->string gnum)))))
;; (println 'pt3: pt 'kk: kk)
kk))
(else
;; (println 'pt: pt 'kk: pt)
pt)))
((pair? pt)
(cons (impc:ti:nativef-generics-make-gtypes-unique (car pt) gnum)
(impc:ti:nativef-generics-make-gtypes-unique (cdr pt) gnum)))
(else pt))))