names in the compile time environment are now NamedBindings in preparation for set\!

This commit is contained in:
Danny Yoo 2011-03-18 22:41:03 -04:00
parent 20818b0a7a
commit 26a5136195
2 changed files with 12 additions and 7 deletions

View File

@ -40,16 +40,16 @@
[else [else
(loop (rest cenv) (add1 depth))])] (loop (rest cenv) (add1 depth))])]
[(symbol? elt) [(NamedBinding? elt)
(cond (cond
[(eq? elt name) [(eq? (NamedBinding-name elt) name)
(make-EnvLexicalReference depth #f)] (make-EnvLexicalReference depth #f)]
[else [else
(loop (rest cenv) (add1 depth))])] (loop (rest cenv) (add1 depth))])]
[(box? elt) [(box? elt)
(cond (cond
[(eq? (unbox elt) name) [(eq? (NamedBinding-name (unbox elt)) name)
(make-EnvLexicalReference depth #t)] (make-EnvLexicalReference depth #t)]
[else [else
(loop (rest cenv) (add1 depth))])] (loop (rest cenv) (add1 depth))])]
@ -81,12 +81,14 @@
(: extend-lexical-environment/names (CompileTimeEnvironment (Listof Symbol) -> CompileTimeEnvironment)) (: extend-lexical-environment/names (CompileTimeEnvironment (Listof Symbol) -> CompileTimeEnvironment))
(define (extend-lexical-environment/names cenv names) (define (extend-lexical-environment/names cenv names)
(append names cenv)) (append (map make-NamedBinding names) cenv))
(: extend-lexical-environment/boxed-names (CompileTimeEnvironment (Listof Symbol) -> CompileTimeEnvironment)) (: extend-lexical-environment/boxed-names (CompileTimeEnvironment (Listof Symbol) -> CompileTimeEnvironment))
(define (extend-lexical-environment/boxed-names cenv names) (define (extend-lexical-environment/boxed-names cenv names)
(append (map (inst box Symbol) names) cenv)) (append (map (inst box NamedBinding)
(map make-NamedBinding names))
cenv))
(: extend-lexical-environment/placeholders (: extend-lexical-environment/placeholders

View File

@ -13,14 +13,17 @@
#:transparent) #:transparent)
(define-struct: NamedBinding ([name : Symbol]))
(define-type CompileTimeEnvironmentEntry (U Prefix ;; a prefix (define-type CompileTimeEnvironmentEntry (U Prefix ;; a prefix
Symbol NamedBinding
(Boxof Symbol) ;; A boxed local (Boxof NamedBinding) ;; A boxed local
False)) False))
;; A compile-time environment is a (listof (listof symbol)). ;; A compile-time environment is a (listof (listof symbol)).
;; A lexical address is either a 2-tuple (depth pos), or 'not-found. ;; A lexical address is either a 2-tuple (depth pos), or 'not-found.
(define-type CompileTimeEnvironment (Listof CompileTimeEnvironmentEntry)) (define-type CompileTimeEnvironment (Listof CompileTimeEnvironmentEntry))