diff --git a/bootstrapped-primitives.rkt b/bootstrapped-primitives.rkt index bb05fa8..049a0e3 100644 --- a/bootstrapped-primitives.rkt +++ b/bootstrapped-primitives.rkt @@ -84,10 +84,11 @@ (make-bootstrapped-primitive-code 'map '(letrec ([map (lambda (f l) - (if (null? l) - null - (cons (f (car l)) - (map f (cdr l)))))]) + (displayln "in map") + (if (null? l) + null + (cons (f (car l)) + (map f (cdr l)))))]) map)) (make-bootstrapped-primitive-code diff --git a/compiler.rkt b/compiler.rkt index 3258685..e51a712 100644 --- a/compiler.rkt +++ b/compiler.rkt @@ -863,7 +863,6 @@ (append-instruction-sequences (make-instruction-sequence `(,(Lam-entry-label exp))) - maybe-unsplice-rest-argument maybe-install-closure-values lam-body-code))) diff --git a/lang/kernel.rkt b/lang/kernel.rkt index 6a418b0..5975fa7 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -154,10 +154,10 @@ (eq? x y))) -(provide-stub-function #;xml->s-exp - #;js-object? - write +;; Many of these should be pushed upward rather than stubbed, so that +;; Racket's compiler can optimize these. +(provide-stub-function write display newline current-print @@ -165,7 +165,7 @@ continuation-mark-set? continuation-mark-set->list for-each - ;; make-thread-cell + make-struct-type make-struct-field-accessor make-struct-field-mutator diff --git a/simulator/simulator.rkt b/simulator/simulator.rkt index 5ea727f..42f7e37 100644 --- a/simulator/simulator.rkt +++ b/simulator/simulator.rkt @@ -259,6 +259,11 @@ [(CheckToplevelBound!? op) (let: ([a-top : toplevel (ensure-toplevel (env-ref m (CheckToplevelBound!-depth op)))]) + (when (> (CheckToplevelBound!-pos op) + (length (toplevel-vals a-top))) + (printf "ERROR: toplevel is length ~s, but trying to refer to ~s" + (length (toplevel-vals a-top)) + (CheckToplevelBound!-pos op))) (cond [(undefined? (list-ref (toplevel-vals a-top) (CheckToplevelBound!-pos op))) (error 'check-toplevel-bound! "Unbound identifier ~s" diff --git a/test-compiler.rkt b/test-compiler.rkt index 96fd418..dff2fa2 100644 --- a/test-compiler.rkt +++ b/test-compiler.rkt @@ -349,7 +349,8 @@ (even? 1023) (even? 2172) (even? 2171))) - (list #t #f #t #f)) + (list #t #f #t #f) + #:with-bootstrapping? #t) @@ -404,6 +405,13 @@ 0)) + +(test '(map (lambda (x) (* x x)) + '(1 2 3 4 5)) + '(1 4 9 16 25) + #:with-bootstrapping? #t) + + ;; Foldl (test '(let() (define (foldl f acc lst) diff --git a/test-helpers.rkt b/test-helpers.rkt index 9901fce..a501775 100644 --- a/test-helpers.rkt +++ b/test-helpers.rkt @@ -1,6 +1,7 @@ #lang racket/base (require (prefix-in racket: racket/base) + racket/runtime-path "compiler-structs.rkt" "compiler.rkt" "parse-bytecode-5.1.1.rkt" @@ -9,11 +10,16 @@ (provide parse run-compiler) +(define-runtime-path kernel-language-path + "lang/kernel.rkt") + ;; Use Racket's compiler, and then parse the resulting bytecode ;; to our own AST structures. (define (parse stx) - (parameterize ([current-namespace (lookup-language-namespace 'racket/base)]) + (parameterize ([current-namespace (lookup-language-namespace + `(file ,(path->string kernel-language-path)) + #;'racket/base)]) (let ([bc (racket:compile stx)] [op (open-output-bytes)]) (write bc op)