a few more open-coded primitives
This commit is contained in:
parent
eb0eee57bd
commit
bbb80800db
18
assemble.rkt
18
assemble.rkt
|
@ -473,6 +473,14 @@ EOF
|
|||
(unless (> (length rand-vals) 0)
|
||||
(error '= "Expected at least one argument"))
|
||||
(assemble-chain "==" rand-vals)]
|
||||
[(>)
|
||||
(unless (> (length rand-vals) 0)
|
||||
(error '> "Expected at least one argument"))
|
||||
(assemble-chain ">" rand-vals)]
|
||||
[(>=)
|
||||
(unless (> (length rand-vals) 0)
|
||||
(error '>= "Expected at least one argument"))
|
||||
(assemble-chain ">=" rand-vals)]
|
||||
[(cons)
|
||||
(unless (= (length rand-vals) 2)
|
||||
(error 'cons "Expected two arguments"))
|
||||
|
@ -496,7 +504,15 @@ EOF
|
|||
(unless (= (length rand-vals) 1)
|
||||
(error 'null? "Expected one argument"))
|
||||
(format "(~a === Primitives.null)"
|
||||
(first rand-vals))])))
|
||||
(first rand-vals))]
|
||||
[(not)
|
||||
(unless (= (length rand-vals) 1)
|
||||
(error 'not? "Expected one argument"))
|
||||
(format "(!~a)" (first rand-vals))]
|
||||
[(eq?)
|
||||
(unless (= (length rand-vals) 2)
|
||||
(error 'eq? "Expected 2 arguments"))
|
||||
(format "(~a === ~a)" (first rand-vals) (second rand-vals))])))
|
||||
|
||||
|
||||
(: assemble-chain (String (Listof String) -> String))
|
||||
|
|
|
@ -167,11 +167,15 @@
|
|||
'<
|
||||
'<=
|
||||
'=
|
||||
'>
|
||||
'>=
|
||||
'cons
|
||||
'car
|
||||
'cdr
|
||||
'list
|
||||
'null?
|
||||
'not
|
||||
'eq?
|
||||
))
|
||||
(define-predicate KernelPrimitiveName? KernelPrimitiveName)
|
||||
|
||||
|
|
|
@ -366,6 +366,10 @@
|
|||
(chain-compare <= (map ensure-real-number rand-vals))]
|
||||
[(=)
|
||||
(chain-compare = (map ensure-real-number rand-vals))]
|
||||
[(>)
|
||||
(chain-compare > (map ensure-real-number rand-vals))]
|
||||
[(>=)
|
||||
(chain-compare >= (map ensure-real-number rand-vals))]
|
||||
[(cons)
|
||||
(make-MutablePair (first rand-vals) (ensure-list (second rand-vals)))]
|
||||
[(car)
|
||||
|
@ -380,6 +384,10 @@
|
|||
(loop (rest rand-vals)))]))]
|
||||
[(null?)
|
||||
(null? (first rand-vals))]
|
||||
[(not)
|
||||
(not (first rand-vals))]
|
||||
[(eq?)
|
||||
(eq? (first rand-vals) (second rand-vals))]
|
||||
[else
|
||||
(error 'evaluate-kernel-primitive-procedure-call "missing operator: ~s\n" op)])))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user