Replace function_t with struct

This commit is contained in:
Lassi Kortela 2019-08-09 19:23:30 +03:00
parent ece07d2e1a
commit fdcdd865b4
4 changed files with 13 additions and 12 deletions

View File

@ -108,8 +108,8 @@ compare_top:
case TAG_FUNCTION:
if (tagb == TAG_FUNCTION) {
if (uintval(a) > N_BUILTINS && uintval(b) > N_BUILTINS) {
function_t *fa = (function_t *)ptr(a);
function_t *fb = (function_t *)ptr(b);
struct function *fa = (struct function *)ptr(a);
struct function *fb = (struct function *)ptr(b);
d = bounded_compare(fa->bcode, fb->bcode, bound - 1, eq);
if (d == NIL || numval(d) != 0)
return d;
@ -239,8 +239,8 @@ cyc_compare_top:
} else if (isvector(a) && isvector(b)) {
return cyc_vector_compare(a, b, table, eq);
} else if (isclosure(a) && isclosure(b)) {
function_t *fa = (function_t *)ptr(a);
function_t *fb = (function_t *)ptr(b);
struct function *fa = (struct function *)ptr(a);
struct function *fb = (struct function *)ptr(b);
d = bounded_compare(fa->bcode, fb->bcode, 1, eq);
if (numval(d) != 0)
return d;
@ -322,7 +322,8 @@ static uptrint_t bounded_hash(value_t a, int bound, int *oob)
return doublehash(u.i64);
case TAG_FUNCTION:
if (uintval(a) > N_BUILTINS)
return bounded_hash(((function_t *)ptr(a))->bcode, bound, oob);
return bounded_hash(((struct function *)ptr(a))->bcode, bound,
oob);
return inthash(a);
case TAG_SYM:
return ((symbol_t *)ptr(a))->hash;

View File

@ -510,8 +510,8 @@ static value_t relocate(value_t v)
} else if (t == TAG_CVALUE) {
return cvalue_relocate(v);
} else if (t == TAG_FUNCTION) {
function_t *fn = (function_t *)ptr(v);
function_t *nfn = (function_t *)alloc_words(4);
struct function *fn = (struct function *)ptr(v);
struct function *nfn = (struct function *)alloc_words(4);
nfn->bcode = fn->bcode;
nfn->vals = fn->vals;
nc = tagptr(nfn, TAG_FUNCTION);
@ -2251,7 +2251,7 @@ static value_t fl_function(value_t *args, uint32_t nargs)
}
uint32_t ms = compute_maxstack((uint8_t *)data, cv_len(arr), swap);
PUT_INT32(data, ms);
function_t *fn = (function_t *)alloc_words(4);
struct function *fn = (struct function *)alloc_words(4);
value_t fv = tagptr(fn, TAG_FUNCTION);
fn->bcode = args[0];
fn->vals = args[1];

View File

@ -279,12 +279,12 @@ typedef struct {
char _space[1];
} cprim_t;
typedef struct {
struct function {
value_t bcode;
value_t vals;
value_t env;
value_t name;
} function_t;
};
#define CPRIM_NWORDS 2
#define MAX_INL_SIZE 384

View File

@ -80,7 +80,7 @@ void print_traverse(value_t v)
// don't consider shared references to e.g. chars
} else if (isclosure(v)) {
mark_cons(v);
function_t *f = (function_t *)ptr(v);
struct function *f = (struct function *)ptr(v);
print_traverse(f->bcode);
print_traverse(f->vals);
print_traverse(f->env);
@ -395,7 +395,7 @@ void fl_print_child(struct ios *f, value_t v)
if (!print_princ) {
if (print_circle_prefix(f, v))
break;
function_t *fn = (function_t *)ptr(v);
struct function *fn = (struct function *)ptr(v);
outs("#fn(", f);
char *data = cvalue_data(fn->bcode);
size_t i, sz = cvalue_len(fn->bcode);