Replace function_t with struct
This commit is contained in:
parent
ece07d2e1a
commit
fdcdd865b4
11
c/equal.h
11
c/equal.h
|
@ -108,8 +108,8 @@ compare_top:
|
||||||
case TAG_FUNCTION:
|
case TAG_FUNCTION:
|
||||||
if (tagb == TAG_FUNCTION) {
|
if (tagb == TAG_FUNCTION) {
|
||||||
if (uintval(a) > N_BUILTINS && uintval(b) > N_BUILTINS) {
|
if (uintval(a) > N_BUILTINS && uintval(b) > N_BUILTINS) {
|
||||||
function_t *fa = (function_t *)ptr(a);
|
struct function *fa = (struct function *)ptr(a);
|
||||||
function_t *fb = (function_t *)ptr(b);
|
struct function *fb = (struct function *)ptr(b);
|
||||||
d = bounded_compare(fa->bcode, fb->bcode, bound - 1, eq);
|
d = bounded_compare(fa->bcode, fb->bcode, bound - 1, eq);
|
||||||
if (d == NIL || numval(d) != 0)
|
if (d == NIL || numval(d) != 0)
|
||||||
return d;
|
return d;
|
||||||
|
@ -239,8 +239,8 @@ cyc_compare_top:
|
||||||
} else if (isvector(a) && isvector(b)) {
|
} else if (isvector(a) && isvector(b)) {
|
||||||
return cyc_vector_compare(a, b, table, eq);
|
return cyc_vector_compare(a, b, table, eq);
|
||||||
} else if (isclosure(a) && isclosure(b)) {
|
} else if (isclosure(a) && isclosure(b)) {
|
||||||
function_t *fa = (function_t *)ptr(a);
|
struct function *fa = (struct function *)ptr(a);
|
||||||
function_t *fb = (function_t *)ptr(b);
|
struct function *fb = (struct function *)ptr(b);
|
||||||
d = bounded_compare(fa->bcode, fb->bcode, 1, eq);
|
d = bounded_compare(fa->bcode, fb->bcode, 1, eq);
|
||||||
if (numval(d) != 0)
|
if (numval(d) != 0)
|
||||||
return d;
|
return d;
|
||||||
|
@ -322,7 +322,8 @@ static uptrint_t bounded_hash(value_t a, int bound, int *oob)
|
||||||
return doublehash(u.i64);
|
return doublehash(u.i64);
|
||||||
case TAG_FUNCTION:
|
case TAG_FUNCTION:
|
||||||
if (uintval(a) > N_BUILTINS)
|
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);
|
return inthash(a);
|
||||||
case TAG_SYM:
|
case TAG_SYM:
|
||||||
return ((symbol_t *)ptr(a))->hash;
|
return ((symbol_t *)ptr(a))->hash;
|
||||||
|
|
|
@ -510,8 +510,8 @@ static value_t relocate(value_t v)
|
||||||
} else if (t == TAG_CVALUE) {
|
} else if (t == TAG_CVALUE) {
|
||||||
return cvalue_relocate(v);
|
return cvalue_relocate(v);
|
||||||
} else if (t == TAG_FUNCTION) {
|
} else if (t == TAG_FUNCTION) {
|
||||||
function_t *fn = (function_t *)ptr(v);
|
struct function *fn = (struct function *)ptr(v);
|
||||||
function_t *nfn = (function_t *)alloc_words(4);
|
struct function *nfn = (struct function *)alloc_words(4);
|
||||||
nfn->bcode = fn->bcode;
|
nfn->bcode = fn->bcode;
|
||||||
nfn->vals = fn->vals;
|
nfn->vals = fn->vals;
|
||||||
nc = tagptr(nfn, TAG_FUNCTION);
|
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);
|
uint32_t ms = compute_maxstack((uint8_t *)data, cv_len(arr), swap);
|
||||||
PUT_INT32(data, ms);
|
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);
|
value_t fv = tagptr(fn, TAG_FUNCTION);
|
||||||
fn->bcode = args[0];
|
fn->bcode = args[0];
|
||||||
fn->vals = args[1];
|
fn->vals = args[1];
|
||||||
|
|
|
@ -279,12 +279,12 @@ typedef struct {
|
||||||
char _space[1];
|
char _space[1];
|
||||||
} cprim_t;
|
} cprim_t;
|
||||||
|
|
||||||
typedef struct {
|
struct function {
|
||||||
value_t bcode;
|
value_t bcode;
|
||||||
value_t vals;
|
value_t vals;
|
||||||
value_t env;
|
value_t env;
|
||||||
value_t name;
|
value_t name;
|
||||||
} function_t;
|
};
|
||||||
|
|
||||||
#define CPRIM_NWORDS 2
|
#define CPRIM_NWORDS 2
|
||||||
#define MAX_INL_SIZE 384
|
#define MAX_INL_SIZE 384
|
||||||
|
|
|
@ -80,7 +80,7 @@ void print_traverse(value_t v)
|
||||||
// don't consider shared references to e.g. chars
|
// don't consider shared references to e.g. chars
|
||||||
} else if (isclosure(v)) {
|
} else if (isclosure(v)) {
|
||||||
mark_cons(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->bcode);
|
||||||
print_traverse(f->vals);
|
print_traverse(f->vals);
|
||||||
print_traverse(f->env);
|
print_traverse(f->env);
|
||||||
|
@ -395,7 +395,7 @@ void fl_print_child(struct ios *f, value_t v)
|
||||||
if (!print_princ) {
|
if (!print_princ) {
|
||||||
if (print_circle_prefix(f, v))
|
if (print_circle_prefix(f, v))
|
||||||
break;
|
break;
|
||||||
function_t *fn = (function_t *)ptr(v);
|
struct function *fn = (struct function *)ptr(v);
|
||||||
outs("#fn(", f);
|
outs("#fn(", f);
|
||||||
char *data = cvalue_data(fn->bcode);
|
char *data = cvalue_data(fn->bcode);
|
||||||
size_t i, sz = cvalue_len(fn->bcode);
|
size_t i, sz = cvalue_len(fn->bcode);
|
||||||
|
|
Loading…
Reference in New Issue