diff --git a/get-module-bytecode.rkt b/get-module-bytecode.rkt index eb18f99..38a7e7f 100644 --- a/get-module-bytecode.rkt +++ b/get-module-bytecode.rkt @@ -1,7 +1,6 @@ #lang racket/base (require racket/path racket/runtime-path - syntax/modcode "language-namespace.rkt" "logger.rkt" "expand-out-images.rkt") @@ -20,42 +19,27 @@ (define (get-module-bytecode x) (log-debug "grabbing module bytecode for ~s" x) - (define-values (compiled-code alternative-f) + (define compiled-code (cond - ;; Assumed to be a path string - [(string? x) - (log-debug "assuming path string") - (values (get-compiled-code-from-path (normalize-path (build-path x))) - (lambda () - (call-with-input-file* (normalize-path (build-path x)) - get-compiled-code-from-port) - ))] - - [(path? x) - (values (get-compiled-code-from-path x) - (lambda () - (call-with-input-file* x get-compiled-code-from-port)))] - - ;; Input port is assumed to contain the text of a module. - [(input-port? x) - (values (get-compiled-code-from-port x) - (lambda () - (get-compiled-code-from-port x)))] - - [else - (error 'get-module-bytecode)])) + ;; Assumed to be a path string + [(string? x) + (log-debug "assuming path string") + (call-with-input-file* (normalize-path (build-path x)) + get-compiled-code-from-port)] + + [(path? x) + (call-with-input-file* x get-compiled-code-from-port)] + + ;; Input port is assumed to contain the text of a module. + [(input-port? x) + (get-compiled-code-from-port x)] + + [else + (error 'get-module-bytecode)])) - (with-handlers ([exn? (lambda (exn) - ;(printf "error? ~s\n" (exn-message exn)) - (define op (open-output-bytes)) - ;(printf "trying alternative to get bytecode\n") - (define bytecode (alternative-f)) - ;(printf "got the bytecode\n") - (write bytecode op) - (get-output-bytes op))]) - (define op (open-output-bytes)) - (write compiled-code op) - (get-output-bytes op))) + (define op (open-output-bytes)) + (write compiled-code op) + (get-output-bytes op)) @@ -69,21 +53,23 @@ -;; Tries to use get-module-code to grab at module bytecode. Sometimes -;; this fails because it appears get-module-code tries to write to -;; compiled/. -(define (get-compiled-code-from-path p) - (log-debug "get-compiled-code-from-path") - (with-handlers ([exn? (lambda (exn) - ;; Failsafe: try to do it from scratch - (log-debug "parsing from scratch") - (call-with-input-file* p - (lambda (ip) - (get-compiled-code-from-port ip))) - )]) - ;; Note: we're trying to preserve the context, to avoid code expansion. - (parameterize ([compile-context-preservation-enabled #t]) - (get-module-code p)))) +;; ;; Tries to use get-module-code to grab at module bytecode. Sometimes +;; ;; this fails because it appears get-module-code tries to write to +;; ;; compiled/. +;; (define (get-compiled-code-from-path p) +;; (log-debug "get-compiled-code-from-path") +;; (with-handlers ([exn? (lambda (exn) +;; ;; Failsafe: try to do it from scratch +;; (log-debug "parsing from scratch") +;; (call-with-input-file* p +;; (lambda (ip) +;; (get-compiled-code-from-port ip))) +;; )]) +;; ;; Note: we're trying to preserve the context, to avoid code expansion. +;; (parameterize ([compile-context-preservation-enabled #t]) +;; (get-module-code p)))) + + ;; get-compiled-code-from-port: input-port -> compiled-code diff --git a/js-assembler/package.rkt b/js-assembler/package.rkt index fd492a9..78f66e1 100644 --- a/js-assembler/package.rkt +++ b/js-assembler/package.rkt @@ -64,7 +64,8 @@ ;; Sets up the compiler parameters we need to do javascript-specific compilation. (define (with-compiler-params thunk) - (parameterize ([current-primitive-identifier? + (parameterize ([compile-context-preservation-enabled #t] + [current-primitive-identifier? (lambda (a-name) (set-member? primitive-identifiers-set a-name))]) (thunk))) diff --git a/version.rkt b/version.rkt index 888d16e..a765352 100644 --- a/version.rkt +++ b/version.rkt @@ -6,4 +6,4 @@ (provide version) (: version String) -(define version "1.51") +(define version "1.53")