fix mistakes uncovered by optimizer warnings

This commit is contained in:
Matthew Flatt 2011-04-30 18:59:46 -06:00
parent 045fd7a77c
commit 1b14c6a38e
9 changed files with 57 additions and 41 deletions

View File

@ -468,8 +468,8 @@
;; Record module as copied ;; Record module as copied
(set-box! codes (set-box! codes
(cons (make-mod filename module-path #f (cons (make-mod filename module-path #f
#f #f #f #f #f #f #f
null null null null null
actual-filename) actual-filename)
(unbox codes)))) (unbox codes))))
;; Build up relative module resolutions, relative to this one, ;; Build up relative module resolutions, relative to this one,
@ -513,7 +513,7 @@
(set-box! codes (set-box! codes
(cons (make-mod filename module-path code (cons (make-mod filename module-path code
name #f #f name #f #f
null null null null null
actual-filename) actual-filename)
(unbox codes)))]))))))) (unbox codes)))])))))))

View File

@ -142,7 +142,7 @@
(and (box? value) (and (box? value)
(let ([value (unbox value)]) (let ([value (unbox value)])
(or (string? value) (bytes? value) (exact-integer? value))))) (or (string? value) (bytes? value) (exact-integer? value)))))
(raise-type-error 'get-resource "box of string, byte string, or exact integer")) (raise-type-error 'get-resource "#f or box of string, byte string, or exact integer" value))
(unless (or (not file) (unless (or (not file)
(path-string? file)) (path-string? file))
(raise-type-error 'get-resource "path string or #f" file)) (raise-type-error 'get-resource "path string or #f" file))
@ -221,7 +221,7 @@
(unless (string? entry) (unless (string? entry)
(raise-type-error 'write-resource "string" entry)) (raise-type-error 'write-resource "string" entry))
(unless (or (string? value) (bytes? value) (exact-integer? value)) (unless (or (string? value) (bytes? value) (exact-integer? value))
(raise-type-error 'write-resource "string, byte string, or exact integer")) (raise-type-error 'write-resource "string, byte string, or exact integer" value))
(unless (or (not file) (unless (or (not file)
(path-string? file)) (path-string? file))
(raise-type-error 'write-resource "path string or #f" file)) (raise-type-error 'write-resource "path string or #f" file))

View File

@ -442,12 +442,12 @@ Various common pieces of code that both the client and server need to access
(define (copy-n-chars n ip op) (define (copy-n-chars n ip op)
(let ((cport (make-cutoff-port ip (let ((cport (make-cutoff-port ip
n n
(lambda () (lambda (m)
(raise (raise
(make-exn:fail:read:eof (make-exn:fail:read:eof
(format "Not enough chars on input (expected ~a, got ~a)" (format "Not enough chars on input (expected ~a, got ~a)"
n n
(- n 0)) m)
(current-continuation-marks) (current-continuation-marks)
ip)))))) ip))))))
(copy-port cport op))) (copy-port cport op)))

View File

@ -7,7 +7,11 @@
(define runtime-predicates (define runtime-predicates
(let ([fn (build-path (collection-path "scheme") (let ([fn (build-path (collection-path "scheme")
"compiled" "compiled"
"main_rkt.zo")]) "main_rkt.zo")]
[ns (make-base-namespace)])
(namespace-attach-module (current-namespace) 'scheme ns)
(parameterize ([current-namespace ns])
(namespace-require 'scheme))
(let-values ([(vars stx) (let-values ([(vars stx)
(module-compiled-exports (module-compiled-exports
(parameterize ([read-accept-compiled #t]) (parameterize ([read-accept-compiled #t])
@ -16,7 +20,10 @@
(filter (λ (sym) (filter (λ (sym)
(let ([str (symbol->string sym)]) (let ([str (symbol->string sym)])
(and (regexp-match #rx"[?]$" str) (and (regexp-match #rx"[?]$" str)
(not (regexp-match #rx"[=<>][?]$" str))))) (not (regexp-match #rx"[=<>][?]$" str))
(procedure-arity-includes?
(namespace-variable-value sym #t #f ns)
1))))
(map car (cdr (assoc 0 vars)))) (map car (cdr (assoc 0 vars))))
string<=? string<=?
#:key symbol->string)))) #:key symbol->string))))
@ -24,7 +31,6 @@
(define-for-syntax predicates (define-for-syntax predicates
'(absolute-path? '(absolute-path?
arity-at-least? arity-at-least?
bitwise-bit-set?
blame-original? blame-original?
blame-swapped? blame-swapped?
blame? blame?
@ -39,7 +45,6 @@
channel? channel?
chaperone-contract-property? chaperone-contract-property?
chaperone-contract? chaperone-contract?
chaperone-of?
chaperone? chaperone?
char-alphabetic? char-alphabetic?
char-blank? char-blank?
@ -64,12 +69,9 @@
continuation-prompt-available? continuation-prompt-available?
continuation-prompt-tag? continuation-prompt-tag?
continuation? continuation?
contract-first-order-passes?
contract-property? contract-property?
contract-stronger?
contract? contract?
custodian-box? custodian-box?
custodian-memory-accounting-available?
custodian? custodian?
custom-print-quotable? custom-print-quotable?
custom-write? custom-write?
@ -80,9 +82,6 @@
empty? empty?
eof-object? eof-object?
ephemeron? ephemeron?
eq?
equal?
eqv?
even? even?
evt? evt?
exact-integer? exact-integer?
@ -126,44 +125,35 @@
hash-eq? hash-eq?
hash-equal? hash-equal?
hash-eqv? hash-eqv?
hash-has-key?
hash-placeholder? hash-placeholder?
hash-weak? hash-weak?
hash? hash?
identifier? identifier?
immutable? immutable?
impersonator-of?
impersonator-property-accessor-procedure? impersonator-property-accessor-procedure?
impersonator-property? impersonator-property?
impersonator? impersonator?
implementation?
inexact-real? inexact-real?
inexact? inexact?
input-port? input-port?
inspector? inspector?
integer? integer?
interface-extension?
interface? interface?
internal-definition-context? internal-definition-context?
is-a?
keyword? keyword?
link-exists? link-exists?
list? list?
log-level?
log-receiver? log-receiver?
logger? logger?
member-name-key? member-name-key?
method-in-interface?
module-path-index? module-path-index?
module-path? module-path?
module-provide-protected?
mpair? mpair?
namespace-anchor? namespace-anchor?
namespace? namespace?
negative? negative?
null? null?
number? number?
object-method-arity-includes?
object? object?
odd? odd?
output-port? output-port?
@ -176,7 +166,6 @@
placeholder? placeholder?
port-closed? port-closed?
port-provides-progress-evts? port-provides-progress-evts?
port-try-file-lock?
port-writes-atomic? port-writes-atomic?
port-writes-special? port-writes-special?
port? port?
@ -185,9 +174,7 @@
pretty-print-style-table? pretty-print-style-table?
primitive-closure? primitive-closure?
primitive? primitive?
procedure-arity-includes?
procedure-arity? procedure-arity?
procedure-closure-contents-eq?
procedure-struct-type? procedure-struct-type?
procedure? procedure?
promise-forced? promise-forced?
@ -197,8 +184,6 @@
rational? rational?
readtable? readtable?
real? real?
regexp-match-exact?
regexp-match?
regexp? regexp?
relative-path? relative-path?
rename-transformer? rename-transformer?
@ -220,16 +205,12 @@
struct-type-property? struct-type-property?
struct-type? struct-type?
struct? struct?
subclass?
subprocess? subprocess?
symbol-interned? symbol-interned?
symbol-unreadable? symbol-unreadable?
symbol? symbol?
syntax-local-transforming-module-provides?
syntax-original? syntax-original?
syntax-transforming?
syntax? syntax?
system-big-endian?
tcp-accept-ready? tcp-accept-ready?
tcp-listener? tcp-listener?
tcp-port? tcp-port?

View File

@ -341,7 +341,7 @@
(send/resp (list 'DONE result))) (send/resp (list 'DONE result)))
(define (send/errorp message) (define (send/errorp message)
(send/resp (list 'ERROR message))) (send/resp (list 'ERROR message)))
(with-handlers ([exn:fail? (lambda (x) (send/errorp (exn-message x)) (loop))]) (with-handlers ([exn:fail? (lambda (x) (send/errorp (exn-message x)) (loop (add1 i)))])
(parameterize ([current-output-port out-str-port] (parameterize ([current-output-port out-str-port]
[current-error-port err-str-port]) [current-error-port err-str-port])
(syntax-parameterize ([send/msg (make-rename-transformer #'send/msgp)] (syntax-parameterize ([send/msg (make-rename-transformer #'send/msgp)]

View File

@ -81,7 +81,11 @@
[(prefab? tmap) [(prefab? tmap)
(d->s (car data) (d->s (car data)
stx stx
(apply
make-prefab-struct
(prefab-struct-key (syntax-e stx))
(loop (prefab-fields tmap) (loop (prefab-fields tmap)
(cdr data) (cdr data)
(struct->list (syntax-e stx))))] (struct->list (syntax-e stx))
pcons)))]
[else (error "template-map-apply fallthrough")]))) [else (error "template-map-apply fallthrough")])))

View File

@ -74,8 +74,7 @@
(and k (and k
(let ([as (loop (struct->list (syntax-e tmpl)) in-ellipses?)]) (let ([as (loop (struct->list (syntax-e tmpl)) in-ellipses?)])
(and (or as (not const-leaf?)) (and (or as (not const-leaf?))
(make-prefab k as)) (make-prefab k as)))))])))
#f)))])))
(define (template-map-collect tmap template s->d leaf->d pvar->d) (define (template-map-collect tmap template s->d leaf->d pvar->d)
(let loop ([tmap tmap][template template]) (let loop ([tmap tmap][template template])

View File

@ -31,5 +31,6 @@
(load-in-sandbox "kw.rktl") (load-in-sandbox "kw.rktl")
(load-in-sandbox "macrolib.rktl") (load-in-sandbox "macrolib.rktl")
(load-in-sandbox "resource.rktl") (load-in-sandbox "resource.rktl")
(load-in-sandbox "syntaxlibs.rktl")
(report-errs) (report-errs)

View File

@ -0,0 +1,31 @@
(load-relative "loadtest.rktl")
(Section 'syntax/....)
(require (for-syntax syntax/template))
(let ()
(define-syntax (a-template-test stx)
(syntax-case stx ()
[(_ tmpl)
(let ([v (transform-template #'tmpl
#:save (lambda (stx) stx)
#:restore-stx (lambda (v stx datum)
(datum->syntax stx datum stx stx stx)))])
v)]))
(test '(1 #s(x "a" 1/2 8 9)
(2 3)
(#s(y 8) #s(y 9))
#(3 4 8 9)
. 6)
syntax->datum
(with-syntax ([(w ...) #'(8 9)])
(a-template-test (1 #s(x "a" 1/2 w ...)
(2 3)
(#s(y w) ...)
#(3 4 w ...)
. 6)))))
(report-errs)