-
Notifications
You must be signed in to change notification settings - Fork 0
/
CFIB-HELPER.j
85 lines (77 loc) · 1.46 KB
/
CFIB-HELPER.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
.class FUN4
.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 FUN4/t LLispObject;
return
.end method
.method public <init>()V
.limit stack 2
.limit locals 1
aload_0
ldc "FUN4"
invokenonvirtual Procedure.<init>(Ljava/lang/String;)V
return
.end method
.method public run([LLispObject;)LLispObject;
.limit stack 255
.limit locals 255
;; (lambda (n a b) (if (= n 0) a (calc-fib (- n 1) b (+ a b))))
aload_1
ldc_w 0
aaload
astore 5
aload_1
ldc_w 1
aaload
astore 6
aload_1
ldc_w 2
aaload
astore 7
Lselftail:
;; (if (= n 0) a (calc-fib (- n 1) b (+ a b)))
aload 5
new LispFixnum
dup
ldc2_w 0
invokenonvirtual LispFixnum.<init>(J)V
invokevirtual java/lang/Object.equals(Ljava/lang/Object;)Z
ifeq L8
getstatic FUN4/t LLispObject;
goto L7
L8:
aconst_null
L7:
ifnonnull L6 ; branches to the true-expr
;; self-recursive tail-call args: ((- n 1) b (+ a b))
aload 5
checkcast LispNumber
new LispFixnum
dup
ldc2_w 1
invokenonvirtual LispFixnum.<init>(J)V
checkcast LispNumber
invokevirtual LispNumber.sub(LLispNumber;)LLispNumber;
aload 7
aload 6
checkcast LispNumber
aload 7
checkcast LispNumber
invokevirtual LispNumber.add(LLispNumber;)LLispNumber;
astore 7
astore 6
astore 5
goto Lselftail
goto L5 ; Don't also run the true-expr like a fool
L6:
aload 6
L5:
;; endif
areturn
;; endlambda
.end method