call/cc looks like it's starting to work.
This commit is contained in:
parent
fc866634cf
commit
aecc0ad896
|
@ -599,9 +599,9 @@
|
|||
;; abandon the current continuation, initialize the control and environment, and then jump.
|
||||
(make-instruction-sequence `(,call/cc-closure-entry
|
||||
,(make-AssignImmediateStatement 'val (make-EnvLexicalReference 0))
|
||||
,(make-PerformStatement (make-InstallClosureValues!))
|
||||
,(make-PerformStatement (make-RestoreControl!))
|
||||
,(make-PerformStatement (make-RestoreEnvironment!))
|
||||
|
||||
,(make-AssignPrimOpStatement 'proc (make-GetControlStackLabel))
|
||||
,(make-PopControlFrame)
|
||||
,(make-GotoStatement (make-Reg 'proc))))))
|
||||
|
|
|
@ -198,6 +198,7 @@
|
|||
|
||||
[(RestoreEnvironment!? op)
|
||||
(set-machine-env! m (CapturedEnvironment-vals (ensure-CapturedEnvironment (env-ref m 1))))
|
||||
(set-machine-stack-size! m (length (machine-env m)))
|
||||
'ok])))
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#'stx))
|
||||
(unless (= (machine-stack-size a-machine) 1)
|
||||
(raise-syntax-error #f (format "Stack is not back to the prefix as expected!")
|
||||
|
||||
#'stx))
|
||||
(unless (null? (machine-control a-machine))
|
||||
(raise-syntax-error #f (format "Control is not empty as expected!")
|
||||
|
@ -536,11 +537,11 @@
|
|||
32)
|
||||
|
||||
|
||||
(test (let ([x 16])
|
||||
(call/cc (lambda (k)
|
||||
(k "escape!")
|
||||
(+ x x))))
|
||||
"escape!")
|
||||
(test (add1 (let ([x 16])
|
||||
(call/cc (lambda (k)
|
||||
(k 0)
|
||||
(+ x x)))))
|
||||
1)
|
||||
|
||||
|
||||
;(simulate (compile (parse '42) 'val 'next))
|
||||
|
|
Loading…
Reference in New Issue
Block a user