add var-ref->mod-decl-insp' and switch cur-code-insp' uses

Macros and other tools that need syntax privilege used
`(current-code-inspector)' at the module top-level to try to
capture the right code inspector at load time. It's more
consistent to instead use the enclosing module's declaration-time
inspector, and `var-ref->mod-decl-insp' provides that. The
new function works only on references to anonymous variables,
which limits access to the inspector.

The real function name is longer, of course.

original commit: 0197902309c5400d463393829a88282c627dafd2
This commit is contained in:
Matthew Flatt 2011-09-20 13:29:42 -06:00
parent 6504b0856e
commit cd4b331886
3 changed files with 7 additions and 2 deletions

View File

@ -1056,6 +1056,7 @@
[variable-reference->empty-namespace (-> -Variable-Reference -Namespace)]
[variable-reference->namespace (-> -Variable-Reference -Namespace)]
[variable-reference->resolved-module-path (-> -Variable-Reference (-opt -Resolved-Module-Path))]
[variable-reference->module-declaration-inspector (-> -Variable-Reference -Inspector)]
[variable-reference->module-source (-> -Variable-Reference (Un Sym (-val #f) -Path))]
[variable-reference->phase (-> -Variable-Reference -Nat)]
[variable-reference-constant? (-> -Variable-Reference -Boolean)]

View File

@ -22,5 +22,7 @@
(cons a d)))]
[else v])))
(define orig-insp (current-code-inspector))
(define orig-insp (variable-reference->module-declaration-inspector
(#%variable-reference)))

View File

@ -2,7 +2,9 @@
(require (for-syntax syntax/parse racket/base syntax/id-table racket/dict
unstable/debug))
(define-for-syntax code-insp (current-code-inspector))
(define-for-syntax code-insp
(variable-reference->module-declaration-inspector
(#%variable-reference)))
(define-for-syntax (rewrite stx tbl from)
(define (rw stx)