impc:ti:check-bang-against-reified   scheme


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

Implementation

;; try to find a type for a !bang from a reified type
;;
;; example use is in impc:ti:sym-unify
(define impc:ti:check-bang-against-reified
  (lambda (bang-sym reified-sym vars)
    (let ((r (assoc-strcmp reified-sym vars)))
      (if (null? r)
          #f
          (let* ((gtd (impc:ti:generic-type-details reified-sym))
                 (gtd2 (impc:ti:generic-type-details bang-sym))
                 (type (cdr r))
                 (gtype (cadddr gtd))
                 (pos (cl:position (car gtd2) gtype)))
            (if (and type pos (list? (car type)) (> (length (car type)) pos))
                (let ((val (list-ref (car type) pos)))
                  val)
                (if (regex:match? (symbol->string (car r)) "^!g(.*)_.*##([0-9]*)$")
                    (let ((l1 (regex:matched (symbol->string bang-sym) "^!g(.*)_.*##([0-9]*)$"))
                          (l2 (regex:matched (symbol->string reified-sym) "^!g(.*)_.*##([0-9]*)$")))
                      (if (and (= (length l1) (length l2))
                               (> (length l1) 2)
                               (and (string=? (cadr l1) (cadr l2))
                                    (string=? (caddr l1) (caddr l2))))
                          type
                          #f))
                    #f)))))))


Back to Index