ref: f32471311a6f949513664b9788a8087074b9d1f9
parent: 2b3838fc4a8d7c8073eff77b0ee4ee05ea4746a5
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Dec 11 21:25:27 EST 2024
make FL_{nil,f,t,eof,unspecified} global
--- a/builtins.c
+++ b/builtins.c
@@ -25,9 +25,9 @@
BUILTIN("nconc", nconc)
{
if(nargs == 0)
- return FL(Nil);
+ return FL_nil;
- value_t lst, first = FL(Nil);
+ value_t lst, first = FL_nil;
value_t *pcdr = &first;
cons_t *c;
uint32_t i = 0;
@@ -42,7 +42,7 @@
while(iscons(c->cdr))
c = ptr(c->cdr);
pcdr = &c->cdr;
- }else if(lst != FL(Nil))
+ }else if(lst != FL_nil)
type_error("cons", lst);
}
*pcdr = lst;
@@ -63,7 +63,7 @@
return bind;
v = cdr_(v);
}
- return FL(f);
+ return FL_f;
}
BUILTIN("memq", memq)
@@ -76,7 +76,7 @@
if((c = ptr(v))->car == args[0])
return v;
}
- return FL(f);
+ return FL_f;
}
BUILTIN("length", length)
@@ -88,7 +88,7 @@
if(isvector(a))
return fixnum(vector_size(a));
- if(a == FL(Nil))
+ if(a == FL_nil)
return fixnum(0);
if(iscons(a)){
size_t n = 0;
@@ -142,7 +142,7 @@
{
argcount(nargs, 1);
return (issymbol(args[0]) &&
- iskeyword((symbol_t*)ptr(args[0]))) ? FL(t) : FL(f);
+ iskeyword((symbol_t*)ptr(args[0]))) ? FL_t : FL_f;
}
BUILTIN("top-level-value", top_level_value)
@@ -169,7 +169,7 @@
symbol_t *sym = tosymbol(args[0]);
if(!isconstant(sym))
sym->binding = UNBOUND;
- return FL(t);
+ return FL_t;
}
static void
@@ -187,7 +187,7 @@
{
USED(args);
argcount(nargs, 0);
- value_t lst = FL(Nil);
+ value_t lst = FL_nil;
fl_gc_handle(&lst);
global_env_list(FL(symtab), &lst);
fl_free_gc_handles(1);
@@ -198,13 +198,13 @@
{
argcount(nargs, 1);
if(issymbol(args[0]))
- return isconstant((symbol_t*)ptr(args[0])) ? FL(t) : FL(f);
+ return isconstant((symbol_t*)ptr(args[0])) ? FL_t : FL_f;
if(iscons(args[0])){
if(car_(args[0]) == FL(quote))
- return FL(t);
- return FL(f);
+ return FL_t;
+ return FL_f;
}
- return FL(t);
+ return FL_t;
}
BUILTIN("integer-valued?", integer_valuedp)
@@ -212,11 +212,11 @@
argcount(nargs, 1);
value_t v = args[0];
if(isfixnum(v))
- return FL(t);
+ return FL_t;
if(iscprim(v)){
numerictype_t nt = cp_numtype(ptr(v));
if(nt < T_FLOAT)
- return FL(t);
+ return FL_t;
void *data = cp_data(ptr(v));
if(nt == T_FLOAT){
float f = *(float*)data;
@@ -223,7 +223,7 @@
if(f < 0)
f = -f;
if(f <= FLT_MAXINT && (float)(int32_t)f == f)
- return FL(t);
+ return FL_t;
}else{
assert(nt == T_DOUBLE);
double d = *(double*)data;
@@ -230,10 +230,10 @@
if(d < 0)
d = -d;
if(d <= DBL_MAXINT && (double)(int64_t)d == d)
- return FL(t);
+ return FL_t;
}
}
- return FL(f);
+ return FL_f;
}
BUILTIN("integer?", integerp)
@@ -242,7 +242,7 @@
value_t v = args[0];
return (isfixnum(v) ||
(iscprim(v) && cp_numtype(ptr(v)) < T_FLOAT)) ?
- FL(t) : FL(f);
+ FL_t : FL_f;
}
BUILTIN("bignum?", bignump)
@@ -250,7 +250,7 @@
argcount(nargs, 1);
value_t v = args[0];
return (iscvalue(v) && cp_numtype(ptr(v)) == T_MPINT) ?
- FL(t) : FL(f);
+ FL_t : FL_f;
}
BUILTIN("fixnum", fixnum)
@@ -306,7 +306,7 @@
v = alloc_vector(i, 0);
a = 1;
for(k = 0; k < i; k++){
- f = a < nargs ? args[a] : FL(unspecified);
+ f = a < nargs ? args[a] : FL_unspecified;
vector_elt(v, k) = f;
if((a = (a + 1) % nargs) < 1)
a = 1;
@@ -366,7 +366,7 @@
char *ptr = tostring(args[0]);
if(chdir(ptr))
lerrorf(FL(IOError), "could not cd to %s", ptr);
- return FL(t);
+ return FL_t;
}
BUILTIN("path-exists?", path_existsp)
@@ -373,7 +373,7 @@
{
argcount(nargs, 1);
char *path = tostring(args[0]);
- return access(path, F_OK) == 0 ? FL(t) : FL(f);
+ return access(path, F_OK) == 0 ? FL_t : FL_f;
}
BUILTIN("os-getenv", os_getenv)
@@ -382,7 +382,7 @@
char *name = tostring(args[0]);
char *val = getenv(name);
if(val == nil)
- return FL(f);
+ return FL_f;
if(*val == 0)
return symbol_value(FL(emptystringsym));
return cvalue_static_cstring(val);
@@ -393,7 +393,7 @@
argcount(nargs, 2);
char *name = tostring(args[0]);
int result;
- if(args[1] == FL(f))
+ if(args[1] == FL_f)
result = unsetenv(name);
else{
char *val = tostring(args[1]);
@@ -401,7 +401,7 @@
}
if(result != 0)
lerrorf(FL(ArgError), "invalid environment variable");
- return FL(t);
+ return FL_t;
}
BUILTIN("rand", rand)
--- a/cvalues.c
+++ b/cvalues.c
@@ -164,7 +164,7 @@
pcv->data = ptr;
pcv->len = sz;
pcv->type = type;
- if(parent != FL(Nil)){
+ if(parent != FL_nil){
pcv->type = (fltype_t*)(((uintptr_t)pcv->type) | CV_PARENT_BIT);
pcv->parent = parent;
}
@@ -181,7 +181,7 @@
value_t
cvalue_static_cstring(const char *str)
{
- return cvalue_from_ref(FL(stringtype), (char*)str, strlen(str), FL(Nil));
+ return cvalue_from_ref(FL(stringtype), (char*)str, strlen(str), FL_nil);
}
value_t
@@ -434,7 +434,7 @@
return vector_size(arg);
if(iscons(arg))
return llength(arg);
- if(arg == FL(Nil))
+ if(arg == FL_nil)
return 0;
if(isarray(arg))
return cvalue_arraylen(arg);
@@ -467,7 +467,7 @@
}
return 0;
}
- if(iscons(arg) || arg == FL(Nil)){
+ if(iscons(arg) || arg == FL_nil){
i = 0;
while(iscons(arg)){
if(i == cnt){
@@ -619,7 +619,7 @@
if(iscons(type)){
value_t hed = car_(type);
if(hed == FL(structsym))
- return cvalue_struct_offs(type, FL(Nil), 1, palign);
+ return cvalue_struct_offs(type, FL_nil, 1, palign);
if(hed == FL(unionsym))
return cvalue_union_size(type, palign);
if(hed == FL(pointersym) || hed == FL(cfunctionsym)){
@@ -691,12 +691,12 @@
case TAG_SYM: return FL(symbolsym);
case TAG_VECTOR: return FL(vectorsym);
case TAG_FUNCTION:
- if(args[0] == FL(t) || args[0] == FL(f))
+ if(args[0] == FL_t || args[0] == FL_f)
return FL(booleansym);
- if(args[0] == FL(Nil))
+ if(args[0] == FL_nil)
return FL(nullsym);
- if(args[0] == FL(eof))
- return FL(eof);
+ if(args[0] == FL_eof)
+ return FL_eof;
if(isbuiltin(args[0]))
return FL(builtinsym);
return FL(function);
@@ -747,7 +747,7 @@
autorelease(ncv);
if(hasparent(cv)){
ncv->type = (fltype_t*)(((uintptr_t)ncv->type) & ~CV_PARENT_BIT);
- ncv->parent = FL(Nil);
+ ncv->parent = FL_nil;
}
}else{
ncv->data = &ncv->_space[0];
@@ -773,7 +773,7 @@
argcount(nargs, 1);
return (iscprim(args[0]) ||
(iscvalue(args[0]) && cv_isPOD((cvalue_t*)ptr(args[0])))) ?
- FL(t) : FL(f);
+ FL_t : FL_f;
}
static void
@@ -1284,7 +1284,7 @@
}
}
assert(0);
- return FL(Nil);
+ return FL_nil;
}
BUILTIN("logand", logand)
--- a/equal.c
+++ b/equal.c
@@ -25,7 +25,7 @@
{
value_t c = (value_t)ptrhash_get(table, (void*)key);
if(c == (value_t)HT_NOTFOUND)
- return FL(Nil);
+ return FL_nil;
if(c == key)
return c;
return eq_class(table, c);
@@ -34,8 +34,8 @@
static void
eq_union(htable_t *table, value_t a, value_t b, value_t c, value_t cb)
{
- value_t ca = c == FL(Nil) ? a : c;
- if(cb != FL(Nil))
+ value_t ca = c == FL_nil ? a : c;
+ if(cb != FL_nil)
ptrhash_put(table, (void*)cb, (void*)ca);
ptrhash_put(table, (void*)a, (void*)ca);
ptrhash_put(table, (void*)b, (void*)ca);
@@ -55,7 +55,7 @@
m = la < lb ? la : lb;
for(i = 0; i < m; i++){
value_t d = bounded_compare(vector_elt(a, i), vector_elt(b, i), bound-1, eq);
- if(d == FL(Nil) || numval(d) != 0)
+ if(d == FL_nil || numval(d) != 0)
return d;
}
if(la < lb)
@@ -77,7 +77,7 @@
if(a == b)
return fixnum(0);
if(bound <= 0)
- return FL(Nil);
+ return FL_nil;
int taga = tag(a);
int tagb = cmptag(b);
int c;
@@ -135,13 +135,13 @@
function_t *fa = ptr(a);
function_t *fb = ptr(b);
d = bounded_compare(fa->bcode, fb->bcode, bound-1, eq);
- if(d == FL(Nil) || numval(d) != 0)
+ if(d == FL_nil || numval(d) != 0)
return d;
d = bounded_compare(fa->vals, fb->vals, bound-1, eq);
- if(d == FL(Nil) || numval(d) != 0)
+ if(d == FL_nil || numval(d) != 0)
return d;
d = bounded_compare(fa->env, fb->env, bound-1, eq);
- if(d == FL(Nil) || numval(d) != 0)
+ if(d == FL_nil || numval(d) != 0)
return d;
return fixnum(0);
}
@@ -152,7 +152,7 @@
if(tagb < TAG_CONS)
return fixnum(1);
d = bounded_compare(car_(a), car_(b), bound-1, eq);
- if(d == FL(Nil) || numval(d) != 0)
+ if(d == FL_nil || numval(d) != 0)
return d;
a = cdr_(a); b = cdr_(b);
bound--;
@@ -178,7 +178,7 @@
xb = vector_elt(b, i);
if(leafp(xa) || leafp(xb)){
d = bounded_compare(xa, xb, 1, eq);
- if(d != FL(Nil) && numval(d) != 0)
+ if(d != FL_nil && numval(d) != 0)
return d;
}else if(tag(xa) < tag(xb))
return fixnum(-1);
@@ -188,7 +188,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(Nil) && ca == cb)
+ if(ca != FL_nil && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -229,7 +229,7 @@
int tagdb = tag(db);
if(leafp(aa) || leafp(ab)){
d = bounded_compare(aa, ab, 1, eq);
- if(d != FL(Nil) && numval(d) != 0)
+ if(d != FL_nil && numval(d) != 0)
return d;
}
if(tagaa < tagab)
@@ -238,7 +238,7 @@
return fixnum(1);
if(leafp(da) || leafp(db)){
d = bounded_compare(da, db, 1, eq);
- if(d != FL(Nil) && numval(d) != 0)
+ if(d != FL_nil && numval(d) != 0)
return d;
}
if(tagda < tagdb)
@@ -248,7 +248,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(Nil) && ca == cb)
+ if(ca != FL_nil && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -273,7 +273,7 @@
ca = eq_class(table, a);
cb = eq_class(table, b);
- if(ca != FL(Nil) && ca == cb)
+ if(ca != FL_nil && ca == cb)
return fixnum(0);
eq_union(table, a, b, ca, cb);
@@ -300,7 +300,7 @@
compare_(value_t a, value_t b, bool eq)
{
value_t guess = bounded_compare(a, b, BOUNDED_COMPARE_BOUND, eq);
- if(guess == FL(Nil)){
+ if(guess == FL_nil){
guess = cyc_compare(a, b, &equal_eq_hashtable, eq);
htable_reset(&equal_eq_hashtable, 512);
}
@@ -317,8 +317,8 @@
fl_equal(value_t a, value_t b)
{
if(eq_comparable(a, b))
- return a == b ? FL(t) : FL(f);
- return numval(compare_(a, b, 1)) == 0 ? FL(t) : FL(f);
+ return a == b ? FL_t : FL_f;
+ return numval(compare_(a, b, 1)) == 0 ? FL_t : FL_f;
}
/*
--- a/flisp.c
+++ b/flisp.c
@@ -62,7 +62,7 @@
for(l__tr = 1; l__tr; l__tr = 0, (void)(FL(exctx) = FL(exctx)->prev))
#define FL_CATCH_INC \
- l__ca = 0, FL(lasterror) = FL(Nil), FL(throwing_frame) = 0, FL(sp) = _ctx.sp, FL(curr_frame) = _ctx.frame
+ l__ca = 0, FL(lasterror) = FL_nil, FL(throwing_frame) = 0, FL(sp) = _ctx.sp, FL(curr_frame) = _ctx.frame
#define FL_CATCH \
else \
@@ -85,7 +85,7 @@
void
fl_restorestate(fl_exception_context_t *_ctx)
{
- FL(lasterror) = FL(Nil);
+ FL(lasterror) = FL_nil;
FL(throwing_frame) = 0;
FL(sp) = _ctx->sp;
FL(curr_frame) = _ctx->frame;
@@ -234,7 +234,7 @@
BUILTIN("gensym?", gensymp)
{
argcount(nargs, 1);
- return isgensym(args[0]) ? FL(t) : FL(f);
+ return isgensym(args[0]) ? FL_t : FL_f;
}
char *
@@ -313,7 +313,7 @@
if(init){
unsigned int i;
for(i = 0; i < n; i++)
- vector_elt(v, i) = FL(unspecified);
+ vector_elt(v, i) = FL_unspecified;
}
return v;
}
@@ -361,7 +361,7 @@
pcdr = &cdr_(nc);
v = d;
}while(iscons(v));
- *pcdr = d == FL(Nil) ? FL(Nil) : relocate(d);
+ *pcdr = d == FL_nil ? FL_nil : relocate(d);
return first;
}
@@ -579,7 +579,7 @@
PUSH(car_(v));
v = cdr_(v);
}
- if(v != FL(Nil))
+ if(v != FL_nil)
lerrorf(FL(ArgError), "apply: last argument: not a list");
n = FL(sp) - n - 1;
v = _applyn(n);
@@ -628,7 +628,7 @@
c->cdr = tagptr(c+1, TAG_CONS);
c++;
}
- c[-1].cdr = FL(Nil);
+ c[-1].cdr = FL_nil;
POPN(n);
va_end(ap);
@@ -646,7 +646,7 @@
c[0].car = a;
c[0].cdr = tagptr(c+1, TAG_CONS);
c[1].car = b;
- c[1].cdr = FL(Nil);
+ c[1].cdr = FL_nil;
return tagptr(c, TAG_CONS);
}
@@ -695,7 +695,7 @@
if(star)
c[-2].cdr = c[-1].car;
else
- c[-1].cdr = FL(Nil);
+ c[-1].cdr = FL_nil;
return v;
}
@@ -703,8 +703,8 @@
copy_list(value_t L)
{
if(!iscons(L))
- return FL(Nil);
- PUSH(FL(Nil));
+ return FL_nil;
+ PUSH(FL_nil);
PUSH(L);
value_t *plcons = &FL(stack)[FL(sp)-2];
value_t *pL = &FL(stack)[FL(sp)-1];
@@ -711,13 +711,13 @@
value_t c;
c = mk_cons(); PUSH(c); // save first cons
car_(c) = car_(*pL);
- cdr_(c) = FL(Nil);
+ cdr_(c) = FL_nil;
*plcons = c;
*pL = cdr_(*pL);
while(iscons(*pL)){
c = mk_cons();
car_(c) = car_(*pL);
- cdr_(c) = FL(Nil);
+ cdr_(c) = FL_nil;
cdr_(*plcons) = c;
*plcons = c;
*pL = cdr_(*pL);
@@ -731,7 +731,7 @@
do_trycatch(void)
{
uint32_t saveSP = FL(sp);
- value_t v = FL(Nil);
+ value_t v = FL_nil;
value_t thunk = FL(stack)[FL(sp)-2];
FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-1];
FL(stack)[FL(sp)-1] = thunk;
@@ -758,7 +758,7 @@
{
uint32_t extr = nopt+nkw;
uint32_t ntot = nreq+extr;
- value_t args[64], v = FL(Nil);
+ value_t args[64], v = FL_nil;
uint32_t i, a = 0, nrestargs;
value_t s1 = FL(stack)[FL(sp)-1];
value_t s3 = FL(stack)[FL(sp)-3];
@@ -1016,7 +1016,7 @@
NEXT_OP;
OP(OP_BRF)
- ip += POP() != FL(f) ? 2 : GET_INT16(ip);
+ ip += POP() != FL_f ? 2 : GET_INT16(ip);
NEXT_OP;
OP(OP_POP)
@@ -1132,7 +1132,7 @@
i = *ip++;
v = mk_cons();
car_(v) = FL(stack)[bp+i];
- cdr_(v) = FL(Nil);
+ cdr_(v) = FL_nil;
FL(stack)[bp+i] = v;
NEXT_OP;
@@ -1140,7 +1140,7 @@
i = GET_INT32(ip); ip += 4;
v = mk_cons();
car_(v) = FL(stack)[bp+i];
- cdr_(v) = FL(Nil);
+ cdr_(v) = FL_nil;
FL(stack)[bp+i] = v;
NEXT_OP;
@@ -1173,7 +1173,7 @@
v = FL(stack)[FL(sp)-1];
if(__likely(iscons(v)))
v = car_(v);
- else if(__unlikely(v != FL(Nil))){
+ else if(__unlikely(v != FL_nil)){
FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
@@ -1184,7 +1184,7 @@
v = FL(stack)[FL(sp)-1];
if(__likely(iscons(v)))
v = cdr_(v);
- else if(__unlikely(v != FL(Nil))){
+ else if(__unlikely(v != FL_nil)){
FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
@@ -1234,7 +1234,7 @@
NEXT_OP;
OP(OP_PAIRP)
- FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL_t : FL_f;
NEXT_OP;
OP(OP_BRNE)
@@ -1243,7 +1243,7 @@
NEXT_OP;
OP(OP_LOADT)
- PUSH(FL(t));
+ PUSH(FL_t);
NEXT_OP;
OP(OP_LOAD0)
@@ -1282,15 +1282,15 @@
NEXT_OP;
OP(OP_ATOMP)
- FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL(f) : FL(t);
+ FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL_f : FL_t;
NEXT_OP;
OP(OP_BRT)
- ip += POP() != FL(f) ? GET_INT16(ip) : 2;
+ ip += POP() != FL_f ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_BRNN)
- ip += POP() != FL(Nil) ? GET_INT16(ip) : 2;
+ ip += POP() != FL_nil ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_LOAD1)
@@ -1302,12 +1302,12 @@
value_t a = FL(stack)[FL(sp)-2], b = FL(stack)[FL(sp)-1];
POPN(1);
if(bothfixnums(a, b)){
- FL(stack)[FL(sp)-1] = (fixnum_t)a < (fixnum_t)b ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = (fixnum_t)a < (fixnum_t)b ? FL_t : FL_f;
}else{
x = numeric_compare(a, b, false, false, false);
if(x > 1)
x = numval(fl_compare(a, b));
- FL(stack)[FL(sp)-1] = x < 0 ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = x < 0 ? FL_t : FL_f;
}
}
NEXT_OP;
@@ -1346,7 +1346,7 @@
NEXT_OP;
OP(OP_LOADF)
- PUSH(FL(f));
+ PUSH(FL_f);
NEXT_OP;
OP(OP_CONS)
@@ -1361,16 +1361,16 @@
NEXT_OP;
OP(OP_EQ)
- FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1] ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1] ? FL_t : FL_f;
POPN(1);
NEXT_OP;
OP(OP_SYMBOLP)
- FL(stack)[FL(sp)-1] = issymbol(FL(stack)[FL(sp)-1]) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = issymbol(FL(stack)[FL(sp)-1]) ? FL_t : FL_f;
NEXT_OP;
OP(OP_NOT)
- FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-1] == FL(f) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-1] == FL_f ? FL_t : FL_f;
NEXT_OP;
OP(OP_CADR)
@@ -1383,7 +1383,7 @@
goto cadr_nil;
}else{
cadr_nil:
- if(__unlikely(v != FL(Nil))){
+ if(__unlikely(v != FL_nil)){
FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
@@ -1398,32 +1398,32 @@
NEXT_OP;
OP(OP_NULLP)
- FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-1] == FL(Nil) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-1] == FL_nil ? FL_t : FL_f;
NEXT_OP;
OP(OP_BOOLEANP)
v = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] = (v == FL(t) || v == FL(f)) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = (v == FL_t || v == FL_f) ? FL_t : FL_f;
NEXT_OP;
OP(OP_NUMBERP)
v = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] = fl_isnumber(v) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = fl_isnumber(v) ? FL_t : FL_f;
NEXT_OP;
OP(OP_FIXNUMP)
- FL(stack)[FL(sp)-1] = isfixnum(FL(stack)[FL(sp)-1]) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = isfixnum(FL(stack)[FL(sp)-1]) ? FL_t : FL_f;
NEXT_OP;
OP(OP_BOUNDP)
FL(stack)[ipd] = (uintptr_t)ip;
sym = tosymbol(FL(stack)[FL(sp)-1]);
- FL(stack)[FL(sp)-1] = sym->binding == UNBOUND ? FL(f) : FL(t);
+ FL(stack)[FL(sp)-1] = sym->binding == UNBOUND ? FL_f : FL_t;
NEXT_OP;
OP(OP_BUILTINP)
v = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL_t : FL_f;
NEXT_OP;
OP(OP_FUNCTIONP)
@@ -1431,11 +1431,11 @@
FL(stack)[FL(sp)-1] =
((tag(v) == TAG_FUNCTION &&
(isbuiltin(v) || v>(N_BUILTINS<<3))) ||
- iscbuiltin(v)) ? FL(t) : FL(f);
+ iscbuiltin(v)) ? FL_t : FL_f;
NEXT_OP;
OP(OP_VECTORP)
- FL(stack)[FL(sp)-1] = isvector(FL(stack)[FL(sp)-1]) ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = isvector(FL(stack)[FL(sp)-1]) ? FL_t : FL_f;
NEXT_OP;
OP(OP_JMPL)
@@ -1443,11 +1443,11 @@
NEXT_OP;
OP(OP_BRFL)
- ip += POP() == FL(f) ? GET_INT32(ip) : 4;
+ ip += POP() == FL_f ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRTL)
- ip += POP() != FL(f) ? GET_INT32(ip) : 4;
+ ip += POP() != FL_f ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRNEL)
@@ -1456,24 +1456,24 @@
NEXT_OP;
OP(OP_BRNNL)
- ip += POP() != FL(Nil) ? GET_INT32(ip) : 4;
+ ip += POP() != FL_nil ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_BRN)
- ip += POP() == FL(Nil) ? GET_INT16(ip) : 2;
+ ip += POP() == FL_nil ? GET_INT16(ip) : 2;
NEXT_OP;
OP(OP_BRNL)
- ip += POP() == FL(Nil) ? GET_INT32(ip) : 4;
+ ip += POP() == FL_nil ? GET_INT32(ip) : 4;
NEXT_OP;
OP(OP_EQV)
if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
- v = FL(t);
+ v = FL_t;
else if(!leafp(FL(stack)[FL(sp)-2]) || !leafp(FL(stack)[FL(sp)-1]))
- v = FL(f);
+ v = FL_f;
else
- v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL(t) : FL(f);
+ v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL_t : FL_f;
FL(stack)[FL(sp)-2] = v;
POPN(1);
NEXT_OP;
@@ -1480,9 +1480,9 @@
OP(OP_EQUAL)
if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
- v = FL(t);
+ v = FL_t;
else
- v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL(t) : FL(f);
+ v = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 1) == 0 ? FL_t : FL_f;
FL(stack)[FL(sp)-2] = v;
POPN(1);
NEXT_OP;
@@ -1505,7 +1505,7 @@
POPN(n);
PUSH(v);
}else{
- PUSH(FL(Nil));
+ PUSH(FL_nil);
}
NEXT_OP;
@@ -1525,7 +1525,7 @@
PUSH(car_(v));
v = cdr_(v);
}
- if(v != FL(Nil)){
+ if(v != FL_nil){
FL(stack)[ipd] = (uintptr_t)ip;
lerrorf(FL(ArgError), "apply: last argument: not a list");
}
@@ -1610,10 +1610,10 @@
OP(OP_NUMEQ)
v = FL(stack)[FL(sp)-2]; e = FL(stack)[FL(sp)-1];
if(bothfixnums(v, e))
- v = v == e ? FL(t) : FL(f);
+ v = v == e ? FL_t : FL_f;
else{
FL(stack)[ipd] = (uintptr_t)ip;
- v = numeric_compare(v, e, true, false, true) == 0 ? FL(t) : FL(f);
+ v = numeric_compare(v, e, true, false, true) == 0 ? FL_t : FL_f;
}
POPN(1);
FL(stack)[FL(sp)-1] = v;
@@ -1688,7 +1688,7 @@
FL(stack)[ipd] = (uintptr_t)ip;
s = tofixnum(FL(stack)[FL(sp)-3]);
hi = tofixnum(FL(stack)[FL(sp)-2]);
- v = FL(unspecified);
+ v = FL_unspecified;
FL(sp) += 2;
n = FL(sp);
for(; s <= hi; s++){
@@ -1702,7 +1702,7 @@
NEXT_OP;
OP(OP_LOADNIL)
- PUSH(FL(Nil));
+ PUSH(FL_nil);
NEXT_OP;
OP(OP_LOADI8)
@@ -1785,7 +1785,7 @@
FL(stack)[FL(sp)-2] = i+1;
FL(stack)[FL(sp)-3] = FL(stack)[FL(sp)-4];
FL(stack)[FL(sp)-4] = FL(stack)[FL(sp)-5];
- FL(stack)[FL(sp)-5] = FL(Nil);
+ FL(stack)[FL(sp)-5] = FL_nil;
FL(curr_frame) = FL(sp);
}
ipd = FL(sp)-1;
@@ -1834,7 +1834,7 @@
i = GET_INT32(ip);
ip += 4;
v = FL(stack)[bp+i];
- PUSH(v != UNBOUND ? FL(t) : FL(f));
+ PUSH(v != UNBOUND ? FL_t : FL_f);
NEXT_OP;
OP(OP_KEYARGS)
@@ -1888,7 +1888,7 @@
static value_t
_stacktrace(uint32_t top)
{
- value_t lst = FL(Nil);
+ value_t lst = FL_nil;
fl_gc_handle(&lst);
while(top > 0){
@@ -1905,7 +1905,7 @@
value_t si = FL(stack)[bp+i];
// if there's an error evaluating argument defaults some slots
// might be left set to UNBOUND (issue #22)
- vector_elt(v, i+1) = si == UNBOUND ? FL(unspecified) : si;
+ vector_elt(v, i+1) = si == UNBOUND ? FL_unspecified : si;
}
lst = fl_cons(v, lst);
top = FL(stack)[top-3];
@@ -1921,7 +1921,7 @@
USED(args);
argcount(nargs, 0);
gc(0);
- return FL(t);
+ return FL_t;
}
BUILTIN("function", function)
@@ -1957,7 +1957,7 @@
value_t fv = tagptr(fn, TAG_FUNCTION);
fn->bcode = args[0];
fn->vals = args[1];
- fn->env = FL(Nil);
+ fn->env = FL_nil;
fn->name = FL(lambda);
if(nargs > 2){
if(issymbol(args[2])){
@@ -2022,10 +2022,10 @@
BUILTIN("append", append)
{
- value_t first = FL(Nil), lst, lastcons = FL(Nil);
+ value_t first = FL_nil, lst, lastcons = FL_nil;
uint32_t i;
if(nargs == 0)
- return FL(Nil);
+ return FL_nil;
fl_gc_handle(&first);
fl_gc_handle(&lastcons);
for(i = 0; i < nargs; i++){
@@ -2032,12 +2032,12 @@
lst = args[i];
if(iscons(lst)){
lst = copy_list(lst);
- if(first == FL(Nil))
+ if(first == FL_nil)
first = lst;
else
cdr_(lastcons) = lst;
lastcons = tagptr((((cons_t*)FL(curheap))-1), TAG_CONS);
- }else if(lst != FL(Nil)){
+ }else if(lst != FL_nil){
type_error("cons", lst);
}
}
@@ -2070,8 +2070,8 @@
while(FL(sp)+2+1+nargs >= FL(nstack))
grow_stack();
uint32_t k = FL(sp);
- PUSH(FL(Nil));
- PUSH(FL(Nil));
+ PUSH(FL_nil);
+ PUSH(FL_nil);
for(bool first = true;;){
PUSH(FL(stack)[argSP]);
for(uint32_t i = 1; i < nargs; i++){
@@ -2086,7 +2086,7 @@
POPN(nargs);
PUSH(v);
value_t c = mk_cons();
- car_(c) = POP(); cdr_(c) = FL(Nil);
+ car_(c) = POP(); cdr_(c) = FL_nil;
if(first)
FL(stack)[k+1] = c;
else
@@ -2149,7 +2149,7 @@
h->i = 0;
}
POPN(pargs+1);
- return FL(t);
+ return FL_t;
}
_applyn(pargs);
POPN(pargs+1);
@@ -2162,7 +2162,7 @@
argcount(nargs, 1);
double s = nargs > 0 ? todouble(args[0]) : 0;
sleep_ms(s * 1000.0);
- return FL(t);
+ return FL_t;
}
BUILTIN("*vm-stats*", vm_stats)
@@ -2176,7 +2176,7 @@
ios_printf(ios_stderr, "gc calls %10"PRIu64"\n", (uint64_t)FL(gccalls));
ios_printf(ios_stderr, "max finalizers %10"PRIu32"\n", (uint32_t)FL(maxfinalizers));
ios_printf(ios_stderr, "opcodes %10d\n", N_OPCODES);
- return FL(t);
+ return FL_t;
}
static const builtinspec_t builtin_fns[] = {
@@ -2207,10 +2207,6 @@
FL(nstack) = 4096;
FL(stack) = MEM_ALLOC(FL(nstack)*sizeof(value_t));
- FL(Nil) = builtin(OP_THE_EMPTY_LIST);
- FL(t) = builtin(OP_BOOL_CONST_T);
- FL(f) = builtin(OP_BOOL_CONST_F);
- FL(eof) = builtin(OP_EOF_OBJECT);
FL(lambda) = symbol("λ", false);
FL(function) = symbol("function", false);
FL(quote) = symbol("quote", false);
@@ -2261,12 +2257,12 @@
FL(fsym) = symbol("f", false);
FL(Fsym) = symbol("F", false);
FL(builtins_table_sym) = symbol("*builtins*", false);
- set(FL(printprettysym) = symbol("*print-pretty*", false), FL(t));
- set(FL(printreadablysym) = symbol("*print-readably*", false), FL(t));
+ set(FL(printprettysym) = symbol("*print-pretty*", false), FL_t);
+ set(FL(printreadablysym) = symbol("*print-readably*", false), FL_t);
set(FL(printwidthsym) = symbol("*print-width*", false), fixnum(FL(scr_width)));
- set(FL(printlengthsym) = symbol("*print-length*", false), FL(f));
- set(FL(printlevelsym) = symbol("*print-level*", false), FL(f));
- FL(lasterror) = FL(Nil);
+ set(FL(printlengthsym) = symbol("*print-length*", false), FL_f);
+ set(FL(printlevelsym) = symbol("*print-level*", false), FL_f);
+ FL(lasterror) = FL_nil;
for(i = 0; i < nelem(builtins); i++){
if(builtins[i].name)
set(symbol(builtins[i].name, false), builtin(i));
--- a/flisp.h
+++ b/flisp.h
@@ -158,7 +158,6 @@
// assumes "nargs" is the argument count
#define FOR_ARGS(i, i0, arg, args) for(i=i0; i<nargs && ((arg=args[i]) || 1); i++)
#define N_BUILTINS ((int)N_OPCODES)
-#define unspecified t
#define PUSH(v) \
do{ \
@@ -328,6 +327,14 @@
#include "opcodes.h"
+enum {
+ FL_nil = builtin(OP_THE_EMPTY_LIST),
+ FL_t = builtin(OP_BOOL_CONST_T),
+ FL_f = builtin(OP_BOOL_CONST_F),
+ FL_eof = builtin(OP_EOF_OBJECT),
+ FL_unspecified = FL_t,
+};
+
#define N_GC_HANDLES 1024
typedef struct Fl Fl;
@@ -346,8 +353,7 @@
size_t malloc_pressure;
- value_t Nil, t, f;
- value_t eof, quote;
+ value_t quote;
value_t lambda, trycatch;
value_t backquote, comma, commaat, commadot, function;
--- a/flmain.c
+++ b/flmain.c
@@ -12,7 +12,7 @@
argv_list(int argc, char *argv[])
{
int i;
- value_t lst = FL(Nil), temp;
+ value_t lst = FL_nil, temp;
fl_gc_handle(&lst);
fl_gc_handle(&temp);
for(i = argc-1; i >= 0; i--){
--- a/iostream.c
+++ b/iostream.c
@@ -49,7 +49,7 @@
BUILTIN("iostream?", iostreamp)
{
argcount(nargs, 1);
- return isiostream(args[0]) ? FL(t) : FL(f);
+ return isiostream(args[0]) ? FL_t : FL_f;
}
BUILTIN("eof-object", eof_object)
@@ -56,13 +56,13 @@
{
USED(args);
argcount(nargs, 0);
- return FL(eof);
+ return FL_eof;
}
BUILTIN("eof-object?", eof_objectp)
{
argcount(nargs, 1);
- return args[0] == FL(eof) ? FL(t) : FL(f);
+ return args[0] == FL_eof ? FL_t : FL_f;
}
ios_t *
@@ -122,7 +122,7 @@
USED(toiostream(a));
value_t v = fl_read_sexpr(a);
a = nargs == 0 ? symbol_value(FL(instrsym)) : args[0];
- return ios_eof(toiostream(a)) ? FL(eof) : v;
+ return ios_eof(toiostream(a)) ? FL_eof : v;
}
BUILTIN("io-getc", io_getc)
@@ -133,7 +133,7 @@
int res;
if((res = ios_getutf8(s, &r)) == IOS_EOF)
//lerrorf(FL(IOError), "end of file reached");
- return FL(eof);
+ return FL_eof;
if(res == 0)
lerrorf(FL(IOError), "invalid UTF-8 sequence");
return mk_rune(r);
@@ -146,9 +146,9 @@
ios_t *s = toiostream(args[0]);
int r = ios_wait(s, nargs > 1 ? todouble(args[1]) : -1);
if(r >= 0)
- return r ? FL(t) : FL(f);
+ return r ? FL_t : FL_f;
if(r == IOS_EOF)
- return FL(eof);
+ return FL_eof;
lerrorf(FL(IOError), "i/o error");
}
@@ -169,7 +169,7 @@
off_t off = tooffset(args[1]);
off_t res = ios_skip(s, off);
if(res < 0)
- return FL(f);
+ return FL_f;
return sizeof(res) == sizeof(int64_t) ? mk_int64(res) : mk_int32(res);
}
@@ -176,7 +176,7 @@
BUILTIN("io-flush", io_flush)
{
argcount(nargs, 1);
- return ios_flush(toiostream(args[0])) == 0 ? FL(t) : FL(f);
+ return ios_flush(toiostream(args[0])) == 0 ? FL_t : FL_f;
}
BUILTIN("io-close", io_close)
@@ -183,7 +183,7 @@
{
argcount(nargs, 1);
ios_close(toiostream(args[0]));
- return FL(t);
+ return FL_t;
}
BUILTIN("io-discardbuffer", io_discardbuffer)
@@ -190,13 +190,13 @@
{
argcount(nargs, 1);
ios_purge(toiostream(args[0]));
- return FL(t);
+ return FL_t;
}
BUILTIN("io-eof?", io_eofp)
{
argcount(nargs, 1);
- return ios_eof(toiostream(args[0])) ? FL(t) : FL(f);
+ return ios_eof(toiostream(args[0])) ? FL_t : FL_f;
}
BUILTIN("io-seek", io_seek)
@@ -206,8 +206,8 @@
size_t pos = tosize(args[1]);
off_t res = ios_seek(s, (off_t)pos);
if(res < 0)
- return FL(f);
- return FL(t);
+ return FL_f;
+ return FL_t;
}
BUILTIN("io-pos", io_pos)
@@ -216,7 +216,7 @@
ios_t *s = toiostream(args[0]);
off_t res = ios_pos(s);
if(res < 0)
- return FL(f);
+ return FL_f;
return size_wrap((size_t)res);
}
@@ -252,7 +252,7 @@
size_t got = ios_read(s, data, n);
if(got < n)
//lerrorf(FL(IOError), "end of input reached");
- return FL(eof);
+ return FL_eof;
return cv;
}
@@ -324,7 +324,7 @@
((uint8_t*)cv->data)[n] = 0;
}
if(n == 0 && ios_eof(src))
- return FL(eof);
+ return FL_eof;
return str;
}
@@ -364,7 +364,7 @@
{
argcount(nargs, 2);
toiostream(args[0])->lineno = tosize(args[1]);
- return FL(t);
+ return FL_t;
}
BUILTIN("io-column", io_column)
@@ -377,7 +377,7 @@
{
argcount(nargs, 2);
toiostream(args[0])->colno = tosize(args[1]);
- return FL(t);
+ return FL_t;
}
value_t
@@ -394,7 +394,7 @@
}else{
uint8_t *b = ios_takebuf(st, &n); n--;
b[n] = '\0';
- str = cvalue_from_ref(FL(stringtype), b, n, FL(Nil));
+ str = cvalue_from_ref(FL(stringtype), b, n, FL_nil);
cv_autorelease(ptr(str));
}
return str;
@@ -421,7 +421,7 @@
FL(instrsym) = symbol("*input-stream*", false);
FL(outstrsym) = symbol("*output-stream*", false);
FL(iostreamtype) = define_opaque_type(FL(iostreamsym), sizeof(ios_t), &iostream_vtable, nil);
- set(symbol("*stdout*", false), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL(Nil)));
- set(symbol("*stderr*", false), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL(Nil)));
- set(symbol("*stdin*", false), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL(Nil)));
+ set(symbol("*stdout*", false), cvalue_from_ref(FL(iostreamtype), ios_stdout, sizeof(ios_t), FL_nil));
+ set(symbol("*stderr*", false), cvalue_from_ref(FL(iostreamtype), ios_stderr, sizeof(ios_t), FL_nil));
+ set(symbol("*stdin*", false), cvalue_from_ref(FL(iostreamtype), ios_stdin, sizeof(ios_t), FL_nil));
}
--- a/print.c
+++ b/print.c
@@ -173,8 +173,8 @@
return (cv_len((cvalue_t*)ptr(v)) < SMALL_STR_LEN);
return (
isfixnum(v) || isbuiltin(v) || iscprim(v) ||
- v == FL(f) || v == FL(t) ||
- v == FL(Nil) || v == FL(eof)
+ v == FL_f || v == FL_t ||
+ v == FL_nil || v == FL_eof
);
}
@@ -187,7 +187,7 @@
return 1;
if(iscons(v)){
if(tinyp(car_(v)) &&
- (tinyp(cdr_(v)) || (iscons(cdr_(v)) && tinyp(car_(cdr_(v))) && cdr_(cdr_(v)) == FL(Nil))))
+ (tinyp(cdr_(v)) || (iscons(cdr_(v)) && tinyp(car_(cdr_(v))) && cdr_(cdr_(v)) == FL_nil)))
return 1;
return 0;
}
@@ -280,7 +280,7 @@
{
value_t cd;
char *op;
- if(iscons(cdr_(v)) && cdr_(cdr_(v)) == FL(Nil) &&
+ if(iscons(cdr_(v)) && cdr_(cdr_(v)) == FL_nil &&
!ptrhash_has(&FL(printconses), (void*)cdr_(v)) &&
(((car_(v) == FL(quote)) && (op = "'")) ||
((car_(v) == FL(backquote)) && (op = "`")) ||
@@ -306,7 +306,7 @@
int n_unindented = 1;
while(1){
cd = cdr_(v);
- if(FL(print_length) >= 0 && n >= FL(print_length) && cd != FL(Nil)){
+ if(FL(print_length) >= 0 && n >= FL(print_length) && cd != FL_nil){
outsn("...)", f, 4);
break;
}
@@ -314,7 +314,7 @@
unmark_cons(v);
fl_print_child(f, car_(v));
if(!iscons(cd) || ptrhash_has(&FL(printconses), (void*)cd)){
- if(cd != FL(Nil)){
+ if(cd != FL_nil){
outsn(" . ", f, 3);
fl_print_child(f, cd);
}
@@ -412,13 +412,13 @@
print_symbol_name(f, name);
break;
case TAG_FUNCTION:
- if(v == FL(t))
+ if(v == FL_t)
outsn("#t", f, 2);
- else if(v == FL(f))
+ else if(v == FL_f)
outsn("#f", f, 2);
- else if(v == FL(Nil))
+ else if(v == FL_nil)
outsn("()", f, 2);
- else if(v == FL(eof))
+ else if(v == FL_eof)
outsn("#<eof>", f, 6);
else if(isbuiltin(v)){
if(!FL(print_princ))
@@ -440,7 +440,7 @@
data[i] -= 48;
outc(' ', f);
fl_print_child(f, fn->vals);
- if(fn->env != FL(Nil)){
+ if(fn->env != FL_nil){
outc(' ', f);
fl_print_child(f, fn->env);
}
@@ -852,10 +852,10 @@
void
fl_print(ios_t *f, value_t v)
{
- FL(print_pretty) = symbol_value(FL(printprettysym)) != FL(f);
+ FL(print_pretty) = symbol_value(FL(printprettysym)) != FL_f;
if(FL(print_pretty))
set_print_width();
- FL(print_princ) = symbol_value(FL(printreadablysym)) == FL(f);
+ FL(print_princ) = symbol_value(FL(printreadablysym)) == FL_f;
value_t pl = symbol_value(FL(printlengthsym));
FL(print_length) = isfixnum(pl) ? numval(pl) : -1;
pl = symbol_value(FL(printlevelsym));
@@ -873,6 +873,6 @@
memset(FL(consflags), 0, 4*bitvector_nwords(FL(heapsize)/sizeof(cons_t)));
if((iscons(v) || isvector(v) || isfunction(v) || iscvalue(v)) &&
- !fl_isstring(v) && v != FL(t) && v != FL(f) && v != FL(Nil))
+ !fl_isstring(v) && v != FL_t && v != FL_f && v != FL_nil)
htable_reset(&FL(printconses), 32);
}
--- a/read.c
+++ b/read.c
@@ -524,13 +524,13 @@
lineno0 = RS->lineno;
colno0 = RS->colno - 1;
- PUSH(FL(Nil));
+ PUSH(FL_nil);
pc = &FL(stack)[FL(sp)-1]; // to keep track of current cons cell
t = peek(ctx);
while(t != closer){
if(ios_eof(RS))
parse_error("unexpected end of input: %"PRIu64":%"PRIu64" not closed", lineno0, colno0);
- c = mk_cons(); car_(c) = cdr_(c) = FL(Nil);
+ c = mk_cons(); car_(c) = cdr_(c) = FL_nil;
if(iscons(*pc))
cdr_(*pc) = c;
else{
@@ -577,7 +577,7 @@
take(ctx);
switch(t){
case TOK_OPEN:
- PUSH(FL(Nil));
+ PUSH(FL_nil);
read_list(ctx, &FL(stack)[FL(sp)-1], label, TOK_CLOSE);
return POP();
case TOK_SYM:
@@ -584,11 +584,11 @@
case TOK_NUM:
return ctx->tokval;
case TOK_OPENB:
- PUSH(FL(Nil));
+ PUSH(FL_nil);
read_list(ctx, &FL(stack)[FL(sp)-1], label, TOK_CLOSEB);
return POP();
case TOK_OPENC:
- PUSH(FL(Nil));
+ PUSH(FL_nil);
read_list(ctx, &FL(stack)[FL(sp)-1], label, TOK_CLOSEC);
return POP();
case TOK_COMMA:
@@ -605,7 +605,7 @@
v = cons_reserve(2);
car_(v) = *head;
cdr_(v) = tagptr(((cons_t*)ptr(v))+1, TAG_CONS);
- car_(cdr_(v)) = cdr_(cdr_(v)) = FL(Nil);
+ car_(cdr_(v)) = cdr_(cdr_(v)) = FL_nil;
PUSH(v);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
@@ -618,9 +618,9 @@
case TOK_SHARPSYM:
sym = ctx->tokval;
if(sym == FL(tsym) || sym == FL(Tsym))
- return FL(t);
+ return FL_t;
if(sym == FL(fsym) || sym == FL(Fsym))
- return FL(f);
+ return FL_f;
// constructor notation
c = nextchar();
if(c != '('){
@@ -627,7 +627,7 @@
take(ctx);
parse_error("expected argument list for %s", symbol_name(ctx->tokval));
}
- PUSH(FL(Nil));
+ PUSH(FL_nil);
read_list(ctx, &FL(stack)[FL(sp)-1], UNBOUND, TOK_CLOSE);
if(sym == FL(vu8sym)){
sym = FL(arraysym);
@@ -685,7 +685,7 @@
case TOK_DOT:
parse_error("unexpected '.'");
}
- return FL(unspecified);
+ return FL_unspecified;
}
value_t
--- a/sixel.c
+++ b/sixel.c
@@ -31,7 +31,7 @@
BUILTIN("sixel-ouput?", fsixel_outputp)
{
argcount(nargs, 1);
- return issixeloutput(args[0]) ? FL(t) : FL(f);
+ return issixeloutput(args[0]) ? FL_t : FL_f;
}
static int
@@ -86,7 +86,7 @@
lerrorf(FL(ArgError), "invalid scale factor: %dx%d", scalex, scaley);
f->scalex = scalex;
f->scaley = scaley;
- return FL(t);
+ return FL_t;
}
// :: sixel-output -> palette -> [paltype ->] ...
@@ -160,7 +160,7 @@
}
sixel_dither_set_palette(f->dither, out);
- return FL(t);
+ return FL_t;
}
// :: sixel-output -> iostream -> pixels -> width -> height -> ...
@@ -211,7 +211,7 @@
r = sixel_encode(pix, w, h, 0, f->dither, f->out);
if(SIXEL_FAILED(r))
lerrorf(FL(IOError), "could not encode image");
- return FL(t);
+ return FL_t;
}
static void
--- a/string.c
+++ b/string.c
@@ -12,7 +12,7 @@
BUILTIN("string?", stringp)
{
argcount(nargs, 1);
- return fl_isstring(args[0]) ? FL(t) : FL(f);
+ return fl_isstring(args[0]) ? FL_t : FL_f;
}
BUILTIN("string-length", string_length)
@@ -47,7 +47,7 @@
cprim_t *cp = ptr(args[0]);
if(cp_class(cp) == FL(runetype)){
int w = wcwidth(*(Rune*)cp_data(cp));
- return w < 0 ? FL(f) : fixnum(w);
+ return w < 0 ? FL_f : fixnum(w);
}
}
return size_wrap(u8_strwidth(tostring(args[0])));
@@ -88,7 +88,7 @@
{
int term = 0;
if(nargs == 2)
- term = args[1] != FL(f);
+ term = args[1] != FL_f;
else
argcount(nargs, 1);
if(!fl_isstring(args[0]))
@@ -121,8 +121,8 @@
ios_t *s = value2c(ios_t*, buf);
value_t oldpr = symbol_value(FL(printreadablysym));
value_t oldpp = symbol_value(FL(printprettysym));
- set(FL(printreadablysym), FL(f));
- set(FL(printprettysym), FL(f));
+ set(FL(printreadablysym), FL_f);
+ set(FL(printprettysym), FL_f);
uint32_t i;
FOR_ARGS(i, 0, arg, args){
USED(arg);
@@ -143,7 +143,7 @@
size_t len = cv_len(ptr(args[0]));
size_t dlen = cv_len(ptr(args[1]));
size_t ssz, tokend, tokstart, i = 0;
- value_t first = FL(Nil), c = FL(Nil), last;
+ value_t first = FL_nil, c = FL_nil, last;
size_t junk;
fl_gc_handle(&first);
fl_gc_handle(&last);
@@ -155,7 +155,7 @@
tokend = i;
ssz = tokend - tokstart;
last = c; // save previous cons cell
- c = fl_cons(cvalue_string(ssz), FL(Nil));
+ c = fl_cons(cvalue_string(ssz), FL_nil);
// we've done allocation; reload movable pointers
s = cvalue_data(args[0]);
@@ -165,7 +165,7 @@
memmove(cvalue_data(car_(c)), &s[tokstart], ssz);
// link new cell
- if(last == FL(Nil))
+ if(last == FL_nil)
first = c; // first time, save first cons
else
((cons_t*)ptr(last))->cdr = c;
@@ -253,7 +253,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isalpharune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return isalpharune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("char-lower-case?", char_lower_casep)
@@ -262,7 +262,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return islowerrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return islowerrune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("char-upper-case?", char_upper_casep)
@@ -271,7 +271,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isupperrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return isupperrune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("char-title-case?", char_title_casep)
@@ -280,7 +280,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return istitlerune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return istitlerune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("char-numeric?", char_numericp)
@@ -289,7 +289,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isdigitrune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return isdigitrune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("char-whitespace?", char_whitespacep)
@@ -298,7 +298,7 @@
cprim_t *cp = ptr(args[0]);
if(!iscprim(args[0]) || cp_class(cp) != FL(runetype))
type_error("rune", args[0]);
- return isspacerune(*(Rune*)cp_data(cp)) ? FL(t) : FL(f);
+ return isspacerune(*(Rune*)cp_data(cp)) ? FL_t : FL_f;
}
BUILTIN("string-find", string_find)
@@ -335,7 +335,7 @@
type_error("string", args[1]);
}
if(needlesz > len-start)
- return FL(f);
+ return FL_f;
if(needlesz == 0)
return size_wrap(start);
size_t i;
@@ -343,7 +343,7 @@
if(s[i] == needle[0] && memcmp(&s[i+1], needle+1, needlesz-1) == 0)
return size_wrap(i);
}
- return FL(f);
+ return FL_f;
}
static unsigned long
@@ -392,7 +392,7 @@
if(nargs == 2)
radix = get_radix_arg(args[1]);
if(!fl_read_numtok(str, &n, (int)radix))
- return FL(f);
+ return FL_f;
return n;
}
@@ -401,5 +401,5 @@
argcount(nargs, 1);
char *s = tostring(args[0]);
size_t len = cv_len((cvalue_t*)ptr(args[0]));
- return u8_isvalid(s, len) ? FL(t) : FL(f);
+ return u8_isvalid(s, len) ? FL_t : FL_f;
}
--- a/table.c
+++ b/table.c
@@ -76,7 +76,7 @@
BUILTIN("table?", tablep)
{
argcount(nargs, 1);
- return ishashtable(args[0]) ? FL(t) : FL(f);
+ return ishashtable(args[0]) ? FL_t : FL_f;
}
htable_t *
@@ -101,7 +101,7 @@
htable_t *h = cvalue_data(nt);
htable_new(h, cnt/2);
size_t i;
- value_t k = FL(Nil), arg;
+ value_t k = FL_nil, arg;
FOR_ARGS(i, 0, arg, args){
if(i & 1)
equalhash_put(h, (void*)k, (void*)arg);
@@ -158,7 +158,7 @@
{
argcount(nargs, 2);
htable_t *h = totable(args[0]);
- return equalhash_has(h, (void*)args[1]) ? FL(t) : FL(f);
+ return equalhash_has(h, (void*)args[1]) ? FL_t : FL_f;
}
// (del! table key)
--- a/terminal_posix.c
+++ b/terminal_posix.c
@@ -54,7 +54,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(true, cursorvisible) == 0 ? FL(t) : FL(f);
+ return termsetraw(true, cursorvisible) == 0 ? FL_t : FL_f;
}
BUILTIN("terminal-leave-raw-mode", terminal_leave_raw_mode)
@@ -61,7 +61,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(false, cursorvisible) == 0 ? FL(t) : FL(f);
+ return termsetraw(false, cursorvisible) == 0 ? FL_t : FL_f;
}
BUILTIN("terminal-show-cursor", terminal_show_cursor)
@@ -68,7 +68,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(inraw, true) == 0 ? FL(t) : FL(f);
+ return termsetraw(inraw, true) == 0 ? FL_t : FL_f;
}
BUILTIN("terminal-hide-cursor", terminal_hide_cursor)
@@ -75,7 +75,7 @@
{
USED(args);
argcount(nargs, 0);
- return termsetraw(inraw, false) == 0 ? FL(t) : FL(f);
+ return termsetraw(inraw, false) == 0 ? FL_t : FL_f;
}
BUILTIN("terminal-get-size", terminal_get_size)
@@ -84,11 +84,11 @@
argcount(nargs, 0);
struct winsize s;
if(ioctl(STDIN_FILENO, TIOCGWINSZ, &s) < 0)
- return FL(f);
+ return FL_f;
value_t v = mk_cons(), tex, pix;
car_(v) = tex = mk_cons();
car_(tex) = fixnum(s.ws_col);
- cdr_(tex) = mk_cons(); car_(cdr_(tex)) = fixnum(s.ws_row); cdr_(cdr_(tex)) = FL(Nil);
+ cdr_(tex) = mk_cons(); car_(cdr_(tex)) = fixnum(s.ws_row); cdr_(cdr_(tex)) = FL_nil;
int x = s.ws_xpixel, y = s.ws_ypixel;
bool wasraw = inraw;
if((x == 0 || y == 0) && isatty(STDOUT_FILENO) && termsetraw(true, cursorvisible) == 0){
@@ -123,9 +123,9 @@
if(!wasraw)
termsetraw(false, cursorvisible);
}
- cdr_(v) = pix = mk_cons(); cdr_(pix) = FL(Nil);
+ cdr_(v) = pix = mk_cons(); cdr_(pix) = FL_nil;
car_(pix) = mk_cons(); pix = car_(pix);
car_(pix) = fixnum(x);
- cdr_(pix) = mk_cons(); car_(cdr_(pix)) = fixnum(y); cdr_(cdr_(pix)) = FL(Nil);
+ cdr_(pix) = mk_cons(); car_(cdr_(pix)) = fixnum(y); cdr_(cdr_(pix)) = FL_nil;
return v;
}