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
(loop (rest cenv) (add1 depth))])]
[(symbol? elt)
[(NamedBinding? elt)
(cond
[(eq? elt name)
[(eq? (NamedBinding-name elt) name)
(make-EnvLexicalReference depth #f)]
[else
(loop (rest cenv) (add1 depth))])]
[(box? elt)
(cond
[(eq? (unbox elt) name)
[(eq? (NamedBinding-name (unbox elt)) name)
(make-EnvLexicalReference depth #t)]
[else
(loop (rest cenv) (add1 depth))])]
@ -81,12 +81,14 @@
(: extend-lexical-environment/names (CompileTimeEnvironment (Listof Symbol) -> CompileTimeEnvironment))
(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))
(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

View File

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