From fdcdd865b473cf0b960ea640aa2c8b4b4a3aa764 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 19:23:30 +0300 Subject: [PATCH] Replace function_t with struct --- c/equal.h | 11 ++++++----- c/flisp.c | 6 +++--- c/flisp.h | 4 ++-- c/print.h | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/c/equal.h b/c/equal.h index 969aac0..75cd311 100644 --- a/c/equal.h +++ b/c/equal.h @@ -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; diff --git a/c/flisp.c b/c/flisp.c index 029e4bf..3fa201d 100644 --- a/c/flisp.c +++ b/c/flisp.c @@ -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]; diff --git a/c/flisp.h b/c/flisp.h index be5977f..b829f7a 100644 --- a/c/flisp.h +++ b/c/flisp.h @@ -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 diff --git a/c/print.h b/c/print.h index a4e10e4..ce6af9e 100644 --- a/c/print.h +++ b/c/print.h @@ -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);