Correcting issue 95. Set! on global variables will check that the variable is defined
before proceeding.
This commit is contained in:
parent
60dda32c2e
commit
04f0aec996
|
@ -482,28 +482,31 @@
|
|||
(define (compile-toplevel-set exp cenv target linkage)
|
||||
(define prefix (ensure-prefix (list-ref cenv (ToplevelSet-depth exp))))
|
||||
(define prefix-element (list-ref (Prefix-names prefix) (ToplevelSet-pos exp)))
|
||||
(let ([get-value-code
|
||||
|
||||
(define top-target
|
||||
(cond
|
||||
[(ModuleVariable? prefix-element)
|
||||
(compile (ToplevelSet-value exp)
|
||||
cenv
|
||||
(make-EnvPrefixReference (ToplevelSet-depth exp)
|
||||
(ToplevelSet-pos exp)
|
||||
#t)
|
||||
next-linkage/expects-single)]
|
||||
#t)]
|
||||
[(GlobalBucket? prefix-element)
|
||||
(compile (ToplevelSet-value exp)
|
||||
cenv
|
||||
(make-GlobalsReference (GlobalBucket-name prefix-element))
|
||||
next-linkage/expects-single)]
|
||||
(make-GlobalsReference (GlobalBucket-name prefix-element))]
|
||||
|
||||
[(or (eq? prefix-element #f)
|
||||
(symbol? prefix-element))
|
||||
(compile (ToplevelSet-value exp)
|
||||
cenv
|
||||
(make-EnvPrefixReference (ToplevelSet-depth exp)
|
||||
(ToplevelSet-pos exp)
|
||||
#f)
|
||||
next-linkage/expects-single)])]
|
||||
#f)]))
|
||||
(let ([get-value-code
|
||||
(cond
|
||||
;; Special case: when set!-ing globals, see that they're defined first.
|
||||
[(GlobalBucket? prefix-element)
|
||||
(append-instruction-sequences
|
||||
(compile (ToplevelSet-value exp) cenv 'val next-linkage/expects-single)
|
||||
(make-Perform (make-CheckGlobalBound! (GlobalBucket-name prefix-element)))
|
||||
(make-AssignImmediate top-target (make-Reg 'val)))]
|
||||
[else
|
||||
(compile (ToplevelSet-value exp) cenv top-target next-linkage/expects-single)])]
|
||||
[singular-context-check (emit-singular-context linkage)])
|
||||
(end-with-linkage
|
||||
linkage
|
||||
|
|
Loading…
Reference in New Issue
Block a user