mescc: Support expression as lhs array index.
* module/language/c99/compiler.mes (expr->accu): Treat array index as expression. * scaffold/t.c (struct_test): Test it. * gc.c (gc_copy)[!__GNUC__]: Remove branch. * vector.c (list_to_vector)[!__GNUC__]: Likewise.
This commit is contained in:
parent
71da0bfb78
commit
c4fe8d8239
7
gc.c
7
gc.c
|
@ -77,14 +77,7 @@ gc_copy (SCM old) ///((internal))
|
||||||
{
|
{
|
||||||
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 __GNUC__
|
|
||||||
g_news[g_free++] = g_cells[VECTOR (old)+i];
|
g_news[g_free++] = g_cells[VECTOR (old)+i];
|
||||||
#else
|
|
||||||
{
|
|
||||||
SCM b = VECTOR (old)+i;
|
|
||||||
g_news[g_free++] = g_cells[b];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
TYPE (old) = TBROKEN_HEART;
|
TYPE (old) = TBROKEN_HEART;
|
||||||
CAR (old) = new;
|
CAR (old) = new;
|
||||||
|
|
|
@ -457,43 +457,30 @@
|
||||||
(i386:value->accu size))))))))
|
(i386:value->accu size))))))))
|
||||||
|
|
||||||
;; c+p expr->arg
|
;; c+p expr->arg
|
||||||
;; g_cells[0]
|
;; g_cells[<expr>]
|
||||||
((array-ref (p-expr (fixed ,index)) (p-expr (ident ,array)))
|
((array-ref ,index (p-expr (ident ,array)))
|
||||||
(let* ((index (cstring->number index))
|
(let* ((info ((expr->accu info) index))
|
||||||
(type (ident->type info array))
|
(type (ident->type info array))
|
||||||
(size (type->size info type)))
|
(size (type->size info type)))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append (.text info)
|
||||||
((ident->base info) array)
|
;; immediate: (i386:value->accu (* size index))
|
||||||
(list (lambda (f g ta t d)
|
;; * size cells: * length * 4 = * 12
|
||||||
(append
|
(list (lambda (f g ta t d)
|
||||||
(i386:value->accu (* size index))
|
(append
|
||||||
(case size
|
(i386:accu->base)
|
||||||
((1) (i386:byte-base-mem->accu))
|
(if (eq? size 1) '()
|
||||||
((4) (i386:base-mem->accu))
|
(append
|
||||||
(else (i386:accu+base))))))))))
|
(if (> size 4) (i386:accu+accu) '())
|
||||||
|
(if (> size 8) (i386:accu+base) '())
|
||||||
;; c+p expr->arg
|
(i386:accu-shl 2))))))
|
||||||
;; g_cells[i]
|
((ident->base info) array)
|
||||||
((array-ref (p-expr (ident ,index)) (p-expr (ident ,array)))
|
(list (lambda (f g ta t d)
|
||||||
(let* ((type (ident->type info array))
|
(append
|
||||||
(size (type->size info type)))
|
(case size
|
||||||
(clone info #:text (append text
|
((1) (i386:byte-base-mem->accu))
|
||||||
((ident->base info) index)
|
((4) (i386:base-mem->accu))
|
||||||
(list (lambda (f g ta t d)
|
(else (i386:accu+base))))))))))
|
||||||
(append
|
|
||||||
(i386:base->accu)
|
|
||||||
(if (< size 4) '()
|
|
||||||
(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)
|
|
||||||
(case size
|
|
||||||
((1) (i386:byte-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)))
|
||||||
|
|
|
@ -294,7 +294,7 @@ struct_test ()
|
||||||
TYPE (1) = 1;
|
TYPE (1) = 1;
|
||||||
CAR (1) = 2;
|
CAR (1) = 2;
|
||||||
CDR (1) = 3;
|
CDR (1) = 3;
|
||||||
g_cells[0] = g_cells[1];
|
g_cells[0] = g_cells[0+1];
|
||||||
if (TYPE (0) != 1) return 1;
|
if (TYPE (0) != 1) return 1;
|
||||||
if (CAR (0) != 2) return 2;
|
if (CAR (0) != 2) return 2;
|
||||||
if (CDR (0) != 3) return 3;
|
if (CDR (0) != 3) return 3;
|
||||||
|
|
5
vector.c
5
vector.c
|
@ -87,12 +87,7 @@ list_to_vector (SCM x)
|
||||||
SCM p = VECTOR (v);
|
SCM p = VECTOR (v);
|
||||||
while (x != cell_nil)
|
while (x != cell_nil)
|
||||||
{
|
{
|
||||||
#if __GNUC__
|
|
||||||
g_cells[p++] = g_cells[vector_entry (car (x))];
|
g_cells[p++] = g_cells[vector_entry (car (x))];
|
||||||
#else
|
|
||||||
SCM b = vector_entry (car (x));
|
|
||||||
g_cells[p++] = g_cells[b];
|
|
||||||
#endif
|
|
||||||
x = cdr (x);
|
x = cdr (x);
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
|
Loading…
Reference in a new issue