Getting the prefix reference stuff working.
This commit is contained in:
parent
d9bb1dd631
commit
c9ddc357e0
|
@ -344,6 +344,9 @@
|
||||||
;; 2. Next, evaluate the module body.
|
;; 2. Next, evaluate the module body.
|
||||||
(make-instruction-sequence
|
(make-instruction-sequence
|
||||||
`(,(make-PerformStatement (make-ExtendEnvironment/Prefix! names))))
|
`(,(make-PerformStatement (make-ExtendEnvironment/Prefix! names))))
|
||||||
|
|
||||||
|
(make-AssignImmediateStatement (make-ModulePrefixTarget path)
|
||||||
|
(make-EnvWholePrefixReference 0))
|
||||||
;; TODO: we need to sequester the prefix of the module with the record.
|
;; TODO: we need to sequester the prefix of the module with the record.
|
||||||
(compile (Module-code mod)
|
(compile (Module-code mod)
|
||||||
(cons (Module-prefix mod) module-cenv)
|
(cons (Module-prefix mod) module-cenv)
|
||||||
|
@ -2122,6 +2125,8 @@
|
||||||
[(PrimitivesReference? target)
|
[(PrimitivesReference? target)
|
||||||
target]
|
target]
|
||||||
[(ControlFrameTemporary? target)
|
[(ControlFrameTemporary? target)
|
||||||
|
target]
|
||||||
|
[(ModulePrefixTarget? target)
|
||||||
target]))
|
target]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
EnvLexicalReference
|
EnvLexicalReference
|
||||||
EnvPrefixReference
|
EnvPrefixReference
|
||||||
PrimitivesReference
|
PrimitivesReference
|
||||||
ControlFrameTemporary))
|
ControlFrameTemporary
|
||||||
|
ModulePrefixTarget))
|
||||||
|
|
||||||
|
|
||||||
;; When we need to store a value temporarily in the top control frame, we can use this as a target.
|
;; When we need to store a value temporarily in the top control frame, we can use this as a target.
|
||||||
|
@ -57,6 +58,11 @@
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
;; Targetting the prefix attribute of a module.
|
||||||
|
(define-struct: ModulePrefixTarget ([path : ModuleLocator])
|
||||||
|
#:transparent)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-struct: Label ([name : Symbol])
|
(define-struct: Label ([name : Symbol])
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
|
|
@ -82,7 +82,10 @@
|
||||||
[(PrimitivesReference? target)
|
[(PrimitivesReference? target)
|
||||||
(format "MACHINE.primitives[~s]" (symbol->string (PrimitivesReference-name target)))]
|
(format "MACHINE.primitives[~s]" (symbol->string (PrimitivesReference-name target)))]
|
||||||
[(ControlFrameTemporary? target)
|
[(ControlFrameTemporary? target)
|
||||||
(assemble-control-frame-temporary target)]))
|
(assemble-control-frame-temporary target)]
|
||||||
|
[(ModulePrefixTarget? target)
|
||||||
|
(format "MACHINE.modules[~s].prefix"
|
||||||
|
(symbol->string (ModuleLocator-name (ModulePrefixTarget-path target))))]))
|
||||||
|
|
||||||
|
|
||||||
(: assemble-control-frame-temporary (ControlFrameTemporary -> String))
|
(: assemble-control-frame-temporary (ControlFrameTemporary -> String))
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.isInvoked = false;
|
this.isInvoked = false;
|
||||||
this.exports = {};
|
this.prefix = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@
|
||||||
[self-path : Symbol]
|
[self-path : Symbol]
|
||||||
[label : Symbol]
|
[label : Symbol]
|
||||||
[invoked? : Boolean]
|
[invoked? : Boolean]
|
||||||
[exports : (HashTable Symbol PrimitiveValue)])
|
[exports : (HashTable Symbol PrimitiveValue)]
|
||||||
|
[toplevel : (U False toplevel)])
|
||||||
#:transparent
|
#:transparent
|
||||||
#:mutable)
|
#:mutable)
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,8 @@
|
||||||
(InstallModuleEntry!-path op))
|
(InstallModuleEntry!-path op))
|
||||||
(InstallModuleEntry!-entry-point op)
|
(InstallModuleEntry!-entry-point op)
|
||||||
#f
|
#f
|
||||||
(make-hash)))
|
(make-hash)
|
||||||
|
#f))
|
||||||
'ok]
|
'ok]
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,6 +555,15 @@
|
||||||
(hash-set! ht
|
(hash-set! ht
|
||||||
(ControlFrameTemporary-name t)
|
(ControlFrameTemporary-name t)
|
||||||
(ensure-primitive-value v))
|
(ensure-primitive-value v))
|
||||||
|
'ok))]
|
||||||
|
[(ModulePrefixTarget? t)
|
||||||
|
(lambda: ([m : machine] [v : SlotValue])
|
||||||
|
(let ([module-record
|
||||||
|
(hash-ref (machine-modules m)
|
||||||
|
(ModuleLocator-name
|
||||||
|
(ModulePrefixTarget-path t)))])
|
||||||
|
(set-module-record-toplevel! module-record
|
||||||
|
(ensure-toplevel v))
|
||||||
'ok))]))
|
'ok))]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user