(define impc:ir:compiler:math
(let ((fcmps '("fadd" "fsub" "fmul" "fdiv" "frem"))
(icmps '("add" "sub" "mul" "sdiv" "srem")))
(lambda (v ast types . hint?)
;;(println 'types: types)
;;(println 'math: 'ast: ast 'hint: hint?)
(let* ((type-hint (let ((value (assoc-strcmp (cl:find-if symbol? (cdr ast)) types)))
(if value
(cdr value)
(if (null? hint?)
'()
(car hint?)))))
(a (if (null? type-hint)
(impc:ir:compiler (cadr ast) types)
(impc:ir:compiler (cadr ast) types type-hint)))
(aval (impc:ir:gname))
(b (if (null? type-hint) ;; use a to provide hint for b
(impc:ir:compiler (caddr ast) types
(impc:ir:get-type-from-str (cadr (impc:ir:gname))))
(impc:ir:compiler (caddr ast) types type-hint)))
(bval (impc:ir:gname))
(os (make-string 0))
(type (if (null? type-hint)
(cadr aval)
(impc:ir:get-type-str type-hint))))