mescc: Fix by value assignment from array-of struct entry.
* module/language/c99/compiler.mes (expr->accu): Fix by value assignment from array-of struct entry. * scaffold/t.c (struct_test): Test it. * vector.c (make_vector, list_to_vector, vector_to_list): Use it; remove workarounds. * gc.c (gc_copy): Likewise.
This commit is contained in:
parent
2209b5728d
commit
e9ac52dfda
28
gc.c
28
gc.c
|
@ -70,39 +70,17 @@ gc_copy (SCM old) ///((internal))
|
|||
{
|
||||
if (TYPE (old) == TBROKEN_HEART) return g_cells[old].car;
|
||||
SCM new = g_free++;
|
||||
#if 0
|
||||
g_news[new] = g_cells[old];
|
||||
#else
|
||||
SCM y = new;
|
||||
SCM z = old;
|
||||
SCM zz = TYPE (z);
|
||||
NTYPE (y) = zz;
|
||||
zz = CAR (z);
|
||||
NCAR (y) = zz;
|
||||
zz = CDR (z);
|
||||
NCDR (y) = zz;
|
||||
#endif
|
||||
if (NTYPE (new) == TVECTOR)
|
||||
{
|
||||
NVECTOR (new) = g_free;
|
||||
for (int i=0; i<LENGTH (old); i++)
|
||||
#if 0
|
||||
//__GNUC__
|
||||
#if __GNUC__
|
||||
g_news[g_free++] = g_cells[VECTOR (old)+i];
|
||||
#else
|
||||
{
|
||||
//eputs ("gc_copy\n");
|
||||
y = g_free;
|
||||
g_free++;
|
||||
z = VECTOR (old);
|
||||
z = z + i;
|
||||
//z = g_cells[z];
|
||||
zz = TYPE (z);
|
||||
NTYPE (y) = zz;
|
||||
zz = CAR (z);
|
||||
NCAR (y) = zz;
|
||||
zz = CDR (z);
|
||||
NCDR (y) = zz;
|
||||
SCM b = VECTOR (old)+i;
|
||||
g_news[g_free++] = g_cells[b];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -551,6 +551,7 @@
|
|||
(i386:value->accu size))))))))
|
||||
|
||||
;; c+p expr->arg
|
||||
;; g_cells[0]
|
||||
((array-ref (p-expr (fixed ,index)) (p-expr (ident ,array)))
|
||||
(let* ((index (cstring->number index))
|
||||
(type (ident->type info array))
|
||||
|
@ -561,11 +562,13 @@
|
|||
(list (lambda (f g ta t d)
|
||||
(append
|
||||
(i386:value->accu (* size index))
|
||||
(if (eq? size 1)
|
||||
(i386:byte-base-mem->accu)
|
||||
(i386:base-mem->accu)))))))))
|
||||
(case size
|
||||
((1) (i386:byte-base-mem->accu))
|
||||
((4) (i386:base-mem->accu))
|
||||
(else (i386:accu+base))))))))))
|
||||
|
||||
;; c+p expr->arg
|
||||
;; g_cells[i]
|
||||
((array-ref (p-expr (ident ,index)) (p-expr (ident ,array)))
|
||||
(let* ((type (ident->type info array))
|
||||
(size (type->size info type)))
|
||||
|
@ -575,15 +578,16 @@
|
|||
(append
|
||||
(i386:base->accu)
|
||||
(if (< size 4) '()
|
||||
(append ;; FIXME
|
||||
(i386:accu+accu)
|
||||
(if (= size 12) (i386:accu+base)
|
||||
'()))))))
|
||||
(append
|
||||
(i386:accu+accu)
|
||||
(if (= size 12) (i386:accu+base) '())
|
||||
(i386:accu-shl 2))))))
|
||||
((ident->base info) array)
|
||||
(list (lambda (f g ta t d)
|
||||
(if (eq? size 1)
|
||||
(i386:byte-base-mem->accu)
|
||||
(i386:base-mem->accu))))))))
|
||||
(case size
|
||||
((1) (i386:byte-base-mem->accu))
|
||||
((4) (i386:base-mem->accu))
|
||||
(else (i386:accu+base)))))))))
|
||||
|
||||
;; f.field
|
||||
((d-sel (ident ,field) (p-expr (ident ,array)))
|
||||
|
|
25
scaffold/t.c
25
scaffold/t.c
|
@ -290,8 +290,33 @@ make_tmps_test (struct scm* cells)
|
|||
int
|
||||
struct_test ()
|
||||
{
|
||||
puts ("t: g_cells[0] = g_cells[1]\n");
|
||||
TYPE (1) = 1;
|
||||
CAR (1) = 2;
|
||||
CDR (1) = 3;
|
||||
g_cells[0] = g_cells[1];
|
||||
if (TYPE (0) != 1) return 1;
|
||||
if (CAR (0) != 2) return 2;
|
||||
if (CDR (0) != 3) return 3;
|
||||
|
||||
puts ("t: g_cells[i] = g_cells[j]\n");
|
||||
int i = 0;
|
||||
int j = 1;
|
||||
TYPE (1) = 4;
|
||||
CAR (1) = 5;
|
||||
CDR (1) = 6;
|
||||
g_cells[i] = g_cells[j];
|
||||
if (TYPE (0) != 4) return 1;
|
||||
if (CAR (0) != 5) return 2;
|
||||
if (CDR (0) != 6) return 3;
|
||||
|
||||
g_cells[0].type = TNUMBER;
|
||||
g_cells[0].car = 0;
|
||||
g_cells[0].cdr = 0;
|
||||
g_cells[1].type = TNUMBER;
|
||||
g_cells[1].car = 0;
|
||||
g_cells[1].cdr = 0;
|
||||
|
||||
puts ("t: TYPE (0) != TYPE (1)\n");
|
||||
if (TYPE (0) == TYPE (1)) goto ok;
|
||||
return 1;
|
||||
|
|
48
vector.c
48
vector.c
|
@ -25,21 +25,15 @@ make_vector (SCM n)
|
|||
VALUE (tmp_num) = TVECTOR;
|
||||
SCM v = alloc (k);
|
||||
SCM x = make_cell_ (tmp_num, k, v);
|
||||
#if 0
|
||||
//__GNUC__
|
||||
#if __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++)
|
||||
for (int i=v; i<k+v; 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;
|
||||
SCM t = vector_entry (cell_unspecified);
|
||||
struct scm s = g_cells[t];
|
||||
s = g_cells[t];
|
||||
g_cells[i] = s;
|
||||
}
|
||||
#endif
|
||||
return x;
|
||||
|
@ -75,19 +69,12 @@ vector_set_x (SCM x, SCM i, SCM e)
|
|||
{
|
||||
assert (TYPE (x) == TVECTOR);
|
||||
assert (VALUE (i) < LENGTH (x));
|
||||
#if 0
|
||||
//__GNUC__
|
||||
#if __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;
|
||||
SCM a = VECTOR (x)+VALUE (i);
|
||||
SCM b = vector_entry (e);
|
||||
g_cells[a] = g_cells[b];
|
||||
#endif
|
||||
return cell_unspecified;
|
||||
}
|
||||
|
@ -100,20 +87,11 @@ list_to_vector (SCM x)
|
|||
SCM p = VECTOR (v);
|
||||
while (x != cell_nil)
|
||||
{
|
||||
#if 0
|
||||
//__GNUC__
|
||||
#if __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++;
|
||||
SCM b = vector_entry (car (x));
|
||||
g_cells[p++] = g_cells[b];
|
||||
#endif
|
||||
x = cdr (x);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue