summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-03-13 17:32:58 +0000
committerAlasdair Armstrong2018-03-13 17:37:12 +0000
commitf063a1e71d90368c04cf1f8eb2ba36cd16592e01 (patch)
tree2e79ad03a62a85a7c7427da099452a59bf0b88ba /lib
parent0da6c4482f2a68d8cde54c5261be6d715d5ce63c (diff)
Polymorphic option types now compile to C
Fixed an issue whereby an option constructor that was never constructed, but only matched on, would cause compilation to fail. Temporarily fixed an issue where union types that can be entirely stack-allocated were not being treated as such, by simply heap-allocating all unions. Need to adapt the code generator to handle this case properly. Fixed a further small issue whereby multiple union types would confuse the type specialisation pass. Added a test case for compiling option types. RISCV now generates C code, but there are still some bugs that need to be squashed before it compile and work.
Diffstat (limited to 'lib')
-rw-r--r--lib/sail.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sail.h b/lib/sail.h
index 8eb4f12a..c0f2674b 100644
--- a/lib/sail.h
+++ b/lib/sail.h
@@ -12,6 +12,10 @@ typedef int unit;
#define UNIT 0
+unit undefined_unit(const unit u) {
+ return UNIT;
+}
+
typedef struct {
mp_bitcnt_t len;
mpz_t *bits;
@@ -867,7 +871,7 @@ void load_image(char *file) {
FILE *fp = fopen(file, "r");
if (!fp) {
- fprintf(stderr, "Image file could not be loaded\n");
+ fprintf(stderr, "Image file %s could not be loaded\n", file);
exit(EXIT_FAILURE);
}
@@ -898,8 +902,7 @@ void load_instr(uint64_t addr, uint32_t instr) {
// ***** Setup and cleanup functions for library code *****
-void setup_library(char *file) {
- load_image(file);
+void setup_library(void) {
mpf_set_default_prec(FLOAT_PRECISION);
mpz_init(eq_bits_test);
}