mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 00:07:36 +02:00
Issue #112 - Compilation of nan/inf
This commit is contained in:
parent
7b1e3ce5f7
commit
b1ca2627d1
1 changed files with 10 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
(define-library (scheme cyclone cgen)
|
(define-library (scheme cyclone cgen)
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme char)
|
(scheme char)
|
||||||
|
(scheme inexact)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
(scheme cyclone primitives)
|
(scheme cyclone primitives)
|
||||||
(scheme cyclone transforms)
|
(scheme cyclone transforms)
|
||||||
|
@ -472,12 +473,19 @@
|
||||||
(c-code (string-append "obj_int2obj("
|
(c-code (string-append "obj_int2obj("
|
||||||
(number->string exp) ")")))
|
(number->string exp) ")")))
|
||||||
((real? exp)
|
((real? exp)
|
||||||
(let ((cvar-name (mangle (gensym 'c))))
|
(let ((cvar-name (mangle (gensym 'c)))
|
||||||
|
(num2str (cond
|
||||||
|
;; The following two may not be very portable,
|
||||||
|
;; may be better to use C99:
|
||||||
|
((nan? exp) "(0./0.)")
|
||||||
|
((infinite? exp) "(1./0.)")
|
||||||
|
(else
|
||||||
|
(number->string exp)))))
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
(string-append "&" cvar-name) ; Code is just the variable name
|
(string-append "&" cvar-name) ; Code is just the variable name
|
||||||
(list ; Allocate on the C stack
|
(list ; Allocate on the C stack
|
||||||
(string-append
|
(string-append
|
||||||
"make_double(" cvar-name ", " (number->string exp) ");")))))
|
"make_double(" cvar-name ", " num2str ");")))))
|
||||||
((boolean? exp)
|
((boolean? exp)
|
||||||
(c-code (string-append
|
(c-code (string-append
|
||||||
(if exp "boolean_t" "boolean_f"))))
|
(if exp "boolean_t" "boolean_f"))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue