-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathgenesis.kdl
131 lines (111 loc) · 2.65 KB
/
genesis.kdl
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
125
126
127
128
129
130
131
// T types
ctr {T0}
ctr {T1 x0}
ctr {T2 x0 x1}
ctr {T3 x0 x1 x2}
ctr {T4 x0 x1 x2 x3}
ctr {T5 x0 x1 x2 x3 x4}
ctr {T6 x0 x1 x2 x3 x4 x5}
ctr {T7 x0 x1 x2 x3 x4 x5 x6}
ctr {T8 x0 x1 x2 x3 x4 x5 x6 x7}
ctr {T9 x0 x1 x2 x3 x4 x5 x6 x7 x8}
ctr {TA x0 x1 x2 x3 x4 x5 x6 x7 x8 x9}
ctr {TB x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10}
ctr {TC x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11}
ctr {TD x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12}
ctr {TE x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13}
ctr {TF x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14}
ctr {TG x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15}
// An if-then-else statement
fun (If cond t f) {
(If #0 ~ f) = f
(If ~ t ~) = t
}
// Used to pretty-print names
ctr {Name name}
// Below, we declare the built-in IO operations
// DONE returns from an IO operation
ctr {DONE expr}
fun (Done expr) {
(Done expr) = {DONE expr}
}
// TAKE recovers an app's stored state
ctr {TAKE cont}
fun (Take) {
(Take) = @cont {TAKE cont}
}
// SAVE stores the app's state
ctr {SAVE expr cont}
fun (Save expr) {
(Save expr) = @cont {SAVE expr cont}
}
// CALL calls another IO operation, assigning
// the caller name to the current subject name
ctr {CALL name argm cont}
fun (Call name argm) {
(Call name argm) = @cont {CALL name argm cont}
}
// SUBJ returns the name of the current subject
ctr {SUBJ cont}
fun (Subj) {
(Subj) = @cont {SUBJ cont}
}
// FROM returns the name of the current caller
ctr {FROM cont}
fun (From) {
(From) = @cont {FROM cont}
}
// TICK returns the current block number
ctr {TICK cont}
fun (Tick) {
(Tick) = @cont {TICK cont}
}
ctr {GIDX name cont}
fun (GetIdx name) {
(GetIdx name) = @cont {GIDX name cont}
}
ctr {STH0 idx cont}
fun (GetStmHash0 idx) {
(GetStmHash0 idx) = @cont {STH0 idx cont}
}
ctr {STH1 idx cont}
fun (GetStmHash1 idx) {
(GetStmHash1 idx) = @cont {STH1 idx cont}
}
// TIME returns the current block timestamp
ctr {TIME cont}
fun (Time) {
(Time) = @cont {TIME cont}
}
// META returns the current block metadata
ctr {META cont}
fun (Meta) {
(Meta) = @cont {META cont}
}
// HAX0 returns the current block metadata
ctr {HAX0 cont}
fun (Hax0) {
(Hax0) = @cont {HAX0 cont}
}
// HAX1 returns the current block metadata
ctr {HAX1 cont}
fun (Hax1) {
(Hax1) = @cont {HAX1 cont}
}
// LOAD works like TAKE, but clones the state
fun (Load) {
(Load) = @cont {TAKE @x dup x0 x1 = x; {SAVE x0 @~ (cont x1)}}
}
// This is here for debugging. Will be removed.
ctr {Inc}
ctr {Get}
fun (Count action) {
(Count {Inc}) = {TAKE @x {SAVE (+ x #1) @~ {DONE #0}}}
(Count {Get}) = ((Load) @x {DONE x})
} with {
#0
}
// Registers the empty namespace.
reg {
#x7e5f4552091a69125d5dfcb7b8c265 // secret_key = 0x1
}