cs: small interpreter clean-ups
This commit is contained in:
parent
5e45dd2e1c
commit
56fe13e6f7
|
@ -147,6 +147,11 @@
|
||||||
(list-of-keywords? (cadr v))
|
(list-of-keywords? (cadr v))
|
||||||
(extflonum? (cadr v))))
|
(extflonum? (cadr v))))
|
||||||
10]
|
10]
|
||||||
|
[(and (pair? v)
|
||||||
|
(pair? (cdr v))
|
||||||
|
(eq? 'quote (car v))
|
||||||
|
(void? (cadr v)))
|
||||||
|
6]
|
||||||
[(bytes? v) (* 3 (bytes-length v))]
|
[(bytes? v) (* 3 (bytes-length v))]
|
||||||
[(and (symbol? v) (regexp-match? #rx"#" (symbol->string v)))
|
[(and (symbol? v) (regexp-match? #rx"#" (symbol->string v)))
|
||||||
(+ 2 (string-length (symbol->string v)))]
|
(+ 2 (string-length (symbol->string v)))]
|
||||||
|
@ -175,6 +180,11 @@
|
||||||
(list-of-keywords? (cadr v))
|
(list-of-keywords? (cadr v))
|
||||||
(extflonum? (cadr v))))
|
(extflonum? (cadr v))))
|
||||||
(write (hash-ref lifts (cadr v)) out)]
|
(write (hash-ref lifts (cadr v)) out)]
|
||||||
|
[(and (pair? v)
|
||||||
|
(pair? (cdr v))
|
||||||
|
(eq? 'quote (car v))
|
||||||
|
(void? (cadr v)))
|
||||||
|
(write '(void) out)]
|
||||||
[(bytes? v)
|
[(bytes? v)
|
||||||
(display "#vu8")
|
(display "#vu8")
|
||||||
(write (bytes->list v) out)]
|
(write (bytes->list v) out)]
|
||||||
|
|
|
@ -302,7 +302,7 @@
|
||||||
(compile-expr `(call-with-values (lambda () ,rhs)
|
(compile-expr `(call-with-values (lambda () ,rhs)
|
||||||
(lambda ,gen-ids
|
(lambda ,gen-ids
|
||||||
,@(if (null? ids)
|
,@(if (null? ids)
|
||||||
'((void))
|
(list (void))
|
||||||
(for/list ([id (in-list ids)]
|
(for/list ([id (in-list ids)]
|
||||||
[gen-id (in-list gen-ids)])
|
[gen-id (in-list gen-ids)])
|
||||||
`(set! ,id ,gen-id)))))
|
`(set! ,id ,gen-id)))))
|
||||||
|
@ -548,7 +548,11 @@
|
||||||
(define pos (stack->pos (if (boxed? var) (boxed-pos var) var) stk-i)) ; box result means unused
|
(define pos (stack->pos (if (boxed? var) (boxed-pos var) var) stk-i)) ; box result means unused
|
||||||
(cond
|
(cond
|
||||||
[(box? pos)
|
[(box? pos)
|
||||||
(vector 'clear (list (unbox pos)) e)]
|
(cond
|
||||||
|
[(and (vector? e) (eq? 'clear (vector-ref e 0)))
|
||||||
|
(vector 'clear (cons (unbox pos) (vector-ref e 1)) (vector-ref e 2))]
|
||||||
|
[else
|
||||||
|
(vector 'clear (list (unbox pos)) e)])]
|
||||||
[(not (hash-ref mutated u #f))
|
[(not (hash-ref mutated u #f))
|
||||||
e]
|
e]
|
||||||
[else
|
[else
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
(cond
|
(cond
|
||||||
[(or (string? x) (bytes? x) (boolean? x) (number? x))
|
[(or (string? x) (bytes? x) (boolean? x) (number? x))
|
||||||
x]
|
x]
|
||||||
[(void? x) '(void)]
|
[(void? x) `(quote ,(void))]
|
||||||
[(eof-object? x) 'eof]
|
[(eof-object? x) 'eof]
|
||||||
[else
|
[else
|
||||||
`(quote ,x)]))
|
`(quote ,x)]))
|
||||||
|
|
|
@ -396,6 +396,9 @@
|
||||||
[`,_ (finish-definition ids)])]
|
[`,_ (finish-definition ids)])]
|
||||||
[else
|
[else
|
||||||
(finish-wrapped-definition ids rhs)])]
|
(finish-wrapped-definition ids rhs)])]
|
||||||
|
[`(quote ,_) ; useful to drop #<void>s for the interpreter
|
||||||
|
#:guard (or (pair? (cdr l)) (pair? accum-ids))
|
||||||
|
(loop (cdr l) mut-l accum-exprs accum-ids knowns)]
|
||||||
[`,_
|
[`,_
|
||||||
(match form
|
(match form
|
||||||
[`(define-values ,ids ,_)
|
[`(define-values ,ids ,_)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user