@@ -0,0 +1,327 @@
1+#include "idris_rts.h"
2+
3+VAL idris_b8CopyForGC(VM *vm, VAL a) {
4+ VAL cl = allocate(vm, sizeof(Closure), 1);
5+ SETTY(cl, BITS8);
6+ cl->info.bits8 = a->info.bits8;
7+ return cl;
8+}
9+
10+VAL idris_b16CopyForGC(VM *vm, VAL a) {
11+ VAL cl = allocate(vm, sizeof(Closure), 1);
12+ SETTY(cl, BITS16);
13+ cl->info.bits16 = a->info.bits16;
14+ return cl;
15+}
16+
17+VAL idris_b32CopyForGC(VM *vm, VAL a) {
18+ VAL cl = allocate(vm, sizeof(Closure), 1);
19+ SETTY(cl, BITS32);
20+ cl->info.bits32 = a->info.bits32;
21+ return cl;
22+}
23+
24+VAL idris_b64CopyForGC(VM *vm, VAL a) {
25+ VAL cl = allocate(vm, sizeof(Closure), 1);
26+ SETTY(cl, BITS64);
27+ cl->info.bits64 = a->info.bits64;
28+ return cl;
29+}
30+
31+VAL idris_b8(VM *vm, VAL a) {
32+ VAL cl = allocate(vm, sizeof(Closure), 0);
33+ SETTY(cl, BITS8);
34+ cl->info.bits8 = (uint8_t) GETINT(a);
35+ return cl;
36+}
37+
38+VAL idris_b16(VM *vm, VAL a) {
39+ VAL cl = allocate(vm, sizeof(Closure), 0);
40+ SETTY(cl, BITS16);
41+ cl->info.bits16 = (uint16_t) GETINT(a);
42+ return cl;
43+}
44+
45+VAL idris_b32(VM *vm, VAL a) {
46+ VAL cl = allocate(vm, sizeof(Closure), 0);
47+ SETTY(cl, BITS32);
48+ cl->info.bits32 = (uint32_t) GETINT(a);
49+ return cl;
50+}
51+
52+VAL idris_b64(VM *vm, VAL a) {
53+ VAL cl = allocate(vm, sizeof(Closure), 0);
54+ SETTY(cl, BITS64);
55+ cl->info.bits64 = (uint64_t) GETINT(a);
56+ return cl;
57+}
58+
59+VAL idris_b8Plus(VM *vm, VAL a, VAL b) {
60+ VAL cl = allocate(vm, sizeof(Closure), 0);
61+ SETTY(cl, BITS8);
62+ cl->info.bits8 = a->info.bits8 + b->info.bits8;
63+ return cl;
64+}
65+
66+VAL idris_b8Minus(VM *vm, VAL a, VAL b) {
67+ VAL cl = allocate(vm, sizeof(Closure), 0);
68+ SETTY(cl, BITS8);
69+ cl->info.bits8 = a->info.bits8 - b->info.bits8;
70+ return cl;
71+}
72+
73+VAL idris_b8Times(VM *vm, VAL a, VAL b) {
74+ VAL cl = allocate(vm, sizeof(Closure), 0);
75+ SETTY(cl, BITS8);
76+ cl->info.bits8 = a->info.bits8 * b->info.bits8;
77+ return cl;
78+}
79+
80+VAL idris_b8UDiv(VM *vm, VAL a, VAL b) {
81+ VAL cl = allocate(vm, sizeof(Closure), 0);
82+ SETTY(cl, BITS8);
83+ cl->info.bits8 = a->info.bits8 / b->info.bits8;
84+ return cl;
85+}
86+
87+VAL idris_b8SDiv(VM *vm, VAL a, VAL b) {
88+ VAL cl = allocate(vm, sizeof(Closure), 0);
89+ SETTY(cl, BITS8);
90+ cl->info.bits8 = (uint8_t) (((int8_t) a->info.bits8) / ((int8_t) b->info.bits8));
91+ return cl;
92+}
93+
94+VAL idris_b8Z16(VM *vm, VAL a) {
95+ VAL cl = allocate(vm, sizeof(Closure), 0);
96+ SETTY(cl, BITS16);
97+ cl->info.bits16 = (uint16_t) a->info.bits8;
98+ return cl;
99+}
100+
101+VAL idris_b8Z32(VM *vm, VAL a) {
102+ VAL cl = allocate(vm, sizeof(Closure), 0);
103+ SETTY(cl, BITS32);
104+ cl->info.bits32 = (uint32_t) a->info.bits8;
105+ return cl;
106+}
107+
108+VAL idris_b8Z64(VM *vm, VAL a) {
109+ VAL cl = allocate(vm, sizeof(Closure), 0);
110+ SETTY(cl, BITS16);
111+ cl->info.bits64 = (uint64_t) a->info.bits8;
112+ return cl;
113+}
114+
115+VAL idris_b8S16(VM *vm, VAL a) {
116+ VAL cl = allocate(vm, sizeof(Closure), 0);
117+ SETTY(cl, BITS16);
118+ cl->info.bits16 = (uint16_t) (int16_t) (int8_t) a->info.bits8;
119+ return cl;
120+}
121+
122+VAL idris_b8S32(VM *vm, VAL a) {
123+ VAL cl = allocate(vm, sizeof(Closure), 0);
124+ SETTY(cl, BITS32);
125+ cl->info.bits32 = (uint32_t) (int32_t) (int8_t) a->info.bits8;
126+ return cl;
127+}
128+
129+VAL idris_b8S64(VM *vm, VAL a) {
130+ VAL cl = allocate(vm, sizeof(Closure), 0);
131+ SETTY(cl, BITS64);
132+ cl->info.bits64 = (uint64_t) (int64_t) (int8_t) a->info.bits8;
133+ return cl;
134+}
135+
136+VAL idris_b16Plus(VM *vm, VAL a, VAL b) {
137+ VAL cl = allocate(vm, sizeof(Closure), 0);
138+ SETTY(cl, BITS16);
139+ cl->info.bits16 = a->info.bits16 + b->info.bits16;
140+ return cl;
141+}
142+
143+VAL idris_b16Minus(VM *vm, VAL a, VAL b) {
144+ VAL cl = allocate(vm, sizeof(Closure), 0);
145+ SETTY(cl, BITS16);
146+ cl->info.bits16 = a->info.bits16 - b->info.bits16;
147+ return cl;
148+}
149+
150+VAL idris_b16Times(VM *vm, VAL a, VAL b) {
151+ VAL cl = allocate(vm, sizeof(Closure), 0);
152+ SETTY(cl, BITS16);
153+ cl->info.bits16 = a->info.bits16 * b->info.bits16;
154+ return cl;
155+}
156+
157+VAL idris_b16UDiv(VM *vm, VAL a, VAL b) {
158+ VAL cl = allocate(vm, sizeof(Closure), 0);
159+ SETTY(cl, BITS16);
160+ cl->info.bits16 = a->info.bits16 / b->info.bits16;
161+ return cl;
162+}
163+
164+VAL idris_b16SDiv(VM *vm, VAL a, VAL b) {
165+ VAL cl = allocate(vm, sizeof(Closure), 0);
166+ SETTY(cl, BITS16);
167+ cl->info.bits16 =
168+ (uint16_t) (((int16_t) a->info.bits16) / ((int16_t) b->info.bits16));
169+ return cl;
170+}
171+
172+VAL idris_b16Z32(VM *vm, VAL a) {
173+ VAL cl = allocate(vm, sizeof(Closure), 0);
174+ SETTY(cl, BITS32);
175+ cl->info.bits32 = (uint32_t) a->info.bits16;
176+ return cl;
177+}
178+
179+VAL idris_b16Z64(VM *vm, VAL a) {
180+ VAL cl = allocate(vm, sizeof(Closure), 0);
181+ SETTY(cl, BITS64);
182+ cl->info.bits64 = (uint64_t) a->info.bits16;
183+ return cl;
184+}
185+
186+VAL idris_b16S32(VM *vm, VAL a) {
187+ VAL cl = allocate(vm, sizeof(Closure), 0);
188+ SETTY(cl, BITS32);
189+ cl->info.bits32 = (uint32_t) (int32_t) (int16_t) a->info.bits16;
190+ return cl;
191+}
192+
193+VAL idris_b16S64(VM *vm, VAL a) {
194+ VAL cl = allocate(vm, sizeof(Closure), 0);
195+ SETTY(cl, BITS64);
196+ cl->info.bits64 = (uint64_t) (int64_t) (int16_t) a->info.bits16;
197+ return cl;
198+}
199+
200+VAL idris_b16T8(VM *vm, VAL a) {
201+ VAL cl = allocate(vm, sizeof(Closure), 0);
202+ SETTY(cl, BITS8);
203+ cl->info.bits8 = (uint8_t) a->info.bits16;
204+ return cl;
205+}
206+
207+VAL idris_b32Plus(VM *vm, VAL a, VAL b) {
208+ VAL cl = allocate(vm, sizeof(Closure), 0);
209+ SETTY(cl, BITS32);
210+ cl->info.bits32 = a->info.bits32 + b->info.bits32;
211+ return cl;
212+}
213+
214+VAL idris_b32Minus(VM *vm, VAL a, VAL b) {
215+ VAL cl = allocate(vm, sizeof(Closure), 0);
216+ SETTY(cl, BITS32);
217+ cl->info.bits32 = a->info.bits32 - b->info.bits32;
218+ return cl;
219+}
220+
221+VAL idris_b32Times(VM *vm, VAL a, VAL b) {
222+ VAL cl = allocate(vm, sizeof(Closure), 0);
223+ SETTY(cl, BITS32);
224+ cl->info.bits32 = a->info.bits32 * b->info.bits32;
225+ return cl;
226+}
227+
228+VAL idris_b32UDiv(VM *vm, VAL a, VAL b) {
229+ VAL cl = allocate(vm, sizeof(Closure), 0);
230+ SETTY(cl, BITS32);
231+ cl->info.bits32 = a->info.bits32 / b->info.bits32;
232+ return cl;
233+}
234+
235+VAL idris_b32SDiv(VM *vm, VAL a, VAL b) {
236+ VAL cl = allocate(vm, sizeof(Closure), 0);
237+ SETTY(cl, BITS32);
238+ cl->info.bits32 =
239+ (uint32_t) (((int32_t) a->info.bits32) / ((int32_t) b->info.bits32));
240+ return cl;
241+}
242+
243+VAL idris_b32Z64(VM *vm, VAL a) {
244+ VAL cl = allocate(vm, sizeof(Closure), 0);
245+ SETTY(cl, BITS64);
246+ cl->info.bits64 = (uint64_t) a->info.bits32;
247+ return cl;
248+}
249+
250+VAL idris_b32S64(VM *vm, VAL a) {
251+ VAL cl = allocate(vm, sizeof(Closure), 0);
252+ SETTY(cl, BITS64);
253+ cl->info.bits64 = (uint64_t) (int64_t) (int32_t) a->info.bits32;
254+ return cl;
255+}
256+
257+VAL idris_b32T8(VM *vm, VAL a) {
258+ VAL cl = allocate(vm, sizeof(Closure), 0);
259+ SETTY(cl, BITS8);
260+ cl->info.bits8 = (uint8_t) a->info.bits32;
261+ return cl;
262+}
263+
264+VAL idris_b32T16(VM *vm, VAL a) {
265+ VAL cl = allocate(vm, sizeof(Closure), 0);
266+ SETTY(cl, BITS16);
267+ cl->info.bits16 = (uint16_t) a->info.bits32;
268+ return cl;
269+}
270+
271+VAL idris_b64Plus(VM *vm, VAL a, VAL b) {
272+ VAL cl = allocate(vm, sizeof(Closure), 0);
273+ SETTY(cl, BITS64);
274+ cl->info.bits64 = a->info.bits64 + b->info.bits64;
275+ return cl;
276+}
277+
278+VAL idris_b64Minus(VM *vm, VAL a, VAL b) {
279+ VAL cl = allocate(vm, sizeof(Closure), 0);
280+ SETTY(cl, BITS64);
281+ cl->info.bits64 = a->info.bits64 - b->info.bits64;
282+ return cl;
283+}
284+
285+VAL idris_b64Times(VM *vm, VAL a, VAL b) {
286+ VAL cl = allocate(vm, sizeof(Closure), 0);
287+ SETTY(cl, BITS64);
288+ cl->info.bits64 = a->info.bits64 * b->info.bits64;
289+ return cl;
290+}
291+
292+VAL idris_b64UDiv(VM *vm, VAL a, VAL b) {
293+ VAL cl = allocate(vm, sizeof(Closure), 0);
294+ SETTY(cl, BITS64);
295+ cl->info.bits64 = a->info.bits64 / b->info.bits64;
296+ return cl;
297+}
298+
299+VAL idris_b64SDiv(VM *vm, VAL a, VAL b) {
300+ VAL cl = allocate(vm, sizeof(Closure), 0);
301+ SETTY(cl, BITS64);
302+ cl->info.bits64 =
303+ (uint64_t) (((int64_t) a->info.bits64) / ((int64_t) b->info.bits64));
304+ return cl;
305+}
306+
307+VAL idris_b64T8(VM *vm, VAL a) {
308+ VAL cl = allocate(vm, sizeof(Closure), 0);
309+ SETTY(cl, BITS8);
310+ cl->info.bits8 = (uint8_t) a->info.bits64;
311+ return cl;
312+}
313+
314+VAL idris_b64T16(VM *vm, VAL a) {
315+ VAL cl = allocate(vm, sizeof(Closure), 0);
316+ SETTY(cl, BITS16);
317+ cl->info.bits16 = (uint16_t) a->info.bits64;
318+ return cl;
319+}
320+
321+VAL idris_b64T32(VM *vm, VAL a) {
322+ VAL cl = allocate(vm, sizeof(Closure), 0);
323+ SETTY(cl, BITS32);
324+ cl->info.bits32 = (uint32_t) a->info.bits64;
325+ return cl;
326+}
327+