diff --git a/lexical-env.rkt b/lexical-env.rkt index ffc6345..a54516c 100644 --- a/lexical-env.rkt +++ b/lexical-env.rkt @@ -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 diff --git a/lexical-structs.rkt b/lexical-structs.rkt index cfca301..e3fde45 100644 --- a/lexical-structs.rkt +++ b/lexical-structs.rkt @@ -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))