Repository navigation
Expand file tree
/
Copy pathruntime.84
More file actions
181 lines (169 loc) · 5.02 KB
/
Copy pathruntime.84
File metadata and controls
181 lines (169 loc) · 5.02 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{
: encode_small_integer
: prim_arity
: prim_short_name
}
Where
Define (encode_small_integer n)
[2 * n]
Define (prim_arity name)
Match (MAP.search prim_arities name) {
| 'just.{_ arity} arity
| 'nothing
(die (STRING.concat ["No such primitive \"" & name & "\"." & 'nil]))
}
Define (prim_short_name name)
Match (MAP.search prim_short_names name) {
| 'just.{_ short_name} short_name
| 'nothing
(die (STRING.concat ["No such primitive \"" & name & "\"." & 'nil]))
}
Where
Let prim_arities
Define (construct_map arity_list)
(LIST.reduce arity_list MAP.empty MAP.insert)
In
(construct_map
(Reduce &
{"exec" 4}
{"exit" 1}
{"getcwd" 0}
{"open" 3}
{"close" 1}
{"read" 4}
{"write" 4}
{"die" 1}
{"command_argc" 0}
{"command_argv" 1}
{"file_create" 1}
{"file_open" 1}
{"file_close" 1}
{"file_read_all" 1}
{"string_length" 1}
{"string_fetch" 2}
{"string_equal" 2}
{"string_compare" 2}
{"string_append" 2}
{"string_clip" 3}
{"mmap" 6}
{"munmap" 1}
{"epoll_create1" 1}
{"epoll_ctl" 4}
{"epoll_wait" 4}
{"chunk_global" 1}
{"chunk_new" 1}
{"chunk_size" 1}
{"chunk_store_bytes" 5}
{"chunk_fetch_bytes_ro" 3}
{"chunk_fetch_bytes_rw" 3}
{"chunk_store_uint8" 3}
{"chunk_fetch_uint8" 2}
{"chunk_store_int8" 3}
{"chunk_fetch_int8" 2}
{"chunk_store_uint16_le" 3}
{"chunk_fetch_uint16_le" 2}
{"chunk_store_int16_le" 3}
{"chunk_fetch_int16_le" 2}
{"chunk_store_uint32_le" 3}
{"chunk_fetch_uint32_le" 2}
{"chunk_store_int32_le" 3}
{"chunk_fetch_int32_le" 2}
{"chunk_store_uint64_le" 3}
{"chunk_fetch_uint64_le" 2}
{"chunk_store_int64_le" 3}
{"chunk_fetch_int64_le" 2}
{"negate" 1}
{"quotient" 2}
{"remainder" 2}
{"multiply" 2}
{"add" 2}
{"subtract" 2}
{"less" 2}
{"less_or_equal" 2}
{"greater" 2}
{"greater_or_equal" 2}
{"equal" 2}
{"print" 1}
{"print_line" 1}
{"show_integer" 1}
{"compose" 2}
'nil))
Let prim_short_names
Define (construct_map list)
(LIST.reduce list MAP.empty MAP.insert)
In
(construct_map
(Reduce &
{"exec" "s00"}
{"exit" "s05"}
{"getcwd" "s85"}
{"open" "s03"}
{"close" "s72"}
{"read" "s67"}
{"write" "s41"}
{"die" "s26"}
{"command_argc" "s40"}
{"command_argv" "s24"}
{"print" "s18"}
{"print_line" "s79"}
{"file_create" "s20"}
{"file_open" "s23"}
{"file_close" "s92"}
{"file_read_all" "s28"}
{"show_integer" "s12"}
{"compose" "s22"}
{"multiply" "s93"}
{"add" "s19"}
{"subtract" "s47"}
{"negate" "s84"}
{"quotient" "s91"}
{"remainder" "s43"}
{"equal" "s50"}
{"less" "s10"}
{"less_or_equal" "s63"}
{"greater" "s61"}
{"greater_or_equal" "s55"}
{"string_length" "s65"}
{"string_fetch" "s69"}
{"string_compare" "s37"}
{"string_equal" "s45"}
{"string_append" "s25"}
{"string_clip" "s44"}
{"mmap" "s95"}
{"munmap" "s56"}
{"epoll_create1" "s71"}
{"epoll_ctl" "s60"}
{"epoll_wait" "s97"}
{"chunk_global" "s04"}
{"chunk_new" "s38"}
{"chunk_size" "s14"}
{"chunk_store_bytes" "s82"}
{"chunk_fetch_bytes_ro" "s11"}
{"chunk_fetch_bytes_rw" "s39"}
{"chunk_store_uint8" "s42"}
{"chunk_fetch_uint8" "s13"}
{"chunk_store_int8" "s76"}
{"chunk_fetch_int8" "s46"}
{"chunk_store_uint16_le" "s54"}
{"chunk_fetch_uint16_le" "s29"}
{"chunk_store_int16_le" "s08"}
{"chunk_fetch_int16_le" "s98"}
{"chunk_store_uint32_le" "s74"}
{"chunk_fetch_uint32_le" "s01"}
{"chunk_store_int32_le" "s17"}
{"chunk_fetch_int32_le" "s59"}
{"chunk_store_uint64_le" "s21"}
{"chunk_fetch_uint64_le" "s99"}
{"chunk_store_int64_le" "s58"}
{"chunk_fetch_int64_le" "s80"}
'nil))
Where
Let MAP
(SEARCH.MAP STRING.compare
Func {key _} key)
Let die OS.die
Where
Let LIST Package "list"
Let OS Package "os"
Let SEARCH Package "search"
Let STRING Package "string"