Implement 5.48

This commit is contained in:
2021-05-01 18:08:17 -04:00
parent 90bd09efc1
commit 363f49d434
2 changed files with 36 additions and 3 deletions

View File

@@ -57,6 +57,16 @@
(set-register-contents! eceval 'flag true)
(start eceval)))
;;; For 5.48 ec-compile-and-run
(define (compile-and-run? expression)
(tagged-list? expression 'compile-and-run))
(define (compile-and-run expression)
(let ((instructions
(assemble (statements
(compile (cadr expression) 'val 'return))
eceval)))
(set-register-contents! eceval 'val instructions)))
;;**NB. To [not] monitor stack operations, comment in/[out] the line after
;; print-result in the machine controller below
;;**Also choose the desired make-stack version in regsim.scm
@@ -128,6 +138,10 @@
(list 'compiled-procedure? compiled-procedure?)
(list 'compiled-procedure-entry compiled-procedure-entry)
(list 'compiled-procedure-env compiled-procedure-env)
;; ex-5.48
(list 'compile-and-run? compile-and-run?)
(list 'compile-and-run compile-and-run)
))
(define eceval
@@ -196,6 +210,8 @@ eval-dispatch
(branch (label ev-lambda))
(test (op begin?) (reg exp))
(branch (label ev-begin))
(test (op compile-and-run?) (reg exp))
(branch (label compile-and-run))
(test (op application?) (reg exp))
(branch (label ev-application))
(goto (label unknown-expression-type))
@@ -216,6 +232,10 @@ ev-lambda
(reg unev) (reg exp) (reg env))
(goto (reg continue))
compile-and-run
(perform (op compile-and-run) (reg exp))
(goto (reg val))
ev-application
(save continue)
(save env)