mini-mes: Workarounds for vector.c.

* vector.c (make_vector, vector_set_x, list_to_vector)[!__GNUC__]: Avoid
  by value assignment from array-of struct entry.
This commit is contained in:
Jan Nieuwenhuizen 2017-03-25 17:15:07 +01:00
parent 43abef7cf5
commit 6c6df16ca3
3 changed files with 45 additions and 8 deletions

View file

@ -129,6 +129,7 @@ mescc-check: t-check
build-aux/mes-snarf.scm $<
mini-mes: mini-mes.h mini-mes.i mini-mes.environment.i mini-mes.symbols.i
mini-mes: vector.c
mini-mes: mlibc.c mstart.c
mini-mes: GNUmakefile
mini-mes: module/mes/read-0-32.mo
@ -140,6 +141,7 @@ mini-mes: scaffold/mini-mes.c
chmod +x $@
guile-mini-mes: mini-mes.h mini-mes.i mini-mes.environment.i mini-mes.symbols.i
guile-mini-mes: vector.c
guile-mini-mes: module/mes/read-0-32.mo
guile-mini-mes: scaffold/mini-mes.c
guile/mescc.scm $< > $@ || rm -f $@

View file

@ -223,9 +223,7 @@ SCM
make_cell_ (SCM type, SCM car, SCM cdr)
{
SCM x = alloc (1);
#if __GNUC__
assert (TYPE (type) == TNUMBER);
#endif
TYPE (x) = VALUE (type);
if (VALUE (type) == TCHAR || VALUE (type) == TNUMBER) {
if (car) CAR (x) = CAR (car);
@ -271,10 +269,8 @@ SCM
list_of_char_equal_p (SCM a, SCM b) ///((internal))
{
while (a != cell_nil && b != cell_nil && VALUE (car (a)) == VALUE (car (b))) {
#if __GNUC__
assert (TYPE (car (a)) == TCHAR);
assert (TYPE (car (b)) == TCHAR);
#endif
a = cdr (a);
b = cdr (b);
}
@ -512,9 +508,7 @@ SCM
append2 (SCM x, SCM y)
{
if (x == cell_nil) return y;
#if __GNUC__
assert (TYPE (x) == TPAIR);
#endif
return cons (car (x), append2 (cdr (x), y));
}
@ -573,9 +567,7 @@ assq_ref_env (SCM x, SCM a)
SCM
set_car_x (SCM x, SCM e)
{
#if __GNUC__
assert (TYPE (x) == TPAIR);
#endif
CAR (x) = e;
return cell_unspecified;
}

View file

@ -25,7 +25,23 @@ make_vector (SCM n)
VALUE (tmp_num) = TVECTOR;
SCM v = alloc (k);
SCM x = make_cell_ (tmp_num, k, v);
#if 0
//__GNUC__
for (int i=0; i<k; i++) g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
#else
for (int i=0; i<k; i++)
{
SCM y = v+i;
SCM z = vector_entry (cell_unspecified);
//g_cells[y] = g_cells[z];
SCM zz = TYPE (z);
TYPE (y) = zz;
zz = CAR (z);
CAR (y) = zz;
zz = CDR (z);
CDR (y) = zz;
}
#endif
return x;
}
@ -59,7 +75,20 @@ vector_set_x (SCM x, SCM i, SCM e)
{
assert (TYPE (x) == TVECTOR);
assert (VALUE (i) < LENGTH (x));
#if 0
//__GNUC__
g_cells[VECTOR (x)+VALUE (i)] = g_cells[vector_entry (e)];
#else
SCM y = VECTOR (x)+VALUE (i);
SCM z = vector_entry (e);
//g_cells[y] = g_cells[z];
SCM zz = TYPE (z);
TYPE (y) = zz;
zz = CAR (z);
CAR (y) = zz;
zz = CDR (z);
CDR (y) = zz;
#endif
return cell_unspecified;
}
@ -71,7 +100,21 @@ list_to_vector (SCM x)
SCM p = VECTOR (v);
while (x != cell_nil)
{
#if 0
//__GNUC__
g_cells[p++] = g_cells[vector_entry (car (x))];
#else
SCM y = p;
SCM z = vector_entry (car (x));
//g_cells[p++] = g_cells[y];
SCM zz = TYPE (z);
TYPE (y) = zz;
zz = CAR (z);
CAR (y) = zz;
zz = CDR (z);
CDR (y) = zz;
p++;
#endif
x = cdr (x);
}
return v;