Right in the middle of getting global references to work.

This commit is contained in:
Danny Yoo 2013-03-03 15:28:02 -07:00
parent cd5e6ee180
commit 35d154345b
3 changed files with 33 additions and 6 deletions

View File

@ -448,9 +448,16 @@
(make-EnvPrefixReference (ToplevelRef-depth exp) (make-EnvPrefixReference (ToplevelRef-depth exp)
(ToplevelRef-pos exp) (ToplevelRef-pos exp)
#t))])] #t))])]
[(GlobalBucket? prefix-element)
(append-instruction-sequences
(if (ToplevelRef-check-defined? exp)
(make-Perform (make-CheckGlobalBound! (GlobalBucket-name prefix-element)))
empty-instruction-sequence)
(make-AssignImmediate
target
(make-GlobalsReference (GlobalBucket-name prefix-element))))]
[(or (eq? prefix-element #f) [(or (eq? prefix-element #f)
(symbol? prefix-element) (symbol? prefix-element))
(GlobalBucket? prefix-element))
(append-instruction-sequences (append-instruction-sequences
(if (ToplevelRef-check-defined? exp) (if (ToplevelRef-check-defined? exp)
(make-Perform (make-CheckToplevelBound! (make-Perform (make-CheckToplevelBound!
@ -487,9 +494,13 @@
(ToplevelSet-pos exp) (ToplevelSet-pos exp)
#t) #t)
next-linkage/expects-single)] next-linkage/expects-single)]
[(GlobalBucket? prefix-element)
(compile (ToplevelSet-value exp)
cenv
(make-GlobalsReference (GlobalBucket-name prefix-element))
next-linkage/expects-single)]
[(or (eq? prefix-element #f) [(or (eq? prefix-element #f)
(symbol? prefix-element) (symbol? prefix-element))
(GlobalBucket? prefix-element))
(compile (ToplevelSet-value exp) (compile (ToplevelSet-value exp)
cenv cenv
(make-EnvPrefixReference (ToplevelSet-depth exp) (make-EnvPrefixReference (ToplevelSet-depth exp)

View File

@ -38,6 +38,7 @@
ModulePredicate ModulePredicate
PrimitiveKernelValue PrimitiveKernelValue
VariableReference VariableReference
GlobalsReference
)) ))
@ -45,7 +46,8 @@
(define-type Target (U AtomicRegisterSymbol (define-type Target (U AtomicRegisterSymbol
EnvLexicalReference EnvLexicalReference
EnvPrefixReference EnvPrefixReference
PrimitivesReference PrimitivesReference
GlobalsReference
ControlFrameTemporary ControlFrameTemporary
ModulePrefixTarget ModulePrefixTarget
)) ))
@ -152,6 +154,10 @@
(define-struct: PrimitivesReference ([name : Symbol]) (define-struct: PrimitivesReference ([name : Symbol])
#:transparent) #:transparent)
(define-struct: GlobalsReference ([name : Symbol])
#:transparent)
;; Produces the entry point of the module. ;; Produces the entry point of the module.
(define-struct: ModuleEntry ([name : ModuleLocator]) (define-struct: ModuleEntry ([name : ModuleLocator])
#:transparent) #:transparent)
@ -313,6 +319,7 @@
ModuleVariable ModuleVariable
PrimitivesReference PrimitivesReference
GlobalsReference
MakeBoxedEnvironmentValue MakeBoxedEnvironmentValue
@ -398,6 +405,12 @@
[pos : Natural]) [pos : Natural])
#:transparent) #:transparent)
;; Check that the global can be defined.
;; If not, raise an error and stop evaluation.
(define-struct: CheckGlobalBound! ([name : Symbol])
#:transparent)
;; Check the closure procedure value in 'proc and make sure it's a closure ;; Check the closure procedure value in 'proc and make sure it's a closure
;; that can accept the right arguments (stored as a number in the argcount register.). ;; that can accept the right arguments (stored as a number in the argcount register.).
(define-struct: CheckClosureAndArity! () (define-struct: CheckClosureAndArity! ()
@ -511,6 +524,7 @@
(define-type PrimitiveCommand (U (define-type PrimitiveCommand (U
CheckToplevelBound! CheckToplevelBound!
CheckGlobalBound!
CheckClosureAndArity! CheckClosureAndArity!
CheckPrimitiveArity! CheckPrimitiveArity!

View File

@ -147,7 +147,9 @@
[(PrimitivesReference? op) [(PrimitivesReference? op)
op] op]
))
[(GlobalsReference? op)
op]))
(: rewrite-primcmd (PrimitiveCommand -> PrimitiveCommand)) (: rewrite-primcmd (PrimitiveCommand -> PrimitiveCommand))