-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCFIB.j
124 lines (116 loc) · 2.32 KB
/
CFIB.j
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.class CFIB
.super Procedure
.field private static final t LLispObject;
.method static <clinit>()V
.limit locals 255
.limit stack 255
ldc_w "t"
invokestatic Symbol.intern(Ljava/lang/String;)LSymbol;
putstatic CFIB/t LLispObject;
return
.end method
.method public <init>()V
.limit stack 2
.limit locals 1
aload_0
ldc "CFIB"
invokenonvirtual Procedure.<init>(Ljava/lang/String;)V
return
.end method
.method public run([LLispObject;)LLispObject;
.limit stack 255
.limit locals 255
;; (lambda (n) (if (= n 0) 0 (if (= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))))
aload_1
ldc_w 0
aaload
astore 5
Lselftail:
;; (if (= n 0) 0 (if (= n 1) 1 (+ (fib (- n 1)) (fib (- n 2)))))
aload 5
new LispFixnum
dup
ldc2_w 0
invokenonvirtual LispFixnum.<init>(J)V
invokevirtual java/lang/Object.equals(Ljava/lang/Object;)Z
ifeq L4
getstatic CFIB/t LLispObject;
goto L3
L4:
aconst_null
L3:
ifnonnull L2 ; branches to the true-expr
;; (if (= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))
aload 5
new LispFixnum
dup
ldc2_w 1
invokenonvirtual LispFixnum.<init>(J)V
invokevirtual java/lang/Object.equals(Ljava/lang/Object;)Z
ifeq L8
getstatic CFIB/t LLispObject;
goto L7
L8:
aconst_null
L7:
ifnonnull L6 ; branches to the true-expr
;; (fib (- n 1))
aload 0
checkcast Procedure
; preparing args
ldc_w 1
anewarray LispObject
dup
ldc_w 0
aload 5
checkcast LispNumber
new LispFixnum
dup
ldc2_w 1
invokenonvirtual LispFixnum.<init>(J)V
checkcast LispNumber
invokevirtual LispNumber.sub(LLispNumber;)LLispNumber;
aastore
; end preparing args
invokevirtual Procedure.run([LLispObject;)LLispObject;
checkcast LispNumber
;; (fib (- n 2))
aload 0
checkcast Procedure
; preparing args
ldc_w 1
anewarray LispObject
dup
ldc_w 0
aload 5
checkcast LispNumber
new LispFixnum
dup
ldc2_w 2
invokenonvirtual LispFixnum.<init>(J)V
checkcast LispNumber
invokevirtual LispNumber.sub(LLispNumber;)LLispNumber;
aastore
; end preparing args
invokevirtual Procedure.run([LLispObject;)LLispObject;
checkcast LispNumber
invokevirtual LispNumber.add(LLispNumber;)LLispNumber;
goto L5 ; Don't also run the true-expr like a fool
L6:
new LispFixnum
dup
ldc2_w 1
invokenonvirtual LispFixnum.<init>(J)V
L5:
;; endif
goto L1 ; Don't also run the true-expr like a fool
L2:
new LispFixnum
dup
ldc2_w 0
invokenonvirtual LispFixnum.<init>(J)V
L1:
;; endif
areturn
;; endlambda
.end method