@@ -95,45 +95,87 @@ VAL idris_b8SDiv(VM *vm, VAL a, VAL b) {
9595 return cl;
9696}
9797
98−VAL idris_b8Z16(VM *vm, VAL a) {
98+VAL idris_b8Lt(VM *vm, VAL a, VAL b) {
9999 VAL cl = allocate(vm, sizeof(Closure), 0);
100− SETTY(cl, BITS16);
101− cl->info.bits16 = (uint16_t) a->info.bits8;
100+ SETTY(cl, BITS8);
101+ cl->info.bits8 = a->info.bits8 < b->info.bits8;
102102 return cl;
103103}
104104
105−VAL idris_b8Z32(VM *vm, VAL a) {
105+VAL idris_b8Gt(VM *vm, VAL a, VAL b) {
106106 VAL cl = allocate(vm, sizeof(Closure), 0);
107− SETTY(cl, BITS32);
108− cl->info.bits32 = (uint32_t) a->info.bits8;
107+ SETTY(cl, BITS8);
108+ cl->info.bits8 = a->info.bits8 > b->info.bits8;
109109 return cl;
110110}
111111
112−VAL idris_b8Z64(VM *vm, VAL a) {
112+VAL idris_b8Eq(VM *vm, VAL a, VAL b) {
113113 VAL cl = allocate(vm, sizeof(Closure), 0);
114− SETTY(cl, BITS16);
115− cl->info.bits64 = (uint64_t) a->info.bits8;
114+ SETTY(cl, BITS8);
115+ cl->info.bits8 = a->info.bits8 == b->info.bits8;
116116 return cl;
117117}
118118
119−VAL idris_b8S16(VM *vm, VAL a) {
119+VAL idris_b8Lte(VM *vm, VAL a, VAL b) {
120120 VAL cl = allocate(vm, sizeof(Closure), 0);
121− SETTY(cl, BITS16);
122− cl->info.bits16 = (uint16_t) (int16_t) (int8_t) a->info.bits8;
121+ SETTY(cl, BITS8);
122+ cl->info.bits8 = a->info.bits8 <= b->info.bits8;
123123 return cl;
124124}
125125
126−VAL idris_b8S32(VM *vm, VAL a) {
126+VAL idris_b8Gte(VM *vm, VAL a, VAL b) {
127127 VAL cl = allocate(vm, sizeof(Closure), 0);
128− SETTY(cl, BITS32);
129− cl->info.bits32 = (uint32_t) (int32_t) (int8_t) a->info.bits8;
128+ SETTY(cl, BITS8);
129+ cl->info.bits8 = a->info.bits8 >= b->info.bits8;
130130 return cl;
131131}
132132
133−VAL idris_b8S64(VM *vm, VAL a) {
133+VAL idris_b8Compl(VM *vm, VAL a) {
134134 VAL cl = allocate(vm, sizeof(Closure), 0);
135− SETTY(cl, BITS64);
136− cl->info.bits64 = (uint64_t) (int64_t) (int8_t) a->info.bits8;
135+ SETTY(cl, BITS8);
136+ cl->info.bits8 = ~ a->info.bits8;
137+ return cl;
138+}
139+
140+VAL idris_b8And(VM *vm, VAL a, VAL b) {
141+ VAL cl = allocate(vm, sizeof(Closure), 0);
142+ SETTY(cl, BITS8);
143+ cl->info.bits8 = a->info.bits8 & b->info.bits8;
144+ return cl;
145+}
146+
147+VAL idris_b8Or(VM *vm, VAL a, VAL b) {
148+ VAL cl = allocate(vm, sizeof(Closure), 0);
149+ SETTY(cl, BITS8);
150+ cl->info.bits8 = a->info.bits8 | b->info.bits8;
151+ return cl;
152+}
153+
154+VAL idris_b8Xor(VM *vm, VAL a, VAL b) {
155+ VAL cl = allocate(vm, sizeof(Closure), 0);
156+ SETTY(cl, BITS8);
157+ cl->info.bits8 = a->info.bits8 ^ b->info.bits8;
158+ return cl;
159+}
160+
161+VAL idris_b8Shl(VM *vm, VAL a, VAL b) {
162+ VAL cl = allocate(vm, sizeof(Closure), 0);
163+ SETTY(cl, BITS8);
164+ cl->info.bits8 = a->info.bits8 << b->info.bits8;
165+ return cl;
166+}
167+
168+VAL idris_b8LShr(VM *vm, VAL a, VAL b) {
169+ VAL cl = allocate(vm, sizeof(Closure), 0);
170+ SETTY(cl, BITS8);
171+ cl->info.bits8 = a->info.bits8 >> b->info.bits8;
172+ return cl;
173+}
174+
175+VAL idris_b8AShr(VM *vm, VAL a, VAL b) {
176+ VAL cl = allocate(vm, sizeof(Closure), 0);
177+ SETTY(cl, BITS8);
178+ cl->info.bits8 = (uint8_t) (((int8_t)a->info.bits8) >> ((int8_t)b->info.bits8));
137179 return cl;
138180}
139181
@@ -169,42 +211,91 @@ VAL idris_b16SDiv(VM *vm, VAL a, VAL b) {
169211 VAL cl = allocate(vm, sizeof(Closure), 0);
170212 SETTY(cl, BITS16);
171213 cl->info.bits16 =
172− (uint16_t) (((int16_t) a->info.bits16) / ((int16_t) b->info.bits16));
214+ (uint16_t) (((int16_t) a->info.bits16) / ((int16_t) b->info.bits16));
173215 return cl;
174216}
175217
176−VAL idris_b16Z32(VM *vm, VAL a) {
218+VAL idris_b16Lt(VM *vm, VAL a, VAL b) {
177219 VAL cl = allocate(vm, sizeof(Closure), 0);
178− SETTY(cl, BITS32);
179− cl->info.bits32 = (uint32_t) a->info.bits16;
220+ SETTY(cl, BITS16);
221+ cl->info.bits16 = a->info.bits16 < b->info.bits16;
180222 return cl;
181223}
182224
183−VAL idris_b16Z64(VM *vm, VAL a) {
225+VAL idris_b16Gt(VM *vm, VAL a, VAL b) {
184226 VAL cl = allocate(vm, sizeof(Closure), 0);
185− SETTY(cl, BITS64);
186− cl->info.bits64 = (uint64_t) a->info.bits16;
227+ SETTY(cl, BITS16);
228+ cl->info.bits16 = a->info.bits16 > b->info.bits16;
187229 return cl;
188230}
189231
190−VAL idris_b16S32(VM *vm, VAL a) {
232+VAL idris_b16Eq(VM *vm, VAL a, VAL b) {
191233 VAL cl = allocate(vm, sizeof(Closure), 0);
192− SETTY(cl, BITS32);
193− cl->info.bits32 = (uint32_t) (int32_t) (int16_t) a->info.bits16;
234+ SETTY(cl, BITS16);
235+ cl->info.bits16 = a->info.bits16 == b->info.bits16;
194236 return cl;
195237}
196238
197−VAL idris_b16S64(VM *vm, VAL a) {
239+VAL idris_b16Lte(VM *vm, VAL a, VAL b) {
198240 VAL cl = allocate(vm, sizeof(Closure), 0);
199− SETTY(cl, BITS64);
200− cl->info.bits64 = (uint64_t) (int64_t) (int16_t) a->info.bits16;
241+ SETTY(cl, BITS16);
242+ cl->info.bits16 = a->info.bits16 <= b->info.bits16;
201243 return cl;
202244}
203245
204−VAL idris_b16T8(VM *vm, VAL a) {
246+VAL idris_b16Gte(VM *vm, VAL a, VAL b) {
205247 VAL cl = allocate(vm, sizeof(Closure), 0);
206− SETTY(cl, BITS8);
207− cl->info.bits8 = (uint8_t) a->info.bits16;
248+ SETTY(cl, BITS16);
249+ cl->info.bits16 = a->info.bits16 >= b->info.bits16;
250+ return cl;
251+}
252+
253+VAL idris_b16Compl(VM *vm, VAL a) {
254+ VAL cl = allocate(vm, sizeof(Closure), 0);
255+ SETTY(cl, BITS16);
256+ cl->info.bits16 = ~ a->info.bits16;
257+ return cl;
258+}
259+
260+VAL idris_b16And(VM *vm, VAL a, VAL b) {
261+ VAL cl = allocate(vm, sizeof(Closure), 0);
262+ SETTY(cl, BITS16);
263+ cl->info.bits16 = a->info.bits16 & b->info.bits16;
264+ return cl;
265+}
266+
267+VAL idris_b16Or(VM *vm, VAL a, VAL b) {
268+ VAL cl = allocate(vm, sizeof(Closure), 0);
269+ SETTY(cl, BITS16);
270+ cl->info.bits16 = a->info.bits16 | b->info.bits16;
271+ return cl;
272+}
273+
274+VAL idris_b16Xor(VM *vm, VAL a, VAL b) {
275+ VAL cl = allocate(vm, sizeof(Closure), 0);
276+ SETTY(cl, BITS16);
277+ cl->info.bits16 = a->info.bits16 ^ b->info.bits16;
278+ return cl;
279+}
280+
281+VAL idris_b16Shl(VM *vm, VAL a, VAL b) {
282+ VAL cl = allocate(vm, sizeof(Closure), 0);
283+ SETTY(cl, BITS16);
284+ cl->info.bits16 = a->info.bits16 << b->info.bits16;
285+ return cl;
286+}
287+
288+VAL idris_b16LShr(VM *vm, VAL a, VAL b) {
289+ VAL cl = allocate(vm, sizeof(Closure), 0);
290+ SETTY(cl, BITS16);
291+ cl->info.bits16 = a->info.bits16 >> b->info.bits16;
292+ return cl;
293+}
294+
295+VAL idris_b16AShr(VM *vm, VAL a, VAL b) {
296+ VAL cl = allocate(vm, sizeof(Closure), 0);
297+ SETTY(cl, BITS16);
298+ cl->info.bits16 = (uint16_t) (((int16_t)a->info.bits16) >> ((int16_t)b->info.bits16));
208299 return cl;
209300}
210301
@@ -240,35 +331,91 @@ VAL idris_b32SDiv(VM *vm, VAL a, VAL b) {
240331 VAL cl = allocate(vm, sizeof(Closure), 0);
241332 SETTY(cl, BITS32);
242333 cl->info.bits32 =
243− (uint32_t) (((int32_t) a->info.bits32) / ((int32_t) b->info.bits32));
334+ (uint32_t) (((int32_t) a->info.bits32) / ((int32_t) b->info.bits32));
244335 return cl;
245336}
246337
247−VAL idris_b32Z64(VM *vm, VAL a) {
338+VAL idris_b32Lt(VM *vm, VAL a, VAL b) {
248339 VAL cl = allocate(vm, sizeof(Closure), 0);
249− SETTY(cl, BITS64);
250− cl->info.bits64 = (uint64_t) a->info.bits32;
340+ SETTY(cl, BITS32);
341+ cl->info.bits32 = a->info.bits32 < b->info.bits32;
251342 return cl;
252343}
253344
254−VAL idris_b32S64(VM *vm, VAL a) {
345+VAL idris_b32Gt(VM *vm, VAL a, VAL b) {
255346 VAL cl = allocate(vm, sizeof(Closure), 0);
256− SETTY(cl, BITS64);
257− cl->info.bits64 = (uint64_t) (int64_t) (int32_t) a->info.bits32;
347+ SETTY(cl, BITS32);
348+ cl->info.bits32 = a->info.bits32 > b->info.bits32;
258349 return cl;
259350}
260351
261−VAL idris_b32T8(VM *vm, VAL a) {
352+VAL idris_b32Eq(VM *vm, VAL a, VAL b) {
262353 VAL cl = allocate(vm, sizeof(Closure), 0);
263− SETTY(cl, BITS8);
264− cl->info.bits8 = (uint8_t) a->info.bits32;
354+ SETTY(cl, BITS32);
355+ cl->info.bits32 = a->info.bits32 == b->info.bits32;
265356 return cl;
266357}
267358
268−VAL idris_b32T16(VM *vm, VAL a) {
359+VAL idris_b32Lte(VM *vm, VAL a, VAL b) {
269360 VAL cl = allocate(vm, sizeof(Closure), 0);
270− SETTY(cl, BITS16);
271− cl->info.bits16 = (uint16_t) a->info.bits32;
361+ SETTY(cl, BITS32);
362+ cl->info.bits32 = a->info.bits32 <= b->info.bits32;
363+ return cl;
364+}
365+
366+VAL idris_b32Gte(VM *vm, VAL a, VAL b) {
367+ VAL cl = allocate(vm, sizeof(Closure), 0);
368+ SETTY(cl, BITS32);
369+ cl->info.bits32 = a->info.bits32 >= b->info.bits32;
370+ return cl;
371+}
372+
373+VAL idris_b32Compl(VM *vm, VAL a) {
374+ VAL cl = allocate(vm, sizeof(Closure), 0);
375+ SETTY(cl, BITS32);
376+ cl->info.bits32 = ~ a->info.bits32;
377+ return cl;
378+}
379+
380+VAL idris_b32And(VM *vm, VAL a, VAL b) {
381+ VAL cl = allocate(vm, sizeof(Closure), 0);
382+ SETTY(cl, BITS32);
383+ cl->info.bits32 = a->info.bits32 & b->info.bits32;
384+ return cl;
385+}
386+
387+VAL idris_b32Or(VM *vm, VAL a, VAL b) {
388+ VAL cl = allocate(vm, sizeof(Closure), 0);
389+ SETTY(cl, BITS32);
390+ cl->info.bits32 = a->info.bits32 | b->info.bits32;
391+ return cl;
392+}
393+
394+VAL idris_b32Xor(VM *vm, VAL a, VAL b) {
395+ VAL cl = allocate(vm, sizeof(Closure), 0);
396+ SETTY(cl, BITS32);
397+ cl->info.bits32 = a->info.bits32 ^ b->info.bits32;
398+ return cl;
399+}
400+
401+VAL idris_b32Shl(VM *vm, VAL a, VAL b) {
402+ VAL cl = allocate(vm, sizeof(Closure), 0);
403+ SETTY(cl, BITS32);
404+ cl->info.bits32 = a->info.bits32 << b->info.bits32;
405+ return cl;
406+}
407+
408+VAL idris_b32LShr(VM *vm, VAL a, VAL b) {
409+ VAL cl = allocate(vm, sizeof(Closure), 0);
410+ SETTY(cl, BITS32);
411+ cl->info.bits32 = a->info.bits32 >> b->info.bits32;
412+ return cl;
413+}
414+
415+VAL idris_b32AShr(VM *vm, VAL a, VAL b) {
416+ VAL cl = allocate(vm, sizeof(Closure), 0);
417+ SETTY(cl, BITS32);
418+ cl->info.bits32 = (uint32_t) (((int32_t)a->info.bits32) >> ((int32_t)b->info.bits32));
272419 return cl;
273420}
274421
@@ -304,7 +451,196 @@ VAL idris_b64SDiv(VM *vm, VAL a, VAL b) {
304451 VAL cl = allocate(vm, sizeof(Closure), 0);
305452 SETTY(cl, BITS64);
306453 cl->info.bits64 =
307− (uint64_t) (((int64_t) a->info.bits64) / ((int64_t) b->info.bits64));
454+ (uint64_t) (((int64_t) a->info.bits64) / ((int64_t) b->info.bits64));
455+ return cl;
456+}
457+
458+VAL idris_b64Lt(VM *vm, VAL a, VAL b) {
459+ VAL cl = allocate(vm, sizeof(Closure), 0);
460+ SETTY(cl, BITS64);
461+ cl->info.bits64 = a->info.bits64 < b->info.bits64;
462+ return cl;
463+}
464+
465+VAL idris_b64Gt(VM *vm, VAL a, VAL b) {
466+ VAL cl = allocate(vm, sizeof(Closure), 0);
467+ SETTY(cl, BITS64);
468+ cl->info.bits64 = a->info.bits64 > b->info.bits64;
469+ return cl;
470+}
471+
472+VAL idris_b64Eq(VM *vm, VAL a, VAL b) {
473+ VAL cl = allocate(vm, sizeof(Closure), 0);
474+ SETTY(cl, BITS64);
475+ cl->info.bits64 = a->info.bits64 == b->info.bits64;
476+ return cl;
477+}
478+
479+VAL idris_b64Lte(VM *vm, VAL a, VAL b) {
480+ VAL cl = allocate(vm, sizeof(Closure), 0);
481+ SETTY(cl, BITS64);
482+ cl->info.bits64 = a->info.bits64 <= b->info.bits64;
483+ return cl;
484+}
485+
486+VAL idris_b64Gte(VM *vm, VAL a, VAL b) {
487+ VAL cl = allocate(vm, sizeof(Closure), 0);
488+ SETTY(cl, BITS64);
489+ cl->info.bits64 = a->info.bits64 >= b->info.bits64;
490+ return cl;
491+}
492+
493+VAL idris_b64Compl(VM *vm, VAL a) {
494+ VAL cl = allocate(vm, sizeof(Closure), 0);
495+ SETTY(cl, BITS64);
496+ cl->info.bits64 = ~ a->info.bits64;
497+ return cl;
498+}
499+
500+VAL idris_b64And(VM *vm, VAL a, VAL b) {
501+ VAL cl = allocate(vm, sizeof(Closure), 0);
502+ SETTY(cl, BITS64);
503+ cl->info.bits64 = a->info.bits64 & b->info.bits64;
504+ return cl;
505+}
506+
507+VAL idris_b64Or(VM *vm, VAL a, VAL b) {
508+ VAL cl = allocate(vm, sizeof(Closure), 0);
509+ SETTY(cl, BITS64);
510+ cl->info.bits64 = a->info.bits64 | b->info.bits64;
511+ return cl;
512+}
513+
514+VAL idris_b64Xor(VM *vm, VAL a, VAL b) {
515+ VAL cl = allocate(vm, sizeof(Closure), 0);
516+ SETTY(cl, BITS64);
517+ cl->info.bits64 = a->info.bits64 ^ b->info.bits64;
518+ return cl;
519+}
520+
521+VAL idris_b64Shl(VM *vm, VAL a, VAL b) {
522+ VAL cl = allocate(vm, sizeof(Closure), 0);
523+ SETTY(cl, BITS64);
524+ cl->info.bits64 = a->info.bits64 << b->info.bits64;
525+ return cl;
526+}
527+
528+VAL idris_b64LShr(VM *vm, VAL a, VAL b) {
529+ VAL cl = allocate(vm, sizeof(Closure), 0);
530+ SETTY(cl, BITS64);
531+ cl->info.bits64 = a->info.bits64 >> b->info.bits64;
532+ return cl;
533+}
534+
535+VAL idris_b64AShr(VM *vm, VAL a, VAL b) {
536+ VAL cl = allocate(vm, sizeof(Closure), 0);
537+ SETTY(cl, BITS64);
538+ cl->info.bits64 = (uint64_t) (((int64_t)a->info.bits64) >> ((int64_t)b->info.bits64));
539+ return cl;
540+}
541+
542+VAL idris_b8Z16(VM *vm, VAL a) {
543+ VAL cl = allocate(vm, sizeof(Closure), 0);
544+ SETTY(cl, BITS16);
545+ cl->info.bits16 = (uint16_t) a->info.bits8;
546+ return cl;
547+}
548+
549+VAL idris_b8Z32(VM *vm, VAL a) {
550+ VAL cl = allocate(vm, sizeof(Closure), 0);
551+ SETTY(cl, BITS32);
552+ cl->info.bits32 = (uint32_t) a->info.bits8;
553+ return cl;
554+}
555+
556+VAL idris_b8Z64(VM *vm, VAL a) {
557+ VAL cl = allocate(vm, sizeof(Closure), 0);
558+ SETTY(cl, BITS16);
559+ cl->info.bits64 = (uint64_t) a->info.bits8;
560+ return cl;
561+}
562+
563+VAL idris_b8S16(VM *vm, VAL a) {
564+ VAL cl = allocate(vm, sizeof(Closure), 0);
565+ SETTY(cl, BITS16);
566+ cl->info.bits16 = (uint16_t) (int16_t) (int8_t) a->info.bits8;
567+ return cl;
568+}
569+
570+VAL idris_b8S32(VM *vm, VAL a) {
571+ VAL cl = allocate(vm, sizeof(Closure), 0);
572+ SETTY(cl, BITS32);
573+ cl->info.bits32 = (uint32_t) (int32_t) (int8_t) a->info.bits8;
574+ return cl;
575+}
576+
577+VAL idris_b8S64(VM *vm, VAL a) {
578+ VAL cl = allocate(vm, sizeof(Closure), 0);
579+ SETTY(cl, BITS64);
580+ cl->info.bits64 = (uint64_t) (int64_t) (int8_t) a->info.bits8;
581+ return cl;
582+}
583+
584+VAL idris_b16Z32(VM *vm, VAL a) {
585+ VAL cl = allocate(vm, sizeof(Closure), 0);
586+ SETTY(cl, BITS32);
587+ cl->info.bits32 = (uint32_t) a->info.bits16;
588+ return cl;
589+}
590+
591+VAL idris_b16Z64(VM *vm, VAL a) {
592+ VAL cl = allocate(vm, sizeof(Closure), 0);
593+ SETTY(cl, BITS64);
594+ cl->info.bits64 = (uint64_t) a->info.bits16;
595+ return cl;
596+}
597+
598+VAL idris_b16S32(VM *vm, VAL a) {
599+ VAL cl = allocate(vm, sizeof(Closure), 0);
600+ SETTY(cl, BITS32);
601+ cl->info.bits32 = (uint32_t) (int32_t) (int16_t) a->info.bits16;
602+ return cl;
603+}
604+
605+VAL idris_b16S64(VM *vm, VAL a) {
606+ VAL cl = allocate(vm, sizeof(Closure), 0);
607+ SETTY(cl, BITS64);
608+ cl->info.bits64 = (uint64_t) (int64_t) (int16_t) a->info.bits16;
609+ return cl;
610+}
611+
612+VAL idris_b16T8(VM *vm, VAL a) {
613+ VAL cl = allocate(vm, sizeof(Closure), 0);
614+ SETTY(cl, BITS8);
615+ cl->info.bits8 = (uint8_t) a->info.bits16;
616+ return cl;
617+}
618+
619+VAL idris_b32Z64(VM *vm, VAL a) {
620+ VAL cl = allocate(vm, sizeof(Closure), 0);
621+ SETTY(cl, BITS64);
622+ cl->info.bits64 = (uint64_t) a->info.bits32;
623+ return cl;
624+}
625+
626+VAL idris_b32S64(VM *vm, VAL a) {
627+ VAL cl = allocate(vm, sizeof(Closure), 0);
628+ SETTY(cl, BITS64);
629+ cl->info.bits64 = (uint64_t) (int64_t) (int32_t) a->info.bits32;
630+ return cl;
631+}
632+
633+VAL idris_b32T8(VM *vm, VAL a) {
634+ VAL cl = allocate(vm, sizeof(Closure), 0);
635+ SETTY(cl, BITS8);
636+ cl->info.bits8 = (uint8_t) a->info.bits32;
637+ return cl;
638+}
639+
640+VAL idris_b32T16(VM *vm, VAL a) {
641+ VAL cl = allocate(vm, sizeof(Closure), 0);
642+ SETTY(cl, BITS16);
643+ cl->info.bits16 = (uint16_t) a->info.bits32;
308644 return cl;
309645}
310646