impc:ti:dotimes-check   scheme


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

Implementation

(define impc:ti:dotimes-check
  (lambda (ast vars kts request?)
    (let ((a (impc:ti:type-check (car (cadr ast)) vars kts #f))
          (b (impc:ti:type-check (cadr (cadr ast)) vars kts #f)))
      (if (and (not (impc:ir:type? b))
               (= (length b) 1))
          (set! b (car b)))
      (if (and (not (impc:ir:type? a))
               (= (length a) 1))
          (set! a (car a)))
      (if (and (impc:ir:type? a)
               (list? b)
               (member a b))
          (set! b a))
      ;; (car (cadr ast)) should be a symbol that we want to update with a
      (if (not (symbol? (car (cadr ast))))
          (impc:compiler:print-badly-formed-expression-error 'dotimes ast))
      (impc:ti:update-var (car (cadr ast)) vars kts b)
      (if (and (symbol? (cadr (cadr ast)))
               (impc:ir:type? a))
          (impc:ti:update-var (cadr (cadr ast)) vars kts a))
      ;; check over body code but don't worry about return types
      (impc:ti:type-check (caddr ast) vars kts #f)
      ;; dotimes returns void
      (list *impc:ir:void*))))


Back to Index