impc:ir:compiler:cmp   scheme


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

Implementation

(define impc:ir:compiler:cmp
  (let ((fcmps '("ugt" "ult" "une" "ueq"))
                                        ;(fcmps '("ogt" "olt" "one" "oeq"))
        (icmps '("sgt" "slt" "ne" "eq")))
    (lambda (v ast types . hint?)
                                        ;(println 'types: types)
      (let* ((type-hint (let ((value (assoc-strcmp (cl:find-if symbol? (cdr ast)) types)))
                          (if value
                              (cdr value)
                              (if (null? hint?)
                                  '()
                                  (car hint?)))))
             (a (impc:ir:compiler (cadr ast) types))
             (aval (impc:ir:gname))
             (t (impc:ir:get-type-from-str (cadr aval)))
             (b (impc:ir:compiler (caddr ast) types t))
             (bval (impc:ir:gname))
             (os (make-string 0))
             (type (cadr aval)))
        ;; sanity checks
        (if (not (or (and (impc:ir:number? (cadr aval))
                          (impc:ir:number? (cadr bval)))
                     (and (impc:ir:pointer? (cadr aval))
                          (impc:ir:pointer? (cadr bval)))
                     (and (impc:ir:vector? (cadr aval))
                          (impc:ir:vector? (cadr bval)))))
            (impc:compiler:print-type-conflict-error (cadr aval) (cadr bval) ast))


Back to Index

Similar Entries