ref: a7bae3835d8f73f5ad2a6fbaec4bd650cd0c1dea
parent: 4531f42eb7ae46af10997d0583d3e3e113e59d1d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Nov 10 14:22:30 EST 2024
more renames and rearrangement
--- a/cvalues.c
+++ b/cvalues.c
@@ -16,13 +16,13 @@
{
if(FL(nfinalizers) == FL(maxfinalizers)){
size_t nn = FL(maxfinalizers) == 0 ? 256 : FL(maxfinalizers)*2;
- cvalue_t **temp = LLT_REALLOC(FL(Finalizers), nn*sizeof(cvalue_t*));
+ cvalue_t **temp = LLT_REALLOC(FL(finalizers), nn*sizeof(cvalue_t*));
if(temp == nil)
lerrorf(FL(MemoryError), "out of memory");
- FL(Finalizers) = temp;
+ FL(finalizers) = temp;
FL(maxfinalizers) = nn;
}
- FL(Finalizers)[FL(nfinalizers)++] = cv;
+ FL(finalizers)[FL(nfinalizers)++] = cv;
}
// remove dead objects from finalization list in-place
@@ -29,7 +29,7 @@
void
sweep_finalizers(void)
{
- cvalue_t **lst = FL(Finalizers);
+ cvalue_t **lst = FL(finalizers);
size_t n = 0, ndel = 0, l = FL(nfinalizers);
cvalue_t *tmp;
#define SWAP_sf(a, b) (tmp = a, a = b, b = tmp, 1)
@@ -252,7 +252,7 @@
{ \
if(nargs == 0){ \
PUSH(fixnum(0)); \
- args = &FL(Stack)[FL(SP)-1]; \
+ args = &FL(stack)[FL(sp)-1]; \
} \
value_t cp = cprim(FL(typenam##type), sizeof(ctype)); \
if(cvalue_##ctype##_init(FL(typenam##type), args[0], cp_data((cprim_t*)ptr(cp)))) \
@@ -314,7 +314,7 @@
{
if(nargs == 0){
PUSH(fixnum(0));
- args = &FL(Stack)[FL(SP)-1];
+ args = &FL(stack)[FL(sp)-1];
}
value_t cv = cvalue(FL(mpinttype), sizeof(mpint*));
if(cvalue_mpint_init(FL(mpinttype), args[0], cv_data((cvalue_t*)ptr(cv))))
--- a/flisp.c
+++ b/flisp.c
@@ -55,13 +55,13 @@
#define FL_TRY \
fl_exception_context_t _ctx; int l__tr, l__ca; \
- _ctx.sp = FL(SP); _ctx.frame = FL(curr_frame); _ctx.rdst = FL(readstate); _ctx.prev = FL(exctx); \
- _ctx.ngchnd = FL(N_GCHND); FL(exctx) = &_ctx; \
+ _ctx.sp = FL(sp); _ctx.frame = FL(curr_frame); _ctx.rdst = FL(readstate); _ctx.prev = FL(exctx); \
+ _ctx.ngchnd = FL(ngchandles); FL(exctx) = &_ctx; \
if(!setjmp(_ctx.buf)) \
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 \
@@ -74,11 +74,11 @@
void
fl_savestate(fl_exception_context_t *_ctx)
{
- _ctx->sp = FL(SP);
+ _ctx->sp = FL(sp);
_ctx->frame = FL(curr_frame);
_ctx->rdst = FL(readstate);
_ctx->prev = FL(exctx);
- _ctx->ngchnd = FL(N_GCHND);
+ _ctx->ngchnd = FL(ngchandles);
}
void
@@ -86,7 +86,7 @@
{
FL(lasterror) = FL(Nil);
FL(throwing_frame) = 0;
- FL(SP) = _ctx->sp;
+ FL(sp) = _ctx->sp;
FL(curr_frame) = _ctx->frame;
}
@@ -101,7 +101,7 @@
}
if(FL(throwing_frame) == 0)
FL(throwing_frame) = FL(curr_frame);
- FL(N_GCHND) = FL(exctx)->ngchnd;
+ FL(ngchandles) = FL(exctx)->ngchnd;
fl_exception_context_t *thisctx = FL(exctx);
if(FL(exctx)->prev) // don't throw past toplevel
FL(exctx) = FL(exctx)->prev;
@@ -213,7 +213,7 @@
argcount(nargs, 0);
USED(args);
gensym_t *gs = alloc_words(sizeof(gensym_t)/sizeof(void*));
- gs->id = FL(_gensym_ctr)++;
+ gs->id = FL(gensym_ctr)++;
gs->binding = UNBOUND;
gs->isconst = 0;
gs->type = nil;
@@ -318,16 +318,16 @@
void
fl_gc_handle(value_t *pv)
{
- if(__unlikely(FL(N_GCHND) >= N_GC_HANDLES))
+ if(__unlikely(FL(ngchandles) >= N_GC_HANDLES))
lerrorf(FL(MemoryError), "out of gc handles");
- FL(GCHandleStack)[FL(N_GCHND)++] = pv;
+ FL(gchandles)[FL(ngchandles)++] = pv;
}
void
fl_free_gc_handles(uint32_t n)
{
- assert(FL(N_GCHND) >= n);
- FL(N_GCHND) -= n;
+ assert(FL(ngchandles) >= n);
+ FL(ngchandles) -= n;
}
value_t
@@ -457,21 +457,21 @@
if(FL(throwing_frame) > FL(curr_frame)){
top = FL(throwing_frame) - 4;
- f = FL(Stack)[FL(throwing_frame)-4];
+ f = FL(stack)[FL(throwing_frame)-4];
}else{
- top = FL(SP);
+ top = FL(sp);
f = FL(curr_frame);
}
while(1){
for(i = f; i < top; i++)
- FL(Stack)[i] = relocate(FL(Stack)[i]);
+ FL(stack)[i] = relocate(FL(stack)[i]);
if(f == 0)
break;
top = f - 4;
- f = FL(Stack)[f-4];
+ f = FL(stack)[f-4];
}
- for(i = 0; i < FL(N_GCHND); i++)
- *FL(GCHandleStack)[i] = relocate(*FL(GCHandleStack)[i]);
+ for(i = 0; i < FL(ngchandles); i++)
+ *FL(gchandles)[i] = relocate(*FL(gchandles)[i]);
trace_globals(FL(symtab));
relocate_typetable();
rs = FL(readstate);
@@ -528,12 +528,12 @@
static void
grow_stack(void)
{
- size_t newsz = FL(N_STACK) * 2;
- value_t *ns = LLT_REALLOC(FL(Stack), newsz*sizeof(value_t));
+ size_t newsz = FL(nstack) * 2;
+ value_t *ns = LLT_REALLOC(FL(stack), newsz*sizeof(value_t));
if(__unlikely(ns == nil))
lerrorf(FL(MemoryError), "stack overflow");
- FL(Stack) = ns;
- FL(N_STACK) = newsz;
+ FL(stack) = ns;
+ FL(nstack) = newsz;
}
// utils ----------------------------------------------------------------------
@@ -542,11 +542,11 @@
static value_t
_applyn(uint32_t n)
{
- value_t f = FL(Stack)[FL(SP)-n-1];
- uint32_t saveSP = FL(SP);
+ value_t f = FL(stack)[FL(sp)-n-1];
+ uint32_t saveSP = FL(sp);
value_t v;
if(iscbuiltin(f)){
- v = ((builtin_t*)ptr(f))[3](&FL(Stack)[FL(SP)-n], n);
+ v = ((builtin_t*)ptr(f))[3](&FL(stack)[FL(sp)-n], n);
}else if(isfunction(f)){
v = apply_cl(n);
}else if(__likely(isbuiltin(f))){
@@ -553,12 +553,12 @@
value_t tab = symbol_value(FL(builtins_table_sym));
if(__unlikely(ptr(tab) == nil))
unbound_error(tab);
- FL(Stack)[FL(SP)-n-1] = vector_elt(tab, uintval(f));
+ FL(stack)[FL(sp)-n-1] = vector_elt(tab, uintval(f));
v = apply_cl(n);
}else{
type_error("function", f);
}
- FL(SP) = saveSP;
+ FL(sp) = saveSP;
return v;
}
@@ -566,16 +566,16 @@
fl_apply(value_t f, value_t l)
{
value_t v = l;
- uint32_t n = FL(SP);
+ uint32_t n = FL(sp);
PUSH(f);
while(iscons(v)){
- if(FL(SP) >= FL(N_STACK))
+ if(FL(sp) >= FL(nstack))
grow_stack();
PUSH(car_(v));
v = cdr_(v);
}
- n = FL(SP) - n - 1;
+ n = FL(sp) - n - 1;
v = _applyn(n);
POPN(n+1);
return v;
@@ -589,7 +589,7 @@
size_t i;
PUSH(f);
- while(FL(SP)+n >= FL(N_STACK))
+ while(FL(sp)+n >= FL(nstack))
grow_stack();
for(i = 0; i < n; i++){
value_t a = va_arg(ap, value_t);
@@ -606,10 +606,10 @@
{
va_list ap;
va_start(ap, n);
- uint32_t si = FL(SP);
+ uint32_t si = FL(sp);
size_t i;
- while(FL(SP)+n >= FL(N_STACK))
+ while(FL(sp)+n >= FL(nstack))
grow_stack();
for(i = 0; i < n; i++){
value_t a = va_arg(ap, value_t);
@@ -618,7 +618,7 @@
cons_t *c = alloc_words(n*2);
cons_t *l = c;
for(i = 0; i < n; i++){
- c->car = FL(Stack)[si++];
+ c->car = FL(stack)[si++];
c->cdr = tagptr(c+1, TAG_CONS);
c++;
}
@@ -700,8 +700,8 @@
return FL(Nil);
PUSH(FL(Nil));
PUSH(L);
- value_t *plcons = &FL(Stack)[FL(SP)-2];
- value_t *pL = &FL(Stack)[FL(SP)-1];
+ value_t *plcons = &FL(stack)[FL(sp)-2];
+ value_t *pL = &FL(stack)[FL(sp)-1];
value_t c;
c = mk_cons(); PUSH(c); // save first cons
car_(c) = car_(*pL);
@@ -724,22 +724,22 @@
static value_t
do_trycatch(void)
{
- uint32_t saveSP = FL(SP);
+ uint32_t saveSP = FL(sp);
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;
+ value_t thunk = FL(stack)[FL(sp)-2];
+ FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-1];
+ FL(stack)[FL(sp)-1] = thunk;
FL_TRY{
v = apply_cl(0);
}
FL_CATCH{
- v = FL(Stack)[saveSP-2];
+ v = FL(stack)[saveSP-2];
PUSH(v);
PUSH(FL(lasterror));
v = apply_cl(1);
}
- FL(SP) = saveSP;
+ FL(sp) = saveSP;
return v;
}
@@ -754,10 +754,10 @@
uint32_t ntot = nreq+extr;
value_t args[64], v = FL(Nil);
uint32_t i, a = 0, nrestargs;
- value_t s1 = FL(Stack)[FL(SP)-1];
- value_t s2 = FL(Stack)[FL(SP)-2];
- value_t s4 = FL(Stack)[FL(SP)-4];
- value_t s5 = FL(Stack)[FL(SP)-5];
+ value_t s1 = FL(stack)[FL(sp)-1];
+ value_t s2 = FL(stack)[FL(sp)-2];
+ value_t s4 = FL(stack)[FL(sp)-4];
+ value_t s5 = FL(stack)[FL(sp)-5];
if(__unlikely(nargs < nreq))
lerrorf(FL(ArgError), "too few arguments");
if(__unlikely(extr > nelem(args)))
@@ -765,7 +765,7 @@
for(i = 0; i < extr; i++)
args[i] = UNBOUND;
for(i = nreq; i < nargs; i++){
- v = FL(Stack)[bp+i];
+ v = FL(stack)[bp+i];
if(issymbol(v) && iskeyword((symbol_t*)ptr(v)))
break;
if(a >= nopt)
@@ -789,7 +789,7 @@
idx += nopt;
if(args[idx] == UNBOUND){
// if duplicate key, keep first value
- args[idx] = FL(Stack)[bp+i];
+ args[idx] = FL(stack)[bp+i];
}
}else{
lerrorf(FL(ArgError), "unsupported keyword %s", symbol_name(v));
@@ -797,7 +797,7 @@
i++;
if(i >= nargs)
break;
- v = FL(Stack)[bp+i];
+ v = FL(stack)[bp+i];
}while(issymbol(v) && iskeyword((symbol_t*)ptr(v)));
no_kw:
nrestargs = nargs - i;
@@ -805,16 +805,16 @@
lerrorf(FL(ArgError), "too many arguments");
nargs = ntot + nrestargs;
if(nrestargs)
- memmove(&FL(Stack)[bp+ntot], &FL(Stack)[bp+i], nrestargs*sizeof(value_t));
- memmove(&FL(Stack)[bp+nreq], args, extr*sizeof(value_t));
- FL(SP) = bp + nargs;
- assert(FL(SP) < FL(N_STACK)-5);
+ memmove(&FL(stack)[bp+ntot], &FL(stack)[bp+i], nrestargs*sizeof(value_t));
+ memmove(&FL(stack)[bp+nreq], args, extr*sizeof(value_t));
+ FL(sp) = bp + nargs;
+ assert(FL(sp) < FL(nstack)-5);
PUSH(s5);
PUSH(s4);
PUSH(nargs);
PUSH(s2);
PUSH(s1);
- FL(curr_frame) = FL(SP);
+ FL(curr_frame) = FL(sp);
return nargs;
}
@@ -876,36 +876,36 @@
USED(v);
apply_cl_top:
captured = 0;
- func = FL(Stack)[FL(SP)-nargs-1];
+ func = FL(stack)[FL(sp)-nargs-1];
ip = cv_data((cvalue_t*)ptr(fn_bcode(func)));
assert(!ismanaged((uintptr_t)ip));
- i = FL(SP)+GET_INT32(ip);
- while(i >= FL(N_STACK))
+ i = FL(sp)+GET_INT32(ip);
+ while(i >= FL(nstack))
grow_stack();
ip += 4;
- bp = FL(SP)-nargs;
+ bp = FL(sp)-nargs;
PUSH(fn_env(func));
PUSH(FL(curr_frame));
PUSH(nargs);
- ipd = FL(SP);
- FL(SP)++; // ip
+ ipd = FL(sp);
+ FL(sp)++; // ip
PUSH(0); // captured?
- FL(curr_frame) = FL(SP);
+ FL(curr_frame) = FL(sp);
op = *ip++;
while(1){
switch(op){
OP(OP_LOADA0)
- PUSH(captured ? vector_elt(FL(Stack)[bp], 0) : FL(Stack)[bp]);
+ PUSH(captured ? vector_elt(FL(stack)[bp], 0) : FL(stack)[bp]);
NEXT_OP;
OP(OP_LOADA1)
- PUSH(captured ? vector_elt(FL(Stack)[bp], 1) : FL(Stack)[bp+1]);
+ PUSH(captured ? vector_elt(FL(stack)[bp], 1) : FL(stack)[bp+1]);
NEXT_OP;
OP(OP_LOADV)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
assert(*ip < vector_size(v));
PUSH(vector_elt(v, *ip++));
NEXT_OP;
@@ -936,15 +936,15 @@
n = *ip++; // nargs
}
do_call:
- FL(Stack)[ipd] = (uintptr_t)ip;
- func = FL(Stack)[FL(SP)-n-1];
+ FL(stack)[ipd] = (uintptr_t)ip;
+ func = FL(stack)[FL(sp)-n-1];
if(tag(func) == TAG_FUNCTION){
if(func > (N_BUILTINS<<3)){
if(tail){
- FL(curr_frame) = FL(Stack)[FL(curr_frame)-4];
+ FL(curr_frame) = FL(stack)[FL(curr_frame)-4];
for(s = -1; s < (fixnum_t)n; s++)
- FL(Stack)[bp+s] = FL(Stack)[FL(SP)-n+s];
- FL(SP) = bp+n;
+ FL(stack)[bp+s] = FL(stack)[FL(sp)-n+s];
+ FL(sp) = bp+n;
}
nargs = n;
goto apply_cl_top;
@@ -957,9 +957,9 @@
else if(s != ANYARGS && (signed)n < -s)
argcount(n, -s);
// remove function arg
- for(s = FL(SP)-n-1; s < (int)FL(SP)-1; s++)
- FL(Stack)[s] = FL(Stack)[s+1];
- FL(SP)--;
+ for(s = FL(sp)-n-1; s < (int)FL(sp)-1; s++)
+ FL(stack)[s] = FL(stack)[s+1];
+ FL(sp)--;
switch(i){
case OP_LIST: goto apply_list;
case OP_VECTOR: goto apply_vector;
@@ -975,21 +975,21 @@
}
}
}else if(__likely(iscbuiltin(func))){
- s = FL(SP);
- v = (((builtin_t*)ptr(func))[3])(&FL(Stack)[FL(SP)-n], n);
- FL(SP) = s-n;
- FL(Stack)[FL(SP)-1] = v;
+ s = FL(sp);
+ v = (((builtin_t*)ptr(func))[3])(&FL(stack)[FL(sp)-n], n);
+ FL(sp) = s-n;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
}
type_error("function", func);
OP(OP_LOADGL)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
v = vector_elt(v, GET_INT32(ip));
ip += 4;
if(0){
OP(OP_LOADG)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
assert(*ip < vector_size(v));
v = vector_elt(v, *ip);
ip++;
@@ -997,7 +997,7 @@
assert(issymbol(v));
sym = (symbol_t*)ptr(v);
if(__unlikely(sym->binding == UNBOUND)){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
unbound_error(v);
}
PUSH(sym->binding);
@@ -1007,12 +1007,12 @@
assert(nargs > 0);
i = *ip++;
if(captured){
- e = FL(Stack)[bp];
+ e = FL(stack)[bp];
assert(isvector(e));
assert(i < vector_size(e));
v = vector_elt(e, i);
}else{
- v = FL(Stack)[bp+i];
+ v = FL(stack)[bp+i];
}
PUSH(v);
NEXT_OP;
@@ -1020,7 +1020,7 @@
OP(OP_LOADC)
s = *ip++;
i = *ip++;
- v = FL(Stack)[bp+nargs];
+ v = FL(stack)[bp+nargs];
while(s--)
v = vector_elt(v, vector_size(v)-1);
assert(isvector(v));
@@ -1030,40 +1030,40 @@
OP(OP_RET)
v = POP();
- FL(SP) = FL(curr_frame);
- FL(curr_frame) = FL(Stack)[FL(SP)-4];
+ FL(sp) = FL(curr_frame);
+ FL(curr_frame) = FL(stack)[FL(sp)-4];
if(FL(curr_frame) == top_frame)
return v;
- FL(SP) -= 5+nargs;
- captured = FL(Stack)[FL(curr_frame)-1];
+ FL(sp) -= 5+nargs;
+ captured = FL(stack)[FL(curr_frame)-1];
ipd = FL(curr_frame)-2;
- ip = (uint8_t*)FL(Stack)[ipd];
- nargs = FL(Stack)[FL(curr_frame)-3];
+ ip = (uint8_t*)FL(stack)[ipd];
+ nargs = FL(stack)[FL(curr_frame)-3];
bp = FL(curr_frame) - 5 - nargs;
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_DUP)
- FL(SP)++;
- FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-2];
+ FL(sp)++;
+ FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-2];
NEXT_OP;
OP(OP_CAR)
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
- FL(Stack)[FL(SP)-1] = car_(v);
+ FL(stack)[FL(sp)-1] = car_(v);
NEXT_OP;
OP(OP_CDR)
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
- FL(Stack)[FL(SP)-1] = cdr_(v);
+ FL(stack)[FL(sp)-1] = cdr_(v);
NEXT_OP;
OP(OP_CLOSURE)
@@ -1076,41 +1076,41 @@
pv[0] = fixnum(n+1);
pv++;
do{
- pv[n] = FL(Stack)[bp+n];
+ pv[n] = FL(stack)[bp+n];
}while(n--);
// environment representation changed; install
// the new representation so everybody can see it
captured = 1;
- FL(Stack)[FL(curr_frame)-1] = 1;
- FL(Stack)[bp] = FL(Stack)[FL(SP)-1];
+ FL(stack)[FL(curr_frame)-1] = 1;
+ FL(stack)[bp] = FL(stack)[FL(sp)-1];
}else{
- PUSH(FL(Stack)[bp]); // env has already been captured; share
+ PUSH(FL(stack)[bp]); // env has already been captured; share
}
if(FL(curheap) > FL(lim)-2)
gc(0);
pv = (value_t*)FL(curheap);
FL(curheap) += 4*sizeof(value_t);
- e = FL(Stack)[FL(SP)-2]; // closure to copy
+ e = FL(stack)[FL(sp)-2]; // closure to copy
assert(isfunction(e));
pv[0] = ((value_t*)ptr(e))[0];
pv[1] = ((value_t*)ptr(e))[1];
- pv[2] = FL(Stack)[FL(SP)-1]; // env
+ pv[2] = FL(stack)[FL(sp)-1]; // env
pv[3] = ((value_t*)ptr(e))[3];
POPN(1);
- FL(Stack)[FL(SP)-1] = tagptr(pv, TAG_FUNCTION);
+ FL(stack)[FL(sp)-1] = tagptr(pv, TAG_FUNCTION);
NEXT_OP;
OP(OP_SETA)
assert(nargs > 0);
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
i = *ip++;
if(captured){
- e = FL(Stack)[bp];
+ e = FL(stack)[bp];
assert(isvector(e));
assert(i < vector_size(e));
vector_elt(e, i) = v;
}else{
- FL(Stack)[bp+i] = v;
+ FL(stack)[bp+i] = v;
}
NEXT_OP;
@@ -1119,15 +1119,15 @@
NEXT_OP;
OP(OP_LOADC00)
- PUSH(vector_elt(FL(Stack)[bp+nargs], 0));
+ PUSH(vector_elt(FL(stack)[bp+nargs], 0));
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)
- ip += FL(Stack)[FL(SP)-2] != FL(Stack)[FL(SP)-1] ? GET_INT16(ip) : 2;
+ ip += FL(stack)[FL(sp)-2] != FL(stack)[FL(sp)-1] ? GET_INT16(ip) : 2;
POPN(2);
NEXT_OP;
@@ -1140,29 +1140,29 @@
NEXT_OP;
OP(OP_LOADC01)
- PUSH(vector_elt(FL(Stack)[bp+nargs], 1));
+ PUSH(vector_elt(FL(stack)[bp+nargs], 1));
NEXT_OP;
OP(OP_AREF)
- FL(Stack)[ipd] = (uintptr_t)ip;
- v = FL(Stack)[FL(SP)-2];
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = FL(stack)[FL(sp)-2];
if(isvector(v)){
- e = FL(Stack)[FL(SP)-1];
+ e = FL(stack)[FL(sp)-1];
i = isfixnum(e) ? numval(e) : (uint32_t)toulong(e);
if(__unlikely(i >= vector_size(v)))
bounds_error(v, e);
v = vector_elt(v, i);
}else if(__likely(isarray(v))){
- v = cvalue_array_aref(&FL(Stack)[FL(SP)-2]);
+ v = cvalue_array_aref(&FL(stack)[FL(sp)-2]);
}else{
type_error("sequence", v);
}
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
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)
@@ -1178,32 +1178,32 @@
NEXT_OP;
OP(OP_LT)
- x = numeric_compare(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 0, 0, 0);
+ x = numeric_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 0, 0, 0);
if(x > 1)
- x = numval(fl_compare(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1]));
+ x = numval(fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1]));
POPN(1);
- FL(Stack)[FL(SP)-1] = x < 0 ? FL(t) : FL(f);
+ FL(stack)[FL(sp)-1] = x < 0 ? FL(t) : FL(f);
NEXT_OP;
OP(OP_ADD2)
- FL(Stack)[ipd] = (uintptr_t)ip;
- if(bothfixnums(FL(Stack)[FL(SP)-1], FL(Stack)[FL(SP)-2])){
- s = numval(FL(Stack)[FL(SP)-1]) + numval(FL(Stack)[FL(SP)-2]);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ if(bothfixnums(FL(stack)[FL(sp)-1], FL(stack)[FL(sp)-2])){
+ s = numval(FL(stack)[FL(sp)-1]) + numval(FL(stack)[FL(sp)-2]);
v = fits_fixnum(s) ? fixnum(s) : mk_xlong(s);
}else{
- v = fl_add_any(&FL(Stack)[FL(SP)-2], 2, 0);
+ v = fl_add_any(&FL(stack)[FL(sp)-2], 2, 0);
}
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_SETCDR)
- v = FL(Stack)[FL(SP)-2];
+ v = FL(stack)[FL(sp)-2];
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
- cdr_(v) = FL(Stack)[FL(SP)-1];
+ cdr_(v) = FL(stack)[FL(sp)-1];
POPN(1);
NEXT_OP;
@@ -1216,77 +1216,77 @@
gc(0);
c = (cons_t*)FL(curheap);
FL(curheap) += sizeof(cons_t);
- c->car = FL(Stack)[FL(SP)-2];
- c->cdr = FL(Stack)[FL(SP)-1];
- FL(Stack)[FL(SP)-2] = tagptr(c, TAG_CONS);
+ c->car = FL(stack)[FL(sp)-2];
+ c->cdr = FL(stack)[FL(sp)-1];
+ FL(stack)[FL(sp)-2] = tagptr(c, TAG_CONS);
POPN(1);
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)
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
v = cdr_(v);
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
- FL(Stack)[FL(SP)-1] = car_(v);
+ FL(stack)[FL(sp)-1] = car_(v);
NEXT_OP;
OP(OP_NEG)
do_neg:
- FL(Stack)[ipd] = (uintptr_t)ip;
- FL(Stack)[FL(SP)-1] = fl_neg(FL(Stack)[FL(SP)-1]);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[FL(sp)-1] = fl_neg(FL(stack)[FL(sp)-1]);
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);
+ v = FL(stack)[FL(sp)-1];
+ 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);
+ v = FL(stack)[FL(sp)-1];
+ 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)[ipd] = (uintptr_t)ip;
+ sym = tosymbol(FL(stack)[FL(sp)-1]);
+ 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);
+ v = FL(stack)[FL(sp)-1];
+ FL(stack)[FL(sp)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL(t) : FL(f);
NEXT_OP;
OP(OP_FUNCTIONP)
- v = FL(Stack)[FL(SP)-1];
- FL(Stack)[FL(SP)-1] =
+ v = FL(stack)[FL(sp)-1];
+ FL(stack)[FL(sp)-1] =
((tag(v) == TAG_FUNCTION &&
(isbuiltin(v) || v>(N_BUILTINS<<3))) ||
iscbuiltin(v)) ? FL(t) : FL(f);
@@ -1293,7 +1293,7 @@
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)
@@ -1309,7 +1309,7 @@
NEXT_OP;
OP(OP_BRNEL)
- ip += FL(Stack)[FL(SP)-2] != FL(Stack)[FL(SP)-1] ? GET_INT32(ip) : 4;
+ ip += FL(stack)[FL(sp)-2] != FL(stack)[FL(sp)-1] ? GET_INT32(ip) : 4;
POPN(2);
NEXT_OP;
@@ -1326,32 +1326,32 @@
NEXT_OP;
OP(OP_EQV)
- if(FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1])
+ if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
v = FL(t);
- else if(!leafp(FL(Stack)[FL(SP)-2]) || !leafp(FL(Stack)[FL(SP)-1]))
+ else if(!leafp(FL(stack)[FL(sp)-2]) || !leafp(FL(stack)[FL(sp)-1]))
v = FL(f);
else
- v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(t) : FL(f);
- FL(Stack)[FL(SP)-2] = v;
+ 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;
OP(OP_EQUAL)
- if(FL(Stack)[FL(SP)-2] == FL(Stack)[FL(SP)-1])
+ if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
v = FL(t);
else
- v = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 1) == 0 ? FL(t) : FL(f);
- FL(Stack)[FL(SP)-2] = v;
+ 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;
OP(OP_SETCAR)
- v = FL(Stack)[FL(SP)-2];
+ v = FL(stack)[FL(sp)-2];
if(__unlikely(!iscons(v))){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
type_error("cons", v);
}
- car_(v) = FL(Stack)[FL(SP)-1];
+ car_(v) = FL(stack)[FL(sp)-1];
POPN(1);
NEXT_OP;
@@ -1359,7 +1359,7 @@
n = *ip++;
apply_list:
if(n > 0){
- v = list(&FL(Stack)[FL(SP)-n], n, 0);
+ v = list(&FL(stack)[FL(sp)-n], n, 0);
POPN(n);
PUSH(v);
}else{
@@ -1376,14 +1376,14 @@
n = *ip++;
apply_apply:
v = POP(); // arglist
- n = FL(SP)-(n-2); // n-2 == # leading arguments not in the list
+ n = FL(sp)-(n-2); // n-2 == # leading arguments not in the list
while(iscons(v)){
- if(FL(SP) >= FL(N_STACK))
+ if(FL(sp) >= FL(nstack))
grow_stack();
PUSH(car_(v));
v = cdr_(v);
}
- n = FL(SP)-n;
+ n = FL(sp)-n;
goto do_call;
OP(OP_ADD)
@@ -1390,10 +1390,10 @@
n = *ip++;
apply_add:
s = 0;
- i = FL(SP)-n;
- for(; i < FL(SP); i++){
- if(isfixnum(FL(Stack)[i])){
- s += numval(FL(Stack)[i]);
+ i = FL(sp)-n;
+ for(; i < FL(sp); i++){
+ if(isfixnum(FL(stack)[i])){
+ s += numval(FL(stack)[i]);
if(__unlikely(!fits_fixnum(s))){
i++;
goto add_ovf;
@@ -1400,12 +1400,12 @@
}
}else{
add_ovf:
- FL(Stack)[ipd] = (uintptr_t)ip;
- v = fl_add_any(&FL(Stack)[i], FL(SP)-i, s);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = fl_add_any(&FL(stack)[i], FL(sp)-i, s);
break;
}
}
- if(i == FL(SP))
+ if(i == FL(sp))
v = fixnum(s);
POPN(n);
PUSH(v);
@@ -1418,15 +1418,15 @@
goto do_sub2;
if(n == 1)
goto do_neg;
- FL(Stack)[ipd] = (uintptr_t)ip;
- i = FL(SP)-n;
+ FL(stack)[ipd] = (uintptr_t)ip;
+ i = FL(sp)-n;
// we need to pass the full arglist on to fl_add_any
// so it can handle rest args properly
- PUSH(FL(Stack)[i]);
- FL(Stack)[i] = fixnum(0);
- FL(Stack)[i+1] = fl_neg(fl_add_any(&FL(Stack)[i], n, 0));
- FL(Stack)[i] = POP();
- v = fl_add_any(&FL(Stack)[i], 2, 0);
+ PUSH(FL(stack)[i]);
+ FL(stack)[i] = fixnum(0);
+ FL(stack)[i+1] = fl_neg(fl_add_any(&FL(stack)[i], n, 0));
+ FL(stack)[i] = POP();
+ v = fl_add_any(&FL(stack)[i], 2, 0);
POPN(n);
PUSH(v);
NEXT_OP;
@@ -1433,23 +1433,23 @@
OP(OP_SUB2)
do_sub2:
- if(bothfixnums(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1])){
- s = numval(FL(Stack)[FL(SP)-2]) - numval(FL(Stack)[FL(SP)-1]);
+ if(bothfixnums(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1])){
+ s = numval(FL(stack)[FL(sp)-2]) - numval(FL(stack)[FL(sp)-1]);
v = fits_fixnum(s) ? fixnum(s) : mk_xlong(s);
}else{
- FL(Stack)[ipd] = (uintptr_t)ip;
- FL(Stack)[FL(SP)-1] = fl_neg(FL(Stack)[FL(SP)-1]);
- v = fl_add_any(&FL(Stack)[FL(SP)-2], 2, 0);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[FL(sp)-1] = fl_neg(FL(stack)[FL(sp)-1]);
+ v = fl_add_any(&FL(stack)[FL(sp)-2], 2, 0);
}
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_MUL)
n = *ip++;
apply_mul:
- FL(Stack)[ipd] = (uintptr_t)ip;
- v = fl_mul_any(&FL(Stack)[FL(SP)-n], n);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = fl_mul_any(&FL(stack)[FL(sp)-n], n);
POPN(n);
PUSH(v);
NEXT_OP;
@@ -1457,18 +1457,18 @@
OP(OP_DIV)
n = *ip++;
apply_div:
- FL(Stack)[ipd] = (uintptr_t)ip;
- i = FL(SP)-n;
+ FL(stack)[ipd] = (uintptr_t)ip;
+ i = FL(sp)-n;
if(n == 1){
- FL(Stack)[FL(SP)-1] = fl_div2(fixnum(1), FL(Stack)[i]);
+ FL(stack)[FL(sp)-1] = fl_div2(fixnum(1), FL(stack)[i]);
}else{
if(n > 2){
- PUSH(FL(Stack)[i]);
- FL(Stack)[i] = fixnum(1);
- FL(Stack)[i+1] = fl_mul_any(&FL(Stack)[i], n);
- FL(Stack)[i] = POP();
+ PUSH(FL(stack)[i]);
+ FL(stack)[i] = fixnum(1);
+ FL(stack)[i+1] = fl_mul_any(&FL(stack)[i], n);
+ FL(stack)[i] = POP();
}
- v = fl_div2(FL(Stack)[i], FL(Stack)[i+1]);
+ v = fl_div2(FL(stack)[i], FL(stack)[i+1]);
POPN(n);
PUSH(v);
}
@@ -1475,9 +1475,9 @@
NEXT_OP;
OP(OP_IDIV)
- FL(Stack)[ipd] = (uintptr_t)ip;
- v = FL(Stack)[FL(SP)-2];
- e = FL(Stack)[FL(SP)-1];
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = FL(stack)[FL(sp)-2];
+ e = FL(stack)[FL(sp)-1];
if(bothfixnums(v, e)){
if(e == 0)
DivideByZeroError();
@@ -1486,23 +1486,23 @@
v = fl_idiv2(v, e);
}
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_NUMEQ)
- v = FL(Stack)[FL(SP)-2]; e = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-2]; e = FL(stack)[FL(sp)-1];
if(bothfixnums(v, e))
v = v == e ? FL(t) : FL(f);
else{
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
v = numeric_compare(v, e, 1, 0, 1) == 0 ? FL(t) : FL(f);
}
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_COMPARE)
- FL(Stack)[FL(SP)-2] = compare_(FL(Stack)[FL(SP)-2], FL(Stack)[FL(SP)-1], 0);
+ FL(stack)[FL(sp)-2] = compare_(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], 0);
POPN(1);
NEXT_OP;
@@ -1513,7 +1513,7 @@
n = GET_INT32(ip);
ip += 4;
}
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
argcount(nargs, n);
NEXT_OP;
@@ -1522,7 +1522,7 @@
apply_vector:
v = alloc_vector(n, 0);
if(n){
- memmove(&vector_elt(v, 0), &FL(Stack)[FL(SP)-n], n*sizeof(value_t));
+ memmove(&vector_elt(v, 0), &FL(stack)[FL(sp)-n], n*sizeof(value_t));
POPN(n);
}
PUSH(v);
@@ -1529,37 +1529,37 @@
NEXT_OP;
OP(OP_ASET)
- e = FL(Stack)[FL(SP)-3];
- FL(Stack)[ipd] = (uintptr_t)ip;
+ e = FL(stack)[FL(sp)-3];
+ FL(stack)[ipd] = (uintptr_t)ip;
if(isvector(e)){
- i = tofixnum(FL(Stack)[FL(SP)-2]);
+ i = tofixnum(FL(stack)[FL(sp)-2]);
if(__unlikely(i >= vector_size(e)))
- bounds_error(v, FL(Stack)[FL(SP)-1]);
- vector_elt(e, i) = (v = FL(Stack)[FL(SP)-1]);
+ bounds_error(v, FL(stack)[FL(sp)-1]);
+ vector_elt(e, i) = (v = FL(stack)[FL(sp)-1]);
}else if(__likely(isarray(e))){
- v = cvalue_array_aset(&FL(Stack)[FL(SP)-3]);
+ v = cvalue_array_aset(&FL(stack)[FL(sp)-3]);
}else{
type_error("sequence", e);
}
POPN(2);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_FOR)
- FL(Stack)[ipd] = (uintptr_t)ip;
- s = tofixnum(FL(Stack)[FL(SP)-3]);
- hi = tofixnum(FL(Stack)[FL(SP)-2]);
+ FL(stack)[ipd] = (uintptr_t)ip;
+ s = tofixnum(FL(stack)[FL(sp)-3]);
+ hi = tofixnum(FL(stack)[FL(sp)-2]);
v = FL(unspecified);
- FL(SP) += 2;
- n = FL(SP);
+ FL(sp) += 2;
+ n = FL(sp);
for(; s <= hi; s++){
- FL(Stack)[FL(SP)-2] = FL(Stack)[FL(SP)-3];
- FL(Stack)[FL(SP)-1] = fixnum(s);
+ FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-3];
+ FL(stack)[FL(sp)-1] = fixnum(s);
v = apply_cl(1);
- FL(SP) = n;
+ FL(sp) = n;
}
POPN(4);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_LOADNIL)
@@ -1572,7 +1572,7 @@
NEXT_OP;
OP(OP_LOADVL)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
v = vector_elt(v, GET_INT32(ip));
ip += 4;
PUSH(v);
@@ -1579,12 +1579,12 @@
NEXT_OP;
OP(OP_SETGL)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
v = vector_elt(v, GET_INT32(ip));
ip += 4;
if(0){
OP(OP_SETG)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
assert(*ip < vector_size(v));
v = vector_elt(v, *ip);
ip++;
@@ -1591,7 +1591,7 @@
}
assert(issymbol(v));
sym = (symbol_t*)ptr(v);
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
if(!isconstant(sym))
sym->binding = v;
NEXT_OP;
@@ -1600,30 +1600,30 @@
assert(nargs > 0);
i = GET_INT32(ip);
ip += 4;
- v = captured ? vector_elt(FL(Stack)[bp], i) : FL(Stack)[bp+i];
+ v = captured ? vector_elt(FL(stack)[bp], i) : FL(stack)[bp+i];
PUSH(v);
NEXT_OP;
OP(OP_SETAL)
assert(nargs > 0);
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
i = GET_INT32(ip);
ip += 4;
if(captured)
- vector_elt(FL(Stack)[bp], i) = v;
+ vector_elt(FL(stack)[bp], i) = v;
else
- FL(Stack)[bp+i] = v;
+ FL(stack)[bp+i] = v;
NEXT_OP;
OP(OP_SETC)
s = *ip++;
i = *ip++;
- v = FL(Stack)[bp+nargs];
+ v = FL(stack)[bp+nargs];
while(s--)
v = vector_elt(v, vector_size(v)-1);
assert(isvector(v));
assert(i < vector_size(v));
- vector_elt(v, i) = FL(Stack)[FL(SP)-1];
+ vector_elt(v, i) = FL(stack)[FL(sp)-1];
NEXT_OP;
OP(OP_LOADCL)
@@ -1631,7 +1631,7 @@
ip += 4;
i = GET_INT32(ip);
ip += 4;
- v = FL(Stack)[bp+nargs];
+ v = FL(stack)[bp+nargs];
while(s--)
v = vector_elt(v, vector_size(v)-1);
PUSH(vector_elt(v, i));
@@ -1642,11 +1642,11 @@
ip += 4;
i = GET_INT32(ip);
ip += 4;
- v = FL(Stack)[bp+nargs];
+ v = FL(stack)[bp+nargs];
while(s--)
v = vector_elt(v, vector_size(v)-1);
assert(i < vector_size(v));
- vector_elt(v, i) = FL(Stack)[FL(SP)-1];
+ vector_elt(v, i) = FL(stack)[FL(sp)-1];
NEXT_OP;
OP(OP_VARGC)
@@ -1658,37 +1658,37 @@
}
s = (fixnum_t)nargs - (fixnum_t)i;
if(s > 0){
- v = list(&FL(Stack)[bp+i], s, 0);
- FL(Stack)[bp+i] = v;
+ v = list(&FL(stack)[bp+i], s, 0);
+ FL(stack)[bp+i] = v;
if(s > 1){
- FL(Stack)[bp+i+1] = FL(Stack)[bp+nargs+0];
- FL(Stack)[bp+i+2] = FL(Stack)[bp+nargs+1];
- FL(Stack)[bp+i+3] = i+1;
- //FL(Stack)[bp+i+4] = 0;
- FL(Stack)[bp+i+5] = 0;
- FL(SP) = bp+i+6;
- FL(curr_frame) = FL(SP);
+ FL(stack)[bp+i+1] = FL(stack)[bp+nargs+0];
+ FL(stack)[bp+i+2] = FL(stack)[bp+nargs+1];
+ FL(stack)[bp+i+3] = i+1;
+ //FL(stack)[bp+i+4] = 0;
+ FL(stack)[bp+i+5] = 0;
+ FL(sp) = bp+i+6;
+ FL(curr_frame) = FL(sp);
}
}else if(__unlikely(s < 0)){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
lerrorf(FL(ArgError), "too few arguments");
}else{
PUSH(0);
- FL(Stack)[FL(SP)-3] = i+1;
- FL(Stack)[FL(SP)-4] = FL(Stack)[FL(SP)-5];
- FL(Stack)[FL(SP)-5] = FL(Stack)[FL(SP)-6];
- FL(Stack)[FL(SP)-6] = FL(Nil);
- FL(curr_frame) = FL(SP);
+ FL(stack)[FL(sp)-3] = i+1;
+ FL(stack)[FL(sp)-4] = FL(stack)[FL(sp)-5];
+ FL(stack)[FL(sp)-5] = FL(stack)[FL(sp)-6];
+ FL(stack)[FL(sp)-6] = FL(Nil);
+ FL(curr_frame) = FL(sp);
}
- ipd = FL(SP)-2;
+ ipd = FL(sp)-2;
nargs = i+1;
NEXT_OP;
OP(OP_TRYCATCH)
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
v = do_trycatch();
POPN(1);
- FL(Stack)[FL(SP)-1] = v;
+ FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_OPTARGS)
@@ -1697,12 +1697,12 @@
n = GET_INT32(ip);
ip += 4;
if(__unlikely(nargs < i)){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
lerrorf(FL(ArgError), "too few arguments");
}
if((int32_t)n > 0){
if(__unlikely(nargs > n)){
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
lerrorf(FL(ArgError), "too many arguments");
}
}else
@@ -1709,16 +1709,16 @@
n = -n;
if(__likely(n > nargs)){
n -= nargs;
- FL(SP) += n;
- FL(Stack)[FL(SP)-1] = FL(Stack)[FL(SP)-n-1];
- FL(Stack)[FL(SP)-2] = FL(Stack)[FL(SP)-n-2];
- FL(Stack)[FL(SP)-3] = nargs+n;
- FL(Stack)[FL(SP)-4] = FL(Stack)[FL(SP)-n-4];
- FL(Stack)[FL(SP)-5] = FL(Stack)[FL(SP)-n-5];
- FL(curr_frame) = FL(SP);
- ipd = FL(SP)-2;
+ FL(sp) += n;
+ FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-n-1];
+ FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-n-2];
+ FL(stack)[FL(sp)-3] = nargs+n;
+ FL(stack)[FL(sp)-4] = FL(stack)[FL(sp)-n-4];
+ FL(stack)[FL(sp)-5] = FL(stack)[FL(sp)-n-5];
+ FL(curr_frame) = FL(sp);
+ ipd = FL(sp)-2;
for(i = 0; i < n; i++)
- FL(Stack)[bp+nargs+i] = UNBOUND;
+ FL(stack)[bp+nargs+i] = UNBOUND;
nargs += n;
}
NEXT_OP;
@@ -1726,12 +1726,12 @@
OP(OP_BRBOUND)
i = GET_INT32(ip);
ip += 4;
- v = captured ? vector_elt(FL(Stack)[bp], i) : FL(Stack)[bp+i];
+ v = captured ? vector_elt(FL(stack)[bp], i) : FL(stack)[bp+i];
PUSH(v != UNBOUND ? FL(t) : FL(f));
NEXT_OP;
OP(OP_KEYARGS)
- v = fn_vals(FL(Stack)[bp-1]);
+ v = fn_vals(FL(stack)[bp-1]);
v = vector_elt(v, 0);
i = GET_INT32(ip);
ip += 4;
@@ -1739,7 +1739,7 @@
ip += 4;
s = GET_INT32(ip);
ip += 4;
- FL(Stack)[ipd] = (uintptr_t)ip;
+ FL(stack)[ipd] = (uintptr_t)ip;
nargs = process_keys(v, i, n, labs(s)-(i+n), bp, nargs, s<0);
NEXT_OP;
}
@@ -1784,21 +1784,21 @@
fl_gc_handle(&lst);
while(top > 0){
- const uint8_t *ip1 = (void*)FL(Stack)[top-2];
- uint32_t sz = FL(Stack)[top-3]+1;
+ const uint8_t *ip1 = (void*)FL(stack)[top-2];
+ uint32_t sz = FL(stack)[top-3]+1;
uint32_t bp = top-5-sz;
- value_t func = FL(Stack)[bp];
+ value_t func = FL(stack)[bp];
const uint8_t *ip0 = cv_data((cvalue_t*)ptr(fn_bcode(func)));
value_t ip = ip1 - ip0 - 1; /* -1: ip1 is *after* the one that was being executed */
value_t v = alloc_vector(sz+1, 0);
vector_elt(v, 0) = fixnum(ip);
vector_elt(v, 1) = func;
- if(FL(Stack)[top-1] /*captured*/){
+ if(FL(stack)[top-1] /*captured*/){
memmove(&vector_elt(v, 2),
- &vector_elt(FL(Stack)[bp+1], 0), (sz-1)*sizeof(value_t));
+ &vector_elt(FL(stack)[bp+1], 0), (sz-1)*sizeof(value_t));
}else{
for(uint32_t i = 1; i < sz; i++){
- value_t si = FL(Stack)[bp+i];
+ 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;
@@ -1805,7 +1805,7 @@
}
}
lst = fl_cons(v, lst);
- top = FL(Stack)[top-4];
+ top = FL(stack)[top-4];
}
fl_free_gc_handles(1);
return lst;
@@ -1965,24 +1965,24 @@
if(!iscons(args[1]))
return FL(Nil);
value_t first, last, v;
- int64_t argSP = args-FL(Stack);
- assert(argSP >= 0 && argSP < FL(N_STACK));
+ int64_t argSP = args-FL(stack);
+ assert(argSP >= 0 && argSP < FL(nstack));
if(nargs == 2){
- if(FL(SP)+3 > FL(N_STACK))
+ if(FL(sp)+3 > FL(nstack))
grow_stack();
- PUSH(FL(Stack)[argSP]);
- PUSH(car_(FL(Stack)[argSP+1]));
+ PUSH(FL(stack)[argSP]);
+ PUSH(car_(FL(stack)[argSP+1]));
v = _applyn(1);
PUSH(v);
v = mk_cons();
car_(v) = POP(); cdr_(v) = FL(Nil);
last = first = v;
- FL(Stack)[argSP+1] = cdr_(FL(Stack)[argSP+1]);
+ FL(stack)[argSP+1] = cdr_(FL(stack)[argSP+1]);
fl_gc_handle(&first);
fl_gc_handle(&last);
- while(iscons(FL(Stack)[argSP+1])){
- FL(Stack)[FL(SP)-2] = FL(Stack)[argSP];
- FL(Stack)[FL(SP)-1] = car_(FL(Stack)[argSP+1]);
+ while(iscons(FL(stack)[argSP+1])){
+ FL(stack)[FL(sp)-2] = FL(stack)[argSP];
+ FL(stack)[FL(sp)-1] = car_(FL(stack)[argSP+1]);
v = _applyn(1);
PUSH(v);
v = mk_cons();
@@ -1989,18 +1989,18 @@
car_(v) = POP(); cdr_(v) = FL(Nil);
cdr_(last) = v;
last = v;
- FL(Stack)[argSP+1] = cdr_(FL(Stack)[argSP+1]);
+ FL(stack)[argSP+1] = cdr_(FL(stack)[argSP+1]);
}
POPN(2);
fl_free_gc_handles(2);
}else{
int i;
- while(FL(SP)+nargs+1 > FL(N_STACK))
+ while(FL(sp)+nargs+1 > FL(nstack))
grow_stack();
- PUSH(FL(Stack)[argSP]);
+ PUSH(FL(stack)[argSP]);
for(i = 1; i < nargs; i++){
- PUSH(car(FL(Stack)[argSP+i]));
- FL(Stack)[argSP+i] = cdr_(FL(Stack)[argSP+i]);
+ PUSH(car(FL(stack)[argSP+i]));
+ FL(stack)[argSP+i] = cdr_(FL(stack)[argSP+i]);
}
v = _applyn(nargs-1);
POPN(nargs);
@@ -2010,11 +2010,11 @@
last = first = v;
fl_gc_handle(&first);
fl_gc_handle(&last);
- while(iscons(FL(Stack)[argSP+1])){
- PUSH(FL(Stack)[argSP]);
+ while(iscons(FL(stack)[argSP+1])){
+ PUSH(FL(stack)[argSP]);
for(i = 1; i < nargs; i++){
- PUSH(car(FL(Stack)[argSP+i]));
- FL(Stack)[argSP+i] = cdr_(FL(Stack)[argSP+i]);
+ PUSH(car(FL(stack)[argSP+i]));
+ FL(stack)[argSP+i] = cdr_(FL(stack)[argSP+i]);
}
v = _applyn(nargs-1);
POPN(nargs);
@@ -2052,7 +2052,7 @@
int i;
memset(&fl, 0, sizeof(fl));
- FL(SCR_WIDTH) = 80;
+ FL(scr_width) = 80;
FL(heapsize) = initial_heapsize;
@@ -2063,8 +2063,8 @@
FL(consflags) = bitvector_new(FL(heapsize)/sizeof(cons_t), 1);
htable_new(&FL(printconses), 32);
comparehash_init();
- FL(N_STACK) = 262144;
- FL(Stack) = LLT_ALLOC(FL(N_STACK)*sizeof(value_t));
+ FL(nstack) = 262144;
+ FL(stack) = LLT_ALLOC(FL(nstack)*sizeof(value_t));
FL(Nil) = builtin(OP_THE_EMPTY_LIST);
FL(t) = builtin(OP_BOOL_CONST_T);
@@ -2122,7 +2122,7 @@
FL(builtins_table_sym) = symbol("*builtins*");
set(FL(printprettysym) = symbol("*print-pretty*"), FL(t));
set(FL(printreadablysym) = symbol("*print-readably*"), FL(t));
- set(FL(printwidthsym) = symbol("*print-width*"), fixnum(FL(SCR_WIDTH)));
+ set(FL(printwidthsym) = symbol("*print-width*"), fixnum(FL(scr_width)));
set(FL(printlengthsym) = symbol("*print-length*"), FL(f));
set(FL(printlevelsym) = symbol("*print-level*"), FL(f));
FL(lasterror) = FL(Nil);
@@ -2181,17 +2181,17 @@
symbol_t *sym;
PUSH(sys_image_iostream);
- saveSP = FL(SP);
+ saveSP = FL(sp);
FL_TRY{
while(1){
- e = fl_read_sexpr(FL(Stack)[FL(SP)-1]);
- if(ios_eof(value2c(ios_t*, FL(Stack)[FL(SP)-1])))
+ e = fl_read_sexpr(FL(stack)[FL(sp)-1]);
+ if(ios_eof(value2c(ios_t*, FL(stack)[FL(sp)-1])))
break;
if(isfunction(e)){
// stage 0 format: series of thunks
PUSH(e);
(void)_applyn(0);
- FL(SP) = saveSP;
+ FL(sp) = saveSP;
}else{
// stage 1 format: list alternating symbol/value
while(iscons(e)){
@@ -2211,7 +2211,7 @@
ios_putc('\n', ios_stderr);
return 1;
}
- ios_close(value2c(ios_t*, FL(Stack)[FL(SP)-1]));
+ ios_close(value2c(ios_t*, FL(stack)[FL(sp)-1]));
POPN(1);
return 0;
}
--- a/flisp.h
+++ b/flisp.h
@@ -154,13 +154,13 @@
#define PUSH(v) \
do{ \
- FL(Stack)[FL(SP)++] = (v); \
+ FL(stack)[FL(sp)++] = (v); \
}while(0)
#define POPN(n) \
do{ \
- FL(SP) -= (n); \
+ FL(sp) -= (n); \
}while(0)
-#define POP() (FL(Stack)[--FL(SP)])
+#define POP() (FL(stack)[--FL(sp)])
int isbuiltin(value_t x);
void fl_init(size_t initial_heapsize);
@@ -326,14 +326,15 @@
typedef struct Fl Fl;
struct Fl {
- value_t *Stack;
- uint32_t SP;
- uint32_t N_STACK;
+ value_t *stack;
+ uint32_t sp;
uint32_t curr_frame;
- value_t *GCHandleStack[N_GC_HANDLES];
- uint32_t N_GCHND;
- symbol_t *symtab;
+ value_t Nil, t, f;
+ value_t *gchandles[N_GC_HANDLES];
+ uint32_t ngchandles;
+ uint32_t nstack;
+
uint8_t *fromspace;
uint8_t *tospace;
uint8_t *curheap;
@@ -342,6 +343,7 @@
uint32_t *consflags;
fl_readstate_t *readstate;
+ symbol_t *symtab;
// saved execution state for an unwind target
fl_exception_context_t *exctx;
@@ -348,7 +350,7 @@
uint32_t throwing_frame; // active frame when exception was thrown
value_t lasterror;
- value_t Nil, t, f, eof, quote;
+ value_t eof, quote;
value_t lambda, trycatch;
value_t backquote, comma, commaat, commadot, function;
@@ -396,11 +398,11 @@
fltype_t *builtintype;
size_t malloc_pressure;
- cvalue_t **Finalizers;
+ cvalue_t **finalizers;
size_t nfinalizers;
size_t maxfinalizers;
- uint32_t _gensym_ctr;
+ uint32_t gensym_ctr;
// two static buffers for gensym printing so there can be two
// gensym names available at a time, mostly for compare()
char gsname[2][16];
@@ -418,9 +420,9 @@
int print_princ;
fixnum_t print_length;
fixnum_t print_level;
- fixnum_t P_LEVEL;
- int SCR_WIDTH;
- int HPOS, VPOS;
+ fixnum_t p_level;
+ int scr_width;
+ int hpos, vpos;
};
extern Fl fl;
--- a/print.c
+++ b/print.c
@@ -12,9 +12,9 @@
{
ios_putc(c, f);
if(c == '\n')
- FL(HPOS) = 0;
+ FL(hpos) = 0;
else
- FL(HPOS)++;
+ FL(hpos)++;
}
static void
@@ -21,7 +21,7 @@
outs(char *s, ios_t *f)
{
ios_puts(s, f);
- FL(HPOS) += u8_strwidth(s);
+ FL(hpos) += u8_strwidth(s);
}
static void
@@ -28,7 +28,7 @@
outsn(char *s, ios_t *f, size_t n)
{
ios_write(f, s, n);
- FL(HPOS) += u8_strwidth(s);
+ FL(hpos) += u8_strwidth(s);
}
static int
@@ -35,12 +35,12 @@
outindent(int n, ios_t *f)
{
// move back to left margin if we get too indented
- if(n > FL(SCR_WIDTH)-12)
+ if(n > FL(scr_width)-12)
n = 2;
int n0 = n;
ios_putc('\n', f);
- FL(VPOS)++;
- FL(HPOS) = n;
+ FL(vpos)++;
+ FL(hpos) = n;
while(n >= 8){
ios_putc('\t', f);
n -= 8;
@@ -294,9 +294,9 @@
fl_print_child(f, car_(cdr_(v)));
return;
}
- int startpos = FL(HPOS);
+ int startpos = FL(hpos);
outc('(', f);
- int newindent = FL(HPOS), blk = blockindent(v);
+ int newindent = FL(hpos), blk = blockindent(v);
int lastv, n = 0, si, ind, est, always = 0, nextsmall, thistiny;
if(!blk)
always = indentevery(v);
@@ -310,7 +310,7 @@
outsn("...)", f, 4);
break;
}
- lastv = FL(VPOS);
+ lastv = FL(vpos);
unmark_cons(v);
fl_print_child(f, car_(v));
if(!iscons(cd) || ptrhash_has(&FL(printconses), (void*)cd)){
@@ -330,12 +330,12 @@
est = lengthestimate(car_(cd));
nextsmall = smallp(car_(cd));
thistiny = tinyp(car_(v));
- ind = (((FL(VPOS) > lastv) ||
- (FL(HPOS)>FL(SCR_WIDTH)/2 && !nextsmall && !thistiny && n>0)) ||
+ ind = (((FL(vpos) > lastv) ||
+ (FL(hpos)>FL(scr_width)/2 && !nextsmall && !thistiny && n>0)) ||
- (FL(HPOS) > FL(SCR_WIDTH)-4) ||
+ (FL(hpos) > FL(scr_width)-4) ||
- (est != -1 && (FL(HPOS)+est > FL(SCR_WIDTH)-2)) ||
+ (est != -1 && (FL(hpos)+est > FL(scr_width)-2)) ||
((head == FL(lambda)) && !nextsmall) ||
@@ -361,7 +361,7 @@
if(si != -1)
newindent = startpos + si;
else if(!blk)
- newindent = FL(HPOS);
+ newindent = FL(hpos);
}
}
n++;
@@ -377,10 +377,10 @@
value_t label;
if((label = (value_t)ptrhash_get(&FL(printconses), (void*)v)) != (value_t)HT_NOTFOUND){
if(!ismarked(v)){
- FL(HPOS) += ios_printf(f, "#%"PRIdPTR"#", numval(label));
+ FL(hpos) += ios_printf(f, "#%"PRIdPTR"#", numval(label));
return 1;
}
- FL(HPOS) += ios_printf(f, "#%"PRIdPTR"=", numval(label));
+ FL(hpos) += ios_printf(f, "#%"PRIdPTR"=", numval(label));
}
if(ismanaged(v))
unmark_cons(v);
@@ -391,15 +391,15 @@
fl_print_child(ios_t *f, value_t v)
{
char *name;
- if(FL(print_level) >= 0 && FL(P_LEVEL) >= FL(print_level) && (iscons(v) || isvector(v) || isclosure(v))){
+ if(FL(print_level) >= 0 && FL(p_level) >= FL(print_level) && (iscons(v) || isvector(v) || isclosure(v))){
outc('#', f);
return;
}
- FL(P_LEVEL)++;
+ FL(p_level)++;
switch(tag(v)){
case TAG_NUM: case TAG_NUM1:
- FL(HPOS) += ios_printf(f, "%"PRId64, (int64_t)numval(v));
+ FL(hpos) += ios_printf(f, "%"PRId64, (int64_t)numval(v));
break;
case TAG_SYM:
name = symbol_name(v);
@@ -467,7 +467,7 @@
break;
if(isvector(v)){
outs("#(", f);
- int newindent = FL(HPOS), est;
+ int newindent = FL(hpos), est;
int i, sz = vector_size(v);
for(i = 0; i < sz; i++){
if(FL(print_length) >= 0 && i >= FL(print_length) && i < sz-1){
@@ -480,9 +480,9 @@
outc(' ', f);
else{
est = lengthestimate(vector_elt(v, i+1));
- if(FL(HPOS) > FL(SCR_WIDTH)-4 ||
- (est != -1 && (FL(HPOS)+est > FL(SCR_WIDTH)-2)) ||
- (FL(HPOS) > FL(SCR_WIDTH)/2 && !smallp(vector_elt(v, i+1)) && !tinyp(vector_elt(v, i))))
+ if(FL(hpos) > FL(scr_width)-4 ||
+ (est != -1 && (FL(hpos)+est > FL(scr_width)-2)) ||
+ (FL(hpos) > FL(scr_width)/2 && !smallp(vector_elt(v, i+1)) && !tinyp(vector_elt(v, i))))
newindent = outindent(newindent, f);
else
outc(' ', f);
@@ -498,7 +498,7 @@
print_pair(f, v);
break;
}
- FL(P_LEVEL)--;
+ FL(p_level)--;
}
static void
@@ -627,9 +627,9 @@
if(FL(print_princ))
outc(ch, f);
else if(weak)
- FL(HPOS) += ios_printf(f, "0x%hhx", ch);
+ FL(hpos) += ios_printf(f, "0x%hhx", ch);
else
- FL(HPOS) += ios_printf(f, "#byte(0x%hhx)", ch);
+ FL(hpos) += ios_printf(f, "#byte(0x%hhx)", ch);
}else if(type == FL(runesym)){
Rune r = *(Rune*)data;
char seq[UTFmax+1];
@@ -655,7 +655,7 @@
if(u8_iswprint(r))
outs(seq, f);
else
- FL(HPOS) += ios_printf(f, "x%04x", r);
+ FL(hpos) += ios_printf(f, "x%04x", r);
break;
}
}
@@ -677,7 +677,7 @@
else
rep = signbit(d) ? "-inf.0" : "+inf.0";
if(type == FL(floatsym) && !FL(print_princ) && !weak)
- FL(HPOS) += ios_printf(f, "#%s(%s)", symbol_name(type), rep);
+ FL(hpos) += ios_printf(f, "#%s(%s)", symbol_name(type), rep);
else
outs(rep, f);
}else if(d == 0){
@@ -703,16 +703,16 @@
#endif
uint64_t ui64 = *(uint64_t*)data;
if(weak || FL(print_princ))
- FL(HPOS) += ios_printf(f, "%"PRIu64, ui64);
+ FL(hpos) += ios_printf(f, "%"PRIu64, ui64);
else
- FL(HPOS) += ios_printf(f, "#%s(%"PRIu64")", symbol_name(type), ui64);
+ FL(hpos) += ios_printf(f, "#%s(%"PRIu64")", symbol_name(type), ui64);
}else if(type == FL(bignumsym)){
mpint *i = *(mpint**)data;
char *s = mptoa(i, 10, nil, 0);
if(weak || FL(print_princ))
- FL(HPOS) += ios_printf(f, "%s", s);
+ FL(hpos) += ios_printf(f, "%s", s);
else
- FL(HPOS) += ios_printf(f, "#%s(%s)", symbol_name(type), s);
+ FL(hpos) += ios_printf(f, "#%s(%s)", symbol_name(type), s);
LLT_FREE(s);
}else if(issymbol(type)){
// handle other integer prims. we know it's smaller than uint64
@@ -721,11 +721,11 @@
if(valid_numtype(nt)){
int64_t i64 = conv_to_int64(data, nt);
if(weak || FL(print_princ))
- FL(HPOS) += ios_printf(f, "%"PRId64, i64);
+ FL(hpos) += ios_printf(f, "%"PRId64, i64);
else
- FL(HPOS) += ios_printf(f, "#%s(%"PRId64")", symbol_name(type), i64);
+ FL(hpos) += ios_printf(f, "#%s(%"PRId64")", symbol_name(type), i64);
}else{
- FL(HPOS) += ios_printf(f, "#<%s>", symbol_name(type));
+ FL(hpos) += ios_printf(f, "#<%s>", symbol_name(type));
}
}else if(iscons(type)){
if(car_(type) == FL(arraysym)){
@@ -747,9 +747,9 @@
/*
char *nl = llt_memrchr(data, '\n', len);
if(nl)
- FL(HPOS) = u8_strwidth(nl+1);
+ FL(hpos) = u8_strwidth(nl+1);
else
- FL(HPOS) += u8_strwidth(data);
+ FL(hpos) += u8_strwidth(data);
*/
}else{
outc('"', f);
@@ -822,7 +822,7 @@
void *fptr = *(void**)data;
label = (value_t)ptrhash_get(&FL(reverse_dlsym_lookup_table), cv);
if(label == (value_t)HT_NOTFOUND){
- FL(HPOS) += ios_printf(f, "#<builtin @%p>", fptr);
+ FL(hpos) += ios_printf(f, "#<builtin @%p>", fptr);
}else{
if(FL(print_princ)){
outs(symbol_name(label), f);
@@ -847,7 +847,7 @@
value_t pw = symbol_value(FL(printwidthsym));
if(!isfixnum(pw))
return;
- FL(SCR_WIDTH) = numval(pw);
+ FL(scr_width) = numval(pw);
}
void
@@ -861,12 +861,12 @@
FL(print_length) = isfixnum(pl) ? numval(pl) : -1;
pl = symbol_value(FL(printlevelsym));
FL(print_level) = isfixnum(pl) ? numval(pl) : -1;
- FL(P_LEVEL) = 0;
+ FL(p_level) = 0;
FL(printlabel) = 0;
if(!FL(print_princ))
print_traverse(v);
- FL(HPOS) = FL(VPOS) = 0;
+ FL(hpos) = FL(vpos) = 0;
fl_print_child(f, v);
--- a/read.c
+++ b/read.c
@@ -441,11 +441,11 @@
PUSH(v);
assert(s+d > s);
value_t newv = alloc_vector(s+d, 1);
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
for(i = 0; i < s; i++)
vector_elt(newv, i) = vector_elt(v, i);
// use gc to rewrite references from the old vector to the new
- FL(Stack)[FL(SP)-1] = newv;
+ FL(stack)[FL(sp)-1] = newv;
if(s > 0){
((size_t*)ptr(v))[0] |= 0x1;
vector_elt(v, 0) = newv;
@@ -466,12 +466,12 @@
if(ios_eof(RS))
lerrorf(FL(ParseError), "unexpected end of input");
if(i >= vector_size(v)){
- v = FL(Stack)[FL(SP)-1] = vector_grow(v);
+ v = FL(stack)[FL(sp)-1] = vector_grow(v);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
}
elt = do_read_sexpr(UNBOUND);
- v = FL(Stack)[FL(SP)-1];
+ v = FL(stack)[FL(sp)-1];
assert(i < vector_size(v));
vector_elt(v, i) = elt;
i++;
@@ -578,7 +578,7 @@
uint32_t t;
PUSH(FL(Nil));
- pc = &FL(Stack)[FL(SP)-1]; // to keep track of current cons cell
+ pc = &FL(stack)[FL(sp)-1]; // to keep track of current cons cell
t = peek();
while(t != closer){
if(ios_eof(RS))
@@ -660,7 +660,7 @@
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
v = do_read_sexpr(UNBOUND);
- car_(cdr_(FL(Stack)[FL(SP)-1])) = v;
+ car_(cdr_(FL(stack)[FL(sp)-1])) = v;
return POP();
case TOK_SHARPQUOTE:
// femtoLisp doesn't need symbol-function, so #' does nothing
@@ -667,15 +667,15 @@
return do_read_sexpr(label);
case TOK_OPEN:
PUSH(FL(Nil));
- read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSE);
+ read_list(&FL(stack)[FL(sp)-1], label, TOK_CLOSE);
return POP();
case TOK_OPENB:
PUSH(FL(Nil));
- read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSEB);
+ read_list(&FL(stack)[FL(sp)-1], label, TOK_CLOSEB);
return POP();
case TOK_OPENC:
PUSH(FL(Nil));
- read_list(&FL(Stack)[FL(SP)-1], label, TOK_CLOSEC);
+ read_list(&FL(stack)[FL(sp)-1], label, TOK_CLOSEC);
return POP();
case TOK_SHARPSYM:
sym = tokval;
@@ -690,10 +690,10 @@
lerrorf(FL(ParseError), "expected argument list for %s", symbol_name(tokval));
}
PUSH(FL(Nil));
- read_list(&FL(Stack)[FL(SP)-1], UNBOUND, TOK_CLOSE);
+ read_list(&FL(stack)[FL(sp)-1], UNBOUND, TOK_CLOSE);
if(sym == FL(vu8sym)){
sym = FL(arraysym);
- FL(Stack)[FL(SP)-1] = fl_cons(FL(uint8sym), FL(Stack)[FL(SP)-1]);
+ FL(stack)[FL(sp)-1] = fl_cons(FL(uint8sym), FL(stack)[FL(sp)-1]);
}else if(sym == FL(fnsym)){
sym = FL(function);
}