mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 20:30:28 +02:00
`link' instruction links to symbols by module
* module/system/il/compile.scm (make-glil-var): Only dump the module if we actually have one. * module/system/il/ghil.scm (ghil-define): Make sure that ghil-var-env is a ghil-env. * src/vm_loader.c (link): * module/system/vm/assemble.scm (dump-object!): Rewrite `link' to take two Scheme arguments on the stack: the symbol, as before, and the module in which the symbol was found at compile time. This introduces some undesireable early binding, but it does let the vm load up modules, and (potentially) have multiple modules in one .go file. On a practical level, I can now compile modules and have their .go files load up the modules' dependencies as necessary.
This commit is contained in:
parent
26e69c9469
commit
6167de4f72
4 changed files with 23 additions and 14 deletions
|
@ -100,8 +100,9 @@
|
|||
((eq? e (ghil-var-env var))
|
||||
(make-glil-external op depth (ghil-var-index var)))))
|
||||
((module)
|
||||
(make-glil-module op (ghil-mod-module (ghil-env-mod (ghil-var-env var)))
|
||||
(ghil-var-name var)))
|
||||
(let ((env (ghil-var-env var)))
|
||||
(make-glil-module op (and env (ghil-mod-module (ghil-env-mod env)))
|
||||
(ghil-var-name var))))
|
||||
(else (error "Unknown kind of variable:" var))))
|
||||
|
||||
(define (codegen ghil)
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
|
||||
(define (ghil-define mod sym)
|
||||
(or (assq-ref (ghil-mod-table mod) sym)
|
||||
(let ((var (make-ghil-var mod sym 'module)))
|
||||
(let ((var (make-ghil-var (make-ghil-env mod) sym 'module)))
|
||||
(apush! sym var (ghil-mod-table mod))
|
||||
var)))
|
||||
|
||||
|
|
|
@ -257,8 +257,9 @@
|
|||
;; dump bytecode
|
||||
(push-code! `(load-program ,bytes)))
|
||||
((<vlink> module name)
|
||||
;; FIXME: dump module
|
||||
(push-code! `(link ,(symbol->string name))))
|
||||
(dump! (and=> module module-name))
|
||||
(dump! name)
|
||||
(push-code! '(link)))
|
||||
((<vdefine> module name)
|
||||
;; FIXME: dump module
|
||||
(push-code! `(define ,(symbol->string name))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue