ref: 6c5270ccccbaea5518ca34302bc2019095614d99
parent: 2eb7a06d08964c0da9beefa3d75cd03382b7235b
parent: 37eb1a1a4ea6e80131ec861421478acaaed249c9
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Apr 19 18:55:55 EDT 2025
merge
--- a/src/equal.c
+++ b/src/equal.c
@@ -117,7 +117,7 @@
break;
case TAG_FN:
if(tagb == TAG_FN){
- if(uintval(a) > N_BUILTINS && uintval(b) > N_BUILTINS){
+ if(!isfnbuiltin(a) && !isfnbuiltin(b)){
sl_fn *fa = ptr(a);
sl_fn *fb = ptr(b);
d = bounded_compare(fa->bcode, fb->bcode, bound-1, eq);
@@ -330,7 +330,7 @@
abort();
return doublehash(u.i64);
case TAG_FN:
- if(uintval(a) > N_BUILTINS)
+ if(!isfnbuiltin(a))
return bounded_hash(((sl_fn*)ptr(a))->bcode, bound, oob);
return inthash(a);
case TAG_SPECIAL:
--- a/src/sl.h
+++ b/src/sl.h
@@ -190,7 +190,8 @@
#define ismanaged(v) ((((u8int*)ptr(v)) >= slg.fromspace) && (((u8int*)ptr(v)) < slg.fromspace+slg.heapsize))
#define isgensym(v) (issym(v) && ismanaged(v))
#define iscbuiltin(v) (iscvalue(v) && cv_class(ptr(v)) == sl_builtintype)
-#define isfn(v) ((tag(v) == TAG_FN && ((v) > (N_BUILTINS<<TAG_BITS) || isbuiltin(v))) || iscbuiltin(v))
+#define isfnbuiltin(v) ((v) < (N_BUILTINS<<TAG_BITS))
+#define isfn(v) (tag(v) == TAG_FN || iscbuiltin(v))
// utility for iterating over all arguments in a builtin
// i=index, i0=start index, arg = var for each arg, args = arg array
// assumes "nargs" is the argument count
--- a/src/vm.h
+++ b/src/vm.h
@@ -32,7 +32,7 @@
SYNC;
sl_v v = sp[-n-1];
if(tag(v) == TAG_FN){
- if(v > (N_BUILTINS<<TAG_BITS)){
+ if(!isfnbuiltin(v)){
nargs = n;
if(tail){
sl.curr_frame = (sl_v*)sl.curr_frame[-3];