commit 267e76b5d25fccce277f8a9acf6baa4d1531a3fe
parent 5de9a277e7a620c82a44c3316751e8c10a37e535
Author: Andres Navarro <canavarro82@gmail.com>
Date: Wed, 20 Apr 2011 02:12:38 -0300
Removed all name & si member in all structs. This will be implemented with tables with weak keys.
Diffstat:
11 files changed, 8 insertions(+), 44 deletions(-)
diff --git a/src/kapplicative.c b/src/kapplicative.c
@@ -19,8 +19,6 @@ TValue kwrap(klisp_State *K, TValue underlying)
klispC_link(K, (GCObject *) new_app, K_TAPPLICATIVE, 0);
/* applicative specific fields */
- new_app->name = KNIL;
- new_app->si = KNIL;
new_app->underlying = underlying;
return gc2app(new_app);
}
diff --git a/src/kcontinuation.c b/src/kcontinuation.c
@@ -25,8 +25,6 @@ TValue kmake_continuation(klisp_State *K, TValue parent, klisp_Cfunc fn,
/* continuation specific fields */
new_cont->mark = KFALSE;
- new_cont->name = KNIL;
- new_cont->si = KNIL;
new_cont->parent = parent;
new_cont->fn = fn;
new_cont->extra_size = xcount;
diff --git a/src/kencapsulation.c b/src/kencapsulation.c
@@ -20,8 +20,6 @@ TValue kmake_encapsulation(klisp_State *K, TValue key, TValue val)
klispC_link(K, (GCObject *) new_enc, K_TENCAPSULATION, 0);
/* encapsulation specific fields */
- new_enc->name = KNIL;
- new_enc->si = KNIL;
new_enc->key = key;
new_enc->value = val;
diff --git a/src/kgc.c b/src/kgc.c
@@ -240,7 +240,6 @@ static int32_t propagatemark (klisp_State *K) {
markvalue(K, p->mark);
markvalue(K, p->car);
markvalue(K, p->cdr);
- markvalue(K, p->si);
return sizeof(Pair);
}
case K_TSYMBOL: {
@@ -266,45 +265,33 @@ static int32_t propagatemark (klisp_State *K) {
case K_TCONTINUATION: {
Continuation *c = cast(Continuation *, o);
markvalue(K, c->mark);
- markvalue(K, c->name);
- markvalue(K, c->si);
markvalue(K, c->parent);
markvaluearray(K, c->extra, c->extra_size);
return sizeof(Continuation) + sizeof(TValue) * c->extra_size;
}
case K_TOPERATIVE: {
Operative *op = cast(Operative *, o);
- markvalue(K, op->name);
- markvalue(K, op->si);
markvaluearray(K, op->extra, op->extra_size);
return sizeof(Operative) + sizeof(TValue) * op->extra_size;
}
case K_TAPPLICATIVE: {
Applicative *a = cast(Applicative *, o);
- markvalue(K, a->name);
- markvalue(K, a->si);
markvalue(K, a->underlying);
return sizeof(Applicative);
}
case K_TENCAPSULATION: {
Encapsulation *e = cast(Encapsulation *, o);
- markvalue(K, e->name);
- markvalue(K, e->si);
markvalue(K, e->key);
markvalue(K, e->value);
return sizeof(Encapsulation);
}
case K_TPROMISE: {
Promise *p = cast(Promise *, o);
- markvalue(K, p->name);
- markvalue(K, p->si);
markvalue(K, p->node);
return sizeof(Promise);
}
case K_TPORT: {
Port *p = cast(Port *, o);
- markvalue(K, p->name);
- markvalue(K, p->si);
markvalue(K, p->filename);
return sizeof(Port);
}
diff --git a/src/kobject.h b/src/kobject.h
@@ -323,7 +323,6 @@ typedef struct __attribute__ ((__packed__)) {
TValue mark; /* for cycle/sharing aware algorithms */
TValue car;
TValue cdr;
- TValue si; /* source code info (either () or (filename line col) */
} Pair;
typedef struct __attribute__ ((__packed__)) {
@@ -350,8 +349,6 @@ typedef struct __attribute__ ((__packed__)) {
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
TValue mark; /* for guarding continuation */
- TValue name; /* cont name/type */
- TValue si; /* source code info (either () or (filename line col) */
TValue parent; /* may be () for root continuation */
void *fn; /* the function that does the work */
int32_t extra_size;
@@ -360,8 +357,6 @@ typedef struct __attribute__ ((__packed__)) {
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
- TValue name;
- TValue si; /* source code info (either () or (filename line col) */
void *fn; /* the function that does the work */
int32_t extra_size;
TValue extra[];
@@ -369,23 +364,17 @@ typedef struct __attribute__ ((__packed__)) {
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
- TValue name;
- TValue si; /* source code info (either () or (filename line col) */
TValue underlying; /* underlying operative/applicative */
} Applicative;
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
- TValue name;
- TValue si; /* source code info (either () or (filename line col) */
TValue key; /* unique pair identifying this type of encapsulation */
TValue value; /* encapsulated object */
} Encapsulation;
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
- TValue name;
- TValue si; /* source code info (either () or (filename line col) */
TValue node; /* pair (exp . maybe-env) */
/* if maybe-env is nil, then the promise has determined exp,
otherwise the promise should eval exp in maybe-env when forced
@@ -397,8 +386,6 @@ typedef struct __attribute__ ((__packed__)) {
/* input/output direction and open/close status are in kflags */
typedef struct __attribute__ ((__packed__)) {
CommonHeader;
- TValue name;
- TValue si; /* source code info (either () or (filename line col) */
TValue filename;
FILE *file;
} Port;
@@ -465,6 +452,8 @@ typedef struct __attribute__ ((__packed__)) {
char b[]; // buffer
} String;
+/* MAYBE: mark fields could be replaced by a hashtable or a bit + a hashtable */
+
/*
** Common header for markable objects
*/
diff --git a/src/koperative.c b/src/koperative.c
@@ -24,8 +24,6 @@ TValue kmake_operative(klisp_State *K, klisp_Ofunc fn, int32_t xcount, ...)
klispC_link(K, (GCObject *) new_op, K_TOPERATIVE, 0);
/* operative specific fields */
- new_op->name = KNIL;
- new_op->si = KNIL;
new_op->fn = fn;
new_op->extra_size = xcount;
diff --git a/src/kpair.c b/src/kpair.c
@@ -21,7 +21,6 @@ TValue kcons_g(klisp_State *K, bool m, TValue car, TValue cdr)
klispC_link(K, (GCObject *) new_pair, K_TPAIR, (m? 0 : K_FLAG_IMMUTABLE));
/* pair specific fields */
- new_pair->si = KNIL;
new_pair->mark = KFALSE;
new_pair->car = car;
new_pair->cdr = cdr;
diff --git a/src/kpair.h b/src/kpair.h
@@ -62,8 +62,9 @@ TValue klist_g(klisp_State *K, bool m, int32_t n, ...);
#define klist(K_, n_, ...) (klist_g(K_, true, n_, __VA_ARGS__))
#define kimm_list(K_, n_, ...) (klist_g(K_, false, n_, __VA_ARGS__))
-#define kget_source_info(p_) (tv2pair(p_)->si)
-#define kset_source_info(p_, si_) (kget_source_info(p_) = (si_))
+/* TODO use a source info table */
+#define kget_source_info(p_) (UNUSED(p_), KNIL)
+#define kset_source_info(K_, p_, si_) (UNUSED(K_), UNUSED(p_), UNUSED(si_))
bool kpairp(TValue obj);
diff --git a/src/kport.c b/src/kport.c
@@ -48,8 +48,6 @@ TValue kmake_std_port(klisp_State *K, TValue filename, bool writep,
writep? K_FLAG_OUTPUT_PORT : K_FLAG_INPUT_PORT);
/* port specific fields */
- new_port->name = name;
- new_port->si = si;
new_port->filename = filename;
new_port->file = file;
diff --git a/src/kpromise.c b/src/kpromise.c
@@ -20,8 +20,6 @@ TValue kmake_promise(klisp_State *K, TValue exp, TValue maybe_env)
klispC_link(K, (GCObject *) new_prom, K_TPROMISE, 0);
/* promise specific fields */
- new_prom->name = KNIL;
- new_prom->si = KNIL;
new_prom->node = KNIL; /* temp in case of GC */
krooted_tvs_push(K, gc2prom(new_prom));
new_prom->node = kcons(K, exp, maybe_env);
diff --git a/src/kread.c b/src/kread.c
@@ -175,7 +175,7 @@ TValue kread_fsm(klisp_State *K)
** in np (later it will be replace by the source info
** of the car of the list
*/
- kset_source_info(np, ktok_get_source_info(K));
+ kset_source_info(K, np, ktok_get_source_info(K));
/* update the shared def to point to the new list */
/* NOTE: this is necessary for self referencing lists */
@@ -391,7 +391,7 @@ TValue kread_fsm(klisp_State *K)
/* GC: the way things are done here fp is rooted at all
times */
TValue fp_old_si = kget_source_info(fp);
- kset_source_info(fp, obj_si);
+ kset_source_info(K, fp, obj_si);
kset_car(fp, obj);
/* continue reading objects of list */
@@ -411,7 +411,7 @@ TValue kread_fsm(klisp_State *K)
/* GC: np is rooted by push_data */
TValue np = kcons_g(K, K->read_mconsp, obj, KNIL);
krooted_tvs_push(K, np);
- kset_source_info(np, obj_si);
+ kset_source_info(K, np, obj_si);
kset_cdr(get_data(K), np);
/* replace last pair of the (still incomplete) read next obj */
pop_data(K);