-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Exercise_5_32.rkt
35 lines (30 loc) · 988 Bytes
/
Exercise_5_32.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#lang racket/base
;; a:
ev-application
(save continue)
(assign unev (op operands) (reg exp))
(assign exp (op operator) (reg exp))
(test (op variable?) (reg exp)) ;; ***
(branch (label ev-appl-symbol-operator))
(save env)
(save unev)
(assign continue (label ev-appl-did-operator))
(goto (label eval-dispatch))
ev-appl-symbol-operator
(assign continue (label ev-appl-did-symbol-operator))
(goto (label ev-variable))
ev-appl-did-operator
(restore unev) ;; the operands
(restore env)
ev-appl-did-symbol-operator
(assign argl (op empty-arglist))
(assign proc (reg val)) ;; the operator
(test (op no-operands?) (reg unev))
(branch (label apply-dispatch))
(save proc)
;; b:
;; it's a pain in the ass to write register machine code than
;; high level code and compiler will know all the code in advance
;; so it defiantly does more optimizations than evaluator
;; besides evaluator runs these optimization code at runtime for each
;; procedure but compiler run them when compiling just once