mescc: Fix by value assignment from array-of struct entry.
[mes.git] / module / language / c99 / compiler.mes
index 02c6e28d784dc2edb20d486df6d97f10e1bdf3f1..3da8fc9acc8c465b4b34e9ac0bcffcb2e8407621 100644 (file)
                                  (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))
                         (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)))
                                               (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)))