Skip to content

Commit

Permalink
support double literals
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaggers committed Jul 7, 2016
1 parent 33e6e02 commit 528666b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions compiler/compile-literal.lisp
Expand Up @@ -13,9 +13,11 @@

(defun get-number-type (x)
;; [TODO] How should we specify numbers unsigned?
(cond ((floatp x) (type-spec->type 'v-float))
((integerp x) (type-spec->type 'v-int))
(t (error "Varjo: Do not know the type of the number '~s'" x))))
(typecase x
(single-float (type-spec->type 'v-float))
(double-float (type-spec->type 'v-double))
(integer (type-spec->type 'v-int))
(otherwise (error "Varjo: Do not know the type of the number '~s'" x))))

(defun compile-number (code env)
(let ((num-type (get-number-type code))
Expand Down
9 changes: 5 additions & 4 deletions compiler/string-generation.lisp
Expand Up @@ -9,11 +9,12 @@
(string-upcase part)
(string-capitalize part))))))

(defun num-suffix (type)
(or (assocr (type->type-spec type) '((v-double . "lf") (v-float . "f") (v-uint . "u"))) ""))

(defun gen-number-string (number type)
(format nil "~a~a" number (num-suffix type)))
(typecase type
(v-double (format nil "~flf" number))
(v-float (format nil "~ff" number))
(v-uint (format nil "~au" number))
(otherwise (format nil "~a" number))))

(defun gen-variable-string (var-name v-value)
(format nil "~a" (or (v-glsl-name v-value) ()
Expand Down

0 comments on commit 528666b

Please sign in to comment.