* racompiler compiles integers.
This commit is contained in:
parent
f5d870f23b
commit
1eff505ab4
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -192,11 +192,19 @@
|
||||||
(lambda (n ac)
|
(lambda (n ac)
|
||||||
(cond
|
(cond
|
||||||
[(int? n)
|
[(int? n)
|
||||||
(list* (byte n)
|
(if (fixnum? n)
|
||||||
(byte (fxsra n 8))
|
(list* (byte n)
|
||||||
(byte (fxsra n 16))
|
(byte (fxsra n 8))
|
||||||
(byte (fxsra n 24))
|
(byte (fxsra n 16))
|
||||||
ac)]
|
(byte (fxsra n 24))
|
||||||
|
ac)
|
||||||
|
(let ([lo (remainder n 256)]
|
||||||
|
[hi (quotient n 256)])
|
||||||
|
(list* (byte lo)
|
||||||
|
(byte hi)
|
||||||
|
(byte (fxsra hi 8))
|
||||||
|
(byte (fxsra hi 16))
|
||||||
|
ac)))]
|
||||||
[(obj? n)
|
[(obj? n)
|
||||||
(let ([v (cadr n)])
|
(let ([v (cadr n)])
|
||||||
(if (immediate? v)
|
(if (immediate? v)
|
||||||
|
|
|
@ -80,11 +80,13 @@
|
||||||
;;;
|
;;;
|
||||||
(define rv-register (mkreg '%eax))
|
(define rv-register (mkreg '%eax))
|
||||||
;;;
|
;;;
|
||||||
|
(define (return x)
|
||||||
|
(mkseq (mkset rv-register x)
|
||||||
|
(mkprm 'return rv-register)))
|
||||||
(define (Tail x)
|
(define (Tail x)
|
||||||
(record-case x
|
(record-case x
|
||||||
[(constant c)
|
[(constant) (return x)]
|
||||||
(mkseq (mkset rv-register x)
|
[(int) (return x)]
|
||||||
(mkprm 'return rv-register))]
|
|
||||||
[else (error who "invalid tail ~s" x)]))
|
[else (error who "invalid tail ~s" x)]))
|
||||||
;;;
|
;;;
|
||||||
(Tail x))
|
(Tail x))
|
||||||
|
@ -94,9 +96,10 @@
|
||||||
;;;
|
;;;
|
||||||
(define (op x)
|
(define (op x)
|
||||||
(record-case x
|
(record-case x
|
||||||
[(register r) r]
|
[(reg r) r]
|
||||||
[(constant c) `(obj ,c)]
|
[(constant c) `(obj ,c)]
|
||||||
[(int i) `(int ,i)]
|
[(int i) i]
|
||||||
|
[else (error who "invalid op ~s" x)]))
|
||||||
;;;
|
;;;
|
||||||
(define (Effect x ac)
|
(define (Effect x ac)
|
||||||
(record-case x
|
(record-case x
|
||||||
|
@ -117,7 +120,7 @@
|
||||||
[else (error who "invalid tail prim ~s" op)])]
|
[else (error who "invalid tail prim ~s" op)])]
|
||||||
[else (error who "invalid tail ~s" x)]))
|
[else (error who "invalid tail ~s" x)]))
|
||||||
;;;
|
;;;
|
||||||
(list (Tail x '())))
|
(list (cons 0 (Tail x '()))))
|
||||||
;;;
|
;;;
|
||||||
(define (compile x)
|
(define (compile x)
|
||||||
(let* ([x (expand x)]
|
(let* ([x (expand x)]
|
||||||
|
@ -151,3 +154,4 @@
|
||||||
|
|
||||||
(load "tests/tests-1.1-req.scm")
|
(load "tests/tests-1.1-req.scm")
|
||||||
|
|
||||||
|
(printf "ALL IS GOOD :-)\n")
|
||||||
|
|
Loading…
Reference in New Issue