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;
|
if (TYPE (old) == TBROKEN_HEART) return g_cells[old].car;
|
||||||
SCM new = g_free++;
|
SCM new = g_free++;
|
||||||
#if 0
|
|
||||||
g_news[new] = g_cells[old];
|
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)
|
if (NTYPE (new) == TVECTOR)
|
||||||
{
|
{
|
||||||
NVECTOR (new) = g_free;
|
NVECTOR (new) = g_free;
|
||||||
for (int i=0; i<LENGTH (old); i++)
|
for (int i=0; i<LENGTH (old); i++)
|
||||||
#if 0
|
#if __GNUC__
|
||||||
//__GNUC__
|
|
||||||
g_news[g_free++] = g_cells[VECTOR (old)+i];
|
g_news[g_free++] = g_cells[VECTOR (old)+i];
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
//eputs ("gc_copy\n");
|
SCM b = VECTOR (old)+i;
|
||||||
y = g_free;
|
g_news[g_free++] = g_cells[b];
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,6 +551,7 @@
|
||||||
(i386:value->accu size))))))))
|
(i386:value->accu size))))))))
|
||||||
|
|
||||||
;; c+p expr->arg
|
;; c+p expr->arg
|
||||||
|
;; g_cells[0]
|
||||||
((array-ref (p-expr (fixed ,index)) (p-expr (ident ,array)))
|
((array-ref (p-expr (fixed ,index)) (p-expr (ident ,array)))
|
||||||
(let* ((index (cstring->number index))
|
(let* ((index (cstring->number index))
|
||||||
(type (ident->type info array))
|
(type (ident->type info array))
|
||||||
|
@ -561,11 +562,13 @@
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(append
|
(append
|
||||||
(i386:value->accu (* size index))
|
(i386:value->accu (* size index))
|
||||||
(if (eq? size 1)
|
(case size
|
||||||
(i386:byte-base-mem->accu)
|
((1) (i386:byte-base-mem->accu))
|
||||||
(i386:base-mem->accu)))))))))
|
((4) (i386:base-mem->accu))
|
||||||
|
(else (i386:accu+base))))))))))
|
||||||
|
|
||||||
;; c+p expr->arg
|
;; c+p expr->arg
|
||||||
|
;; g_cells[i]
|
||||||
((array-ref (p-expr (ident ,index)) (p-expr (ident ,array)))
|
((array-ref (p-expr (ident ,index)) (p-expr (ident ,array)))
|
||||||
(let* ((type (ident->type info array))
|
(let* ((type (ident->type info array))
|
||||||
(size (type->size info type)))
|
(size (type->size info type)))
|
||||||
|
@ -575,15 +578,16 @@
|
||||||
(append
|
(append
|
||||||
(i386:base->accu)
|
(i386:base->accu)
|
||||||
(if (< size 4) '()
|
(if (< size 4) '()
|
||||||
(append ;; FIXME
|
(append
|
||||||
(i386:accu+accu)
|
(i386:accu+accu)
|
||||||
(if (= size 12) (i386:accu+base)
|
(if (= size 12) (i386:accu+base) '())
|
||||||
'()))))))
|
(i386:accu-shl 2))))))
|
||||||
((ident->base info) array)
|
((ident->base info) array)
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(if (eq? size 1)
|
(case size
|
||||||
(i386:byte-base-mem->accu)
|
((1) (i386:byte-base-mem->accu))
|
||||||
(i386:base-mem->accu))))))))
|
((4) (i386:base-mem->accu))
|
||||||
|
(else (i386:accu+base)))))))))
|
||||||
|
|
||||||
;; f.field
|
;; f.field
|
||||||
((d-sel (ident ,field) (p-expr (ident ,array)))
|
((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
|
int
|
||||||
struct_test ()
|
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].type = TNUMBER;
|
||||||
|
g_cells[0].car = 0;
|
||||||
|
g_cells[0].cdr = 0;
|
||||||
g_cells[1].type = TNUMBER;
|
g_cells[1].type = TNUMBER;
|
||||||
|
g_cells[1].car = 0;
|
||||||
|
g_cells[1].cdr = 0;
|
||||||
|
|
||||||
puts ("t: TYPE (0) != TYPE (1)\n");
|
puts ("t: TYPE (0) != TYPE (1)\n");
|
||||||
if (TYPE (0) == TYPE (1)) goto ok;
|
if (TYPE (0) == TYPE (1)) goto ok;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
48
vector.c
48
vector.c
|
@ -25,21 +25,15 @@ make_vector (SCM n)
|
||||||
VALUE (tmp_num) = TVECTOR;
|
VALUE (tmp_num) = TVECTOR;
|
||||||
SCM v = alloc (k);
|
SCM v = alloc (k);
|
||||||
SCM x = make_cell_ (tmp_num, k, v);
|
SCM x = make_cell_ (tmp_num, k, v);
|
||||||
#if 0
|
#if __GNUC__
|
||||||
//__GNUC__
|
|
||||||
for (int i=0; i<k; i++) g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
|
for (int i=0; i<k; i++) g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
|
||||||
#else
|
#else
|
||||||
for (int i=0; i<k; i++)
|
for (int i=v; i<k+v; i++)
|
||||||
{
|
{
|
||||||
SCM y = v+i;
|
SCM t = vector_entry (cell_unspecified);
|
||||||
SCM z = vector_entry (cell_unspecified);
|
struct scm s = g_cells[t];
|
||||||
//g_cells[y] = g_cells[z];
|
s = g_cells[t];
|
||||||
SCM zz = TYPE (z);
|
g_cells[i] = s;
|
||||||
TYPE (y) = zz;
|
|
||||||
zz = CAR (z);
|
|
||||||
CAR (y) = zz;
|
|
||||||
zz = CDR (z);
|
|
||||||
CDR (y) = zz;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return x;
|
return x;
|
||||||
|
@ -75,19 +69,12 @@ vector_set_x (SCM x, SCM i, SCM e)
|
||||||
{
|
{
|
||||||
assert (TYPE (x) == TVECTOR);
|
assert (TYPE (x) == TVECTOR);
|
||||||
assert (VALUE (i) < LENGTH (x));
|
assert (VALUE (i) < LENGTH (x));
|
||||||
#if 0
|
#if __GNUC__
|
||||||
//__GNUC__
|
|
||||||
g_cells[VECTOR (x)+VALUE (i)] = g_cells[vector_entry (e)];
|
g_cells[VECTOR (x)+VALUE (i)] = g_cells[vector_entry (e)];
|
||||||
#else
|
#else
|
||||||
SCM y = VECTOR (x)+VALUE (i);
|
SCM a = VECTOR (x)+VALUE (i);
|
||||||
SCM z = vector_entry (e);
|
SCM b = vector_entry (e);
|
||||||
//g_cells[y] = g_cells[z];
|
g_cells[a] = g_cells[b];
|
||||||
SCM zz = TYPE (z);
|
|
||||||
TYPE (y) = zz;
|
|
||||||
zz = CAR (z);
|
|
||||||
CAR (y) = zz;
|
|
||||||
zz = CDR (z);
|
|
||||||
CDR (y) = zz;
|
|
||||||
#endif
|
#endif
|
||||||
return cell_unspecified;
|
return cell_unspecified;
|
||||||
}
|
}
|
||||||
|
@ -100,20 +87,11 @@ list_to_vector (SCM x)
|
||||||
SCM p = VECTOR (v);
|
SCM p = VECTOR (v);
|
||||||
while (x != cell_nil)
|
while (x != cell_nil)
|
||||||
{
|
{
|
||||||
#if 0
|
#if __GNUC__
|
||||||
//__GNUC__
|
|
||||||
g_cells[p++] = g_cells[vector_entry (car (x))];
|
g_cells[p++] = g_cells[vector_entry (car (x))];
|
||||||
#else
|
#else
|
||||||
SCM y = p;
|
SCM b = vector_entry (car (x));
|
||||||
SCM z = vector_entry (car (x));
|
g_cells[p++] = g_cells[b];
|
||||||
//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
|
#endif
|
||||||
x = cdr (x);
|
x = cdr (x);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue