impc:ti:variable-substitution   scheme


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

Implementation

(define impc:ti:variable-substitution
  (lambda (type t1 t2 gnum vars kts)
    ;; (println 'variable-sub-in type)
    (let ((pairs (impc:ti:variable-substitution-pairs t1 t2))
          (newtype (sexpr->string type)))
      (for-each (lambda (x)
                  ;; (println 'updatevar:
                  ;;          (string->symbol (string-append (car x) "##" (number->string gnum)))
                  ;;          'with:
                  ;;          (impc:ir:get-type-from-pretty-str (cdr x)))
                  (impc:ti:update-var (string->symbol (string-append (car x) "##" (number->string gnum)))
                                      vars kts (list (impc:ir:get-type-from-pretty-str (cdr x))))
                  ;; (println 'x x (impc:ir:get-type-from-pretty-str (cdr x)))
                  (if (impc:ir:type? (impc:ir:get-type-from-pretty-str (cdr x)))
                      (set! newtype (regex:replace-all newtype
                                                       (string-append (car x) "##" (number->string gnum))
                                                       (if (string? (impc:ir:get-type-from-pretty-str (cdr x)))
                                                           (string-append "\""
                                                                          (impc:ir:get-type-from-pretty-str (cdr x))
                                                                          "\"")
                                                           (sexpr->string (impc:ir:get-type-from-pretty-str (cdr x))))))
                      (set! newtype (regex:replace-all newtype (car x) (cdr x)))))
                pairs)
      ;; (if (not (null? pairs)) (println 'newt: newtype (impc:ir:type? newtype)))
      ;; (println 'variable-sub-out (string->sexpr newtype))
      (string->sexpr newtype))))


Back to Index

Similar Entries