fixing some of the open coding; about to add a few more.

This commit is contained in:
Danny Yoo 2011-03-28 22:13:40 -04:00
parent d0eb3b610e
commit 2cb966f01f
4 changed files with 17 additions and 6 deletions

View File

@ -422,6 +422,7 @@ EOF
(open-code-kernel-primitive-procedure op)])) (open-code-kernel-primitive-procedure op)]))
;; FIXME: this needs to check that the domains are good! ;; FIXME: this needs to check that the domains are good!
(: open-code-kernel-primitive-procedure (CallKernelPrimitiveProcedure -> String)) (: open-code-kernel-primitive-procedure (CallKernelPrimitiveProcedure -> String))
(define (open-code-kernel-primitive-procedure op) (define (open-code-kernel-primitive-procedure op)
@ -430,9 +431,11 @@ EOF
(case operator (case operator
[(+) [(+)
(cond [(empty? rand-vals) (cond [(empty? rand-vals)
"0"] "(0)"]
[else [else
(string-append "(" (string-join rand-vals " + ") ")")])] (string-append "("
(string-join rand-vals " + ")
")")])]
[(add1) [(add1)
(unless (= 1 (length rand-vals)) (unless (= 1 (length rand-vals))
(error 'add1 "Expected one argument")) (error 'add1 "Expected one argument"))

View File

@ -500,14 +500,14 @@
;; Produces a list of OpArgs if all the operands are particularly simple, and false otherwise. ;; Produces a list of OpArgs if all the operands are particularly simple, and false otherwise.
(define (all-operands-are-constant-or-stack-references rands) (define (all-operands-are-constant-or-stack-references rands)
(cond [(andmap (lambda: ([rand : ExpressionCore]) (cond [(andmap (lambda: ([rand : ExpressionCore])
(or (Const? rand) (or (Constant? rand)
(LocalRef? rand) (LocalRef? rand)
(ToplevelRef? rand))) (ToplevelRef? rand)))
rands) rands)
(map (lambda: ([e : ExpressionCore]) (map (lambda: ([e : ExpressionCore])
(cond (cond
[(Const? e) [(Constant? e)
e] (make-Const (Constant-v e))]
[(LocalRef? e) [(LocalRef? e)
(make-EnvLexicalReference (LocalRef-depth e) (make-EnvLexicalReference (LocalRef-depth e)
(LocalRef-unbox? e))] (LocalRef-unbox? e))]

View File

@ -159,12 +159,14 @@
;; The following are primitives that the compiler knows about: ;; The following are primitives that the compiler knows about:
(define-type KernelPrimitiveName (U '+ (define-type KernelPrimitiveName (U '+
'-
'*
'/
'add1 'add1
'sub1 'sub1
'< '<
'<= '<=
'= '=
'cons 'cons
'car 'car
'cdr 'cdr

View File

@ -48,6 +48,12 @@ EOF
#'stx))) #'stx)))
(printf " ok (~a milliseconds)\n" (evaluated-t result))))))])) (printf " ok (~a milliseconds)\n" (evaluated-t result))))))]))
(test '(display 42)
"42")
(test '(display (+ 3 4))
"7")
(test '(begin (define (f x) (test '(begin (define (f x)
(if (= x 0) (if (= x 0)
0 0