1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 02:00:26 +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:
Andy Wingo 2008-05-12 00:22:36 +02:00
parent 859f639074
commit cd9d95d760
5 changed files with 41 additions and 26 deletions

View file

@ -44,6 +44,7 @@
(define-record (<venv> parent nexts closure?))
(define-record (<vmod> id))
(define-record (<vlink> module name))
(define-record (<vdefine> module name))
(define-record (<bytespec> vars bytes meta objs closure?))
@ -146,10 +147,16 @@
(push-code! `(external-set ,(+ n index)))))))
((<glil-module> op module name)
(push-object! (make-vlink :module #f :name name))
(if (eq? op 'ref)
(push-code! '(variable-ref))
(push-code! '(variable-set))))
(case op
((ref)
(push-object! (make-vlink :module module :name name))
(push-code! '(variable-ref)))
((set)
(push-object! (make-vlink :module module :name name))
(push-code! '(variable-set)))
((define)
(push-object! (make-vdefine :module module :name name))
(push-code! '(variable-set)))))
((<glil-label> label)
(set! label-alist (assq-set! label-alist label (current-address))))
@ -252,6 +259,9 @@
((<vlink> module name)
;; FIXME: dump module
(push-code! `(link ,(symbol->string name))))
((<vdefine> module name)
;; FIXME: dump module
(push-code! `(define ,(symbol->string name))))
((<vmod> id)
(push-code! `(load-module ,id)))
(else