impc:ti:get-expression-type   scheme


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

Implementation

(define impc:ti:get-expression-type
  (lambda (ast)
    (let* ((symname 'nosuchname)
           (c `(let ((xtm_exp_result ,ast)) xtm_exp_result))
           (shadows (impc:ti:rename-all-shadow-vars symname c '()))
           (c1 (impc:ti:get-var-types shadows)) ;; this is a cons pairof (ast . types)
           (ta (impc:ti:first-transform (car c1) #t)) ;; car is ast
           (shadow-code (impc:ti:rename-all-shadow-vars symname ta '()))
           (c2 (impc:ti:get-var-types shadow-code))
           (ccc (append (cdr c2) (cdr c1)))
           (cc (impc:ti:expand-generic-types ccc))
           (t1 (car c2))
           (t2 (impc:ti:closure:convert t1 (list))) ;(list symname)))
           (vars (map (lambda (x) (list x)) (impc:ti:find-all-vars t2 '())))
           (forced-types '()) ;(apply impc:ti:handle-forced-types t1 (append cc args)))
           (t4 (impc:ti:coercion-run t2 forced-types)) ;; t4 and t5 are optional
           (typespre (impc:ti:run-type-check vars forced-types t1))
           (t5 (impc:ti:closure:convert t4 (list symname)))
           (types (impc:ti:type-normalize typespre)))
      (cdr (assoc 'xtm_exp_result types)))))


Back to Index