names in the compile time environment are now NamedBindings in preparation for set\!
This commit is contained in:
parent
20818b0a7a
commit
26a5136195
|
@ -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
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user