-
Notifications
You must be signed in to change notification settings - Fork 0
/
fact2
84 lines (84 loc) · 2.89 KB
/
fact2
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
((env)
(val)
((assign env (op get-global-env))
(assign
val
(op make-compiled-procedure)
(label entry2)
(reg env))
(goto (label after-lambda1)) entry2
(assign env (op compiled-procedure-env) (reg proc))
(assign env (op extend-environment) (const (n)) (reg argl)
(reg env))
(save continue) (save env)
(assign proc (op lookup-variable-value) (const =) (reg env))
(assign val (const 1)) (assign argl (op list) (reg val))
(assign val (op lookup-variable-value) (const n) (reg env))
(assign argl (op cons) (reg val) (reg argl))
(test (op primitive-procedure?) (reg proc))
(branch (label primitive-branch17)) compiled-branch16
(assign continue (label after-call15))
(assign val (op compiled-procedure-entry) (reg proc))
(goto (reg val)) primitive-branch17
(assign
val
(op apply-primitive-procedure)
(reg proc)
(reg argl))
after-call15 (restore env) (restore continue)
(test (op false?) (reg val)) (branch (label false-branch4))
true-branch5 (assign val (const 1)) (goto (reg continue))
false-branch4
(assign proc (op lookup-variable-value) (const *) (reg env))
(save continue) (save proc) (save env)
(assign
proc
(op lookup-variable-value)
(const factorial-alt)
(reg env))
(save proc)
(assign proc (op lookup-variable-value) (const -) (reg env))
(assign val (const 1)) (assign argl (op list) (reg val))
(assign val (op lookup-variable-value) (const n) (reg env))
(assign argl (op cons) (reg val) (reg argl))
(test (op primitive-procedure?) (reg proc))
(branch (label primitive-branch8)) compiled-branch7
(assign continue (label after-call6))
(assign val (op compiled-procedure-entry) (reg proc))
(goto (reg val)) primitive-branch8
(assign
val
(op apply-primitive-procedure)
(reg proc)
(reg argl))
after-call6 (assign argl (op list) (reg val)) (restore proc)
(test (op primitive-procedure?) (reg proc))
(branch (label primitive-branch11)) compiled-branch10
(assign continue (label after-call9))
(assign val (op compiled-procedure-entry) (reg proc))
(goto (reg val)) primitive-branch11
(assign
val
(op apply-primitive-procedure)
(reg proc)
(reg argl))
after-call9 (assign argl (op list) (reg val)) (restore env)
(assign val (op lookup-variable-value) (const n) (reg env))
(assign argl (op cons) (reg val) (reg argl)) (restore proc)
(restore continue)
(test (op primitive-procedure?) (reg proc))
(branch (label primitive-branch14)) compiled-branch13
(assign val (op compiled-procedure-entry) (reg proc))
(goto (reg val)) primitive-branch14
(assign
val
(op apply-primitive-procedure)
(reg proc)
(reg argl))
(goto (reg continue)) after-call12 after-if3 after-lambda1
(perform
(op define-variable!)
(const factorial-alt)
(reg val)
(reg env))
(assign val (const ok))))