box
This commit is contained in:
parent
9bce564bf3
commit
44078dd40e
|
@ -159,7 +159,7 @@
|
||||||
`(,(make-AssignImmediateStatement
|
`(,(make-AssignImmediateStatement
|
||||||
target
|
target
|
||||||
(make-EnvLexicalReference (LocalAddress-depth lexical-pos)
|
(make-EnvLexicalReference (LocalAddress-depth lexical-pos)
|
||||||
#f)))))]
|
(LocalAddress-unbox? lexical-pos))))))]
|
||||||
[(PrefixAddress? lexical-pos)
|
[(PrefixAddress? lexical-pos)
|
||||||
(end-with-linkage linkage
|
(end-with-linkage linkage
|
||||||
cenv
|
cenv
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(provide find-variable
|
(provide find-variable
|
||||||
extend-lexical-environment
|
extend-lexical-environment
|
||||||
extend-lexical-environment/names
|
extend-lexical-environment/names
|
||||||
|
extend-lexical-environment/boxed-names
|
||||||
extend-lexical-environment/placeholders
|
extend-lexical-environment/placeholders
|
||||||
collect-lexical-references
|
collect-lexical-references
|
||||||
lexical-references->compile-time-environment)
|
lexical-references->compile-time-environment)
|
||||||
|
@ -39,7 +40,14 @@
|
||||||
[(symbol? elt)
|
[(symbol? elt)
|
||||||
(cond
|
(cond
|
||||||
[(eq? elt name)
|
[(eq? elt name)
|
||||||
(make-LocalAddress depth)]
|
(make-LocalAddress depth #f)]
|
||||||
|
[else
|
||||||
|
(loop (rest cenv) (add1 depth))])]
|
||||||
|
|
||||||
|
[(box? elt)
|
||||||
|
(cond
|
||||||
|
[(eq? (unbox elt) name)
|
||||||
|
(make-LocalAddress depth #t)]
|
||||||
[else
|
[else
|
||||||
(loop (rest cenv) (add1 depth))])]
|
(loop (rest cenv) (add1 depth))])]
|
||||||
|
|
||||||
|
@ -73,6 +81,11 @@
|
||||||
(append names cenv))
|
(append 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))
|
||||||
|
|
||||||
|
|
||||||
(: extend-lexical-environment/placeholders
|
(: extend-lexical-environment/placeholders
|
||||||
(CompileTimeEnvironment Natural -> CompileTimeEnvironment))
|
(CompileTimeEnvironment Natural -> CompileTimeEnvironment))
|
||||||
;; Add placeholders to the lexical environment (This represents what happens during procedure application.)
|
;; Add placeholders to the lexical environment (This represents what happens during procedure application.)
|
||||||
|
@ -102,7 +115,7 @@
|
||||||
[(LocalAddress? addr)
|
[(LocalAddress? addr)
|
||||||
(set-insert! lexical-references
|
(set-insert! lexical-references
|
||||||
(make-EnvLexicalReference (LocalAddress-depth addr)
|
(make-EnvLexicalReference (LocalAddress-depth addr)
|
||||||
#f))
|
(LocalAddress-unbox? addr)))
|
||||||
(loop (rest addresses))]
|
(loop (rest addresses))]
|
||||||
[(PrefixAddress? addr)
|
[(PrefixAddress? addr)
|
||||||
(set-insert! prefix-references
|
(set-insert! prefix-references
|
||||||
|
|
|
@ -11,18 +11,12 @@
|
||||||
(define-struct: Prefix ([names : (Listof Symbol)])
|
(define-struct: Prefix ([names : (Listof Symbol)])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
#;(define-struct: FunctionExtension ([names : (Listof Symbol)])
|
|
||||||
#:transparent)
|
|
||||||
|
|
||||||
#;(define-struct: LocalExtension ([names : (Listof Symbol)])
|
|
||||||
#:transparent)
|
|
||||||
|
|
||||||
#;(define-struct: TemporaryExtension ([n : Natural])
|
|
||||||
#:transparent)
|
|
||||||
|
|
||||||
|
|
||||||
(define-type CompileTimeEnvironmentEntry (U Prefix ;; a prefix
|
(define-type CompileTimeEnvironmentEntry (U Prefix ;; a prefix
|
||||||
Symbol
|
Symbol
|
||||||
|
(Boxof Symbol) ;; A boxed local
|
||||||
False
|
False
|
||||||
#;FunctionExtension
|
#;FunctionExtension
|
||||||
#;LocalExtension
|
#;LocalExtension
|
||||||
|
@ -35,7 +29,8 @@
|
||||||
|
|
||||||
;; A lexical address is a reference to an value in the environment stack.
|
;; A lexical address is a reference to an value in the environment stack.
|
||||||
(define-type LexicalAddress (U LocalAddress PrefixAddress))
|
(define-type LexicalAddress (U LocalAddress PrefixAddress))
|
||||||
(define-struct: LocalAddress ([depth : Natural])
|
(define-struct: LocalAddress ([depth : Natural]
|
||||||
|
[unbox? : Boolean])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
(define-struct: PrefixAddress ([depth : Natural]
|
(define-struct: PrefixAddress ([depth : Natural]
|
||||||
[pos : Natural]
|
[pos : Natural]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user