mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-22 19:44:10 +02:00
fixes so that typing asdfadfasff in the repl doesn't error
Before: > ,c (set! x 3) 0 (make-int8 3) ;; 3 2 (link "x") 5 (variable-set) > ,c (define x 3) 0 (make-int8 3) ;; 3 2 (link "x") 5 (variable-set) After: > ,c (define x 3) 0 (make-int8 3) ;; 3 2 (define "x") 5 (variable-set) * src/vm_loader.c (link): `link' now errors if the variable is undefined. This corresponds with desired behavior, for both `ref' and `set' operations, for scheme. It's not what elisp wants, though. Perhaps elisp linking needs another instruction. (define): New instruction, the same as calling scm_define(), basically. * module/language/scheme/translate.scm (trans-pair): Don't try to look up an existing variable definition when translating `define'; instead use the special-purpose lookup from ghil.scm's `ghil-define'. * module/system/il/compile.scm (codegen): Compile to a different kind of variable access from `set!', specifically via passing 'define as the op to `make-glil-var'. * module/system/il/ghil.scm (ghil-lookup): Don't add to the module table when compiling variable sets via `set!'. (ghil-define): New procedure, for looking up variables for `define'. * module/system/vm/assemble.scm (<vdefine>): New record: a new instruction type. (codegen): Compile `define' module vars into <vdefine>. (dump-object!): <vdefine> == `define'.
This commit is contained in:
parent
859f639074
commit
cd9d95d760
5 changed files with 41 additions and 26 deletions
|
@ -81,7 +81,7 @@
|
|||
<ghil-env> make-ghil-env ghil-env?
|
||||
ghil-env-mod ghil-env-parent ghil-env-table ghil-env-variables
|
||||
|
||||
ghil-primitive-macro? ghil-env-add! ghil-lookup
|
||||
ghil-primitive-macro? ghil-env-add! ghil-lookup ghil-define
|
||||
ghil-env-toplevel?
|
||||
call-with-ghil-environment call-with-ghil-bindings))
|
||||
|
||||
|
@ -192,15 +192,20 @@
|
|||
(record-case e
|
||||
((<ghil-mod> module table imports)
|
||||
(or (assq-ref table sym)
|
||||
(let ((var (make-ghil-var #f sym 'module)))
|
||||
(apush! sym var (ghil-mod-table e))
|
||||
var)))
|
||||
;; a free variable that we have not resolved
|
||||
(make-ghil-var #f sym 'module)))
|
||||
((<ghil-env> mod parent table variables)
|
||||
(let ((found (assq-ref table sym)))
|
||||
(if found
|
||||
(begin (set! (ghil-var-kind found) 'external) found)
|
||||
(loop parent))))))))
|
||||
|
||||
(define (ghil-define mod sym)
|
||||
(or (assq-ref (ghil-mod-table mod) sym)
|
||||
(let ((var (make-ghil-var mod sym 'module)))
|
||||
(apush! sym var (ghil-mod-table mod))
|
||||
var)))
|
||||
|
||||
(define (call-with-ghil-environment e syms func)
|
||||
(let* ((e (make-ghil-env e))
|
||||
(vars (map (lambda (s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue