diff options
| author | LLLL Colonq <llll@colonq> | 2026-03-27 17:23:26 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-03-27 17:23:26 -0400 |
| commit | 4b294e47144da00ae4b9568fed39569d187ce07e (patch) | |
| tree | 179222746330c25fa4f0dfdb03e0fc0a15ad7c9b | |
| parent | 3707dfaa64715c8fb1ba8a23f9762fef174538d8 (diff) | |
Fix doubles
| -rw-r--r-- | include/lcq/pit/runtime.h | 2 | ||||
| -rw-r--r-- | src/runtime.c | 8 | ||||
| -rw-r--r-- | test/array.lisp (renamed from array.lisp) | 0 | ||||
| -rw-r--r-- | test/bif.pit | 12 | ||||
| -rw-r--r-- | test/broken.lisp (renamed from broken.lisp) | 0 | ||||
| -rw-r--r-- | test/fold.lisp (renamed from fold.lisp) | 0 | ||||
| -rw-r--r-- | test/gc.pit (renamed from gc.pit) | 0 | ||||
| -rw-r--r-- | test/nonbroken.lisp (renamed from nonbroken.lisp) | 0 | ||||
| -rw-r--r-- | test/struct.lisp (renamed from struct.lisp) | 0 | ||||
| -rw-r--r-- | test/test.lisp (renamed from test.lisp) | 0 | ||||
| -rw-r--r-- | test/test2.lisp (renamed from test2.lisp) | 0 | ||||
| -rw-r--r-- | test/test3.lisp (renamed from test3.lisp) | 0 | ||||
| -rw-r--r-- | test/thebug.lisp (renamed from thebug.lisp) | 0 | ||||
| -rw-r--r-- | test/thebug2.lisp | 13 | ||||
| -rw-r--r-- | test/x86.pit (renamed from x86.pit) | 0 | ||||
| -rw-r--r-- | test/y.lisp (renamed from y.lisp) | 0 |
16 files changed, 32 insertions, 3 deletions
diff --git a/include/lcq/pit/runtime.h b/include/lcq/pit/runtime.h index 4132231..f946a71 100644 --- a/include/lcq/pit/runtime.h +++ b/include/lcq/pit/runtime.h @@ -9,7 +9,7 @@ struct pit_runtime; /* nil is always the symbol with index 0 */ #define PIT_NIL 0xfff4000000000000 /* 0b1111111111110100000000000000000000000000000000000000000000000000 */ -#define PIT_T (PIT_NIL+sizeof(pit_symtab_entry)) +#define PIT_T (PIT_NIL+1) enum pit_value_sort { PIT_VALUE_SORT_DOUBLE = 0, /* 0b00 - double */ diff --git a/src/runtime.c b/src/runtime.c index a77fbf4..6f3759f 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -212,10 +212,14 @@ double pit_as_double(pit_runtime *rt, pit_value v) { pit_error(rt, "invalid use of value as double"); return 0.0; } - return (double) v; + union { double dval; u64 ival; } x; + x.ival = v; + return x.dval; } pit_value pit_double_new(pit_runtime *rt, double d) { - return pit_value_new(rt, PIT_VALUE_SORT_DOUBLE, (u64) d); + union { double dval; u64 ival; } x; + x.dval = d; + return pit_value_new(rt, PIT_VALUE_SORT_DOUBLE, x.ival); } i64 pit_as_integer(pit_runtime *rt, pit_value v) { diff --git a/array.lisp b/test/array.lisp index 976f70d..976f70d 100644 --- a/array.lisp +++ b/test/array.lisp diff --git a/test/bif.pit b/test/bif.pit new file mode 100644 index 0000000..81a1248 --- /dev/null +++ b/test/bif.pit @@ -0,0 +1,12 @@ +(print! nil) +(print! nil) +(print! t) +(print! (eq? 1 1)) +(diagnostics!) +(defun! bif (x) + (cons x x)) +(diagnostics!) +(setq! foo (print! (bif (bif (bif 67))))) +(print! (eq? (car foo) (cdr foo))) +(diagnostics!) +(print! foo) diff --git a/broken.lisp b/test/broken.lisp index 09f4afc..09f4afc 100644 --- a/broken.lisp +++ b/test/broken.lisp diff --git a/fold.lisp b/test/fold.lisp index 89031d0..89031d0 100644 --- a/fold.lisp +++ b/test/fold.lisp diff --git a/nonbroken.lisp b/test/nonbroken.lisp index 350f64f..350f64f 100644 --- a/nonbroken.lisp +++ b/test/nonbroken.lisp diff --git a/struct.lisp b/test/struct.lisp index 9e35654..9e35654 100644 --- a/struct.lisp +++ b/test/struct.lisp diff --git a/test.lisp b/test/test.lisp index ef13abb..ef13abb 100644 --- a/test.lisp +++ b/test/test.lisp diff --git a/test2.lisp b/test/test2.lisp index 79a9791..79a9791 100644 --- a/test2.lisp +++ b/test/test2.lisp diff --git a/test3.lisp b/test/test3.lisp index 2febb75..2febb75 100644 --- a/test3.lisp +++ b/test/test3.lisp diff --git a/thebug.lisp b/test/thebug.lisp index ad87bd7..ad87bd7 100644 --- a/thebug.lisp +++ b/test/thebug.lisp diff --git a/test/thebug2.lisp b/test/thebug2.lisp new file mode 100644 index 0000000..2376ff8 --- /dev/null +++ b/test/thebug2.lisp @@ -0,0 +1,13 @@ + +(setq! z 40) +(setq! f + (lambda (x) + (lambda (y) + (lambda (w) + (+ + (funcall (lambda (z) (+ x y z)) 3) + w + z))))) +(let ((z 20)) + (print! (funcall (funcall (funcall f 1) 2) 3))) + |
