mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-17 22:22:25 +02:00
add multiple values support to the vm
* libguile/vm-engine.c (vm_run): The bootstrap program now uses mv_call, so as to allow multiple values out of the VM. (It did before, because multiple values were represented internally as single scm_values objects, but now that values go on the stack, we need to note the boot frame as accepting multiple values.) (vm_error_no_values): New error, happens if you pass no values into a single-value continuation. Passing more than one is OK though, it just takes the first one. * libguile/vm-i-system.c (halt): Assume that someone has pushed the number of values onto the stack, and package up that number of values as a scm_values() object, for communication with the interpreter. (mv-call): New instruction, calls a procedure with a multiple-value continuation, even handling calls out to the interpreter. (return/values): New instruction, returns multiple values to the continuation. If the continuation is single-valued, takes the first value or errors if there are no values. Otherwise it returns to the multiple-value return address, pushing the number of values on top of the values. * module/system/il/compile.scm (codegen): Compile <ghil-values> forms. * module/system/il/ghil.scm (<ghil-values>) Add new GHIL data structure and associated procedures. * module/language/scheme/translate.scm (custom-transformer-table): Compile (values .. ) forms into <ghil-values>.
This commit is contained in:
parent
7e97ad2dd6
commit
a222b0fa91
5 changed files with 161 additions and 5 deletions
|
@ -301,6 +301,17 @@
|
|||
(maybe-drop)
|
||||
(maybe-return))
|
||||
|
||||
((<ghil-values> env loc values)
|
||||
(cond (tail ;; (lambda () (values 1 2))
|
||||
(push-call! loc 'return/values values))
|
||||
(drop ;; (lambda () (values 1 2) 3)
|
||||
(for-each comp-drop values))
|
||||
(else ;; (lambda () (list (values 10 12) 1))
|
||||
(push-code! #f (make-glil-const #:obj 'values))
|
||||
(push-code! #f (make-glil-call #:inst 'link-now #:nargs 1))
|
||||
(push-code! #f (make-glil-call #:inst 'variable-ref #:nargs 0))
|
||||
(push-call! loc 'call values))))
|
||||
|
||||
((<ghil-call> env loc proc args)
|
||||
;; PROC
|
||||
;; ARGS...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue