diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 3d5db01..f7b7c47 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -7,3 +7,9 @@ quote %GL.Sphere{segments_u: 100}
%GL.Sphere{segments_u: 100 + 1}
%GL.Sphere{segments_u: (Uw) (100 + 1)}
a = (U8) { 1, 2 }
+quote a[0]
+a[0]
+a = (U8) { 1, 2 }
+a[0]
+a = (U8) { 1, 2 }
+a[0]
diff --git a/libc3/array.c b/libc3/array.c
index af7533d..de87424 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -10,7 +10,7 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
-#include <assert.h>
+#include "assert.h"
#include <stdlib.h>
#include <string.h>
#include <err.h>
@@ -128,21 +128,47 @@ s_array * array_data_set (s_array *a, const uw *address,
return NULL;
}
-s_tag * array_data_tag (s_tag *a, const s_tag *address, s_tag *dest)
+s_tag * array_data_tag (const s_tag *a, const s_tag *address,
+ s_tag *dest)
{
void *a_data;
f_init_copy init_copy;
void *tmp_data;
s_tag tmp = {0};
- assert(a->type == TAG_ARRAY);
- assert(address->type == TAG_ARRAY);
+ if (a->type != TAG_ARRAY) {
+ err_puts("array_data_tag: not an array");
+ assert(! "array_data_tag: not an array");
+ return NULL;
+ }
+ if (address->type != TAG_ARRAY) {
+ err_puts("array_data_tag: address: not an array");
+ assert(! "array_data_tag: address: not an array");
+ return NULL;
+ }
+ if (address->data.array.dimension != 1) {
+ err_puts("array_data_tag: address dimension != 1");
+ assert(! "array_data_tag: address dimension != 1");
+ return NULL;
+ }
+ if (address->data.array.dimensions[0].count !=
+ a->data.array.dimension) {
+ err_write_1("array_data_tag: address dimension mismatch: ");
+ err_inspect_uw(&address->data.array.dimensions[0].count);
+ err_write_1(" != ");
+ err_inspect_uw(&a->data.array.dimension);
+ err_write_1("\n");
+ assert(! "array_data_tag: address dimension mismatch");
+ return NULL;
+ }
a_data = array_data(&a->data.array, address->data.array.data);
if (a_data) {
if (! sym_to_init_copy(a->data.array.type, &init_copy) ||
! sym_to_tag_type(a->data.array.type, &tmp.type) ||
! tag_to_pointer(&tmp, a->data.array.type, &tmp_data) ||
- ! init_copy(tmp_data, a_data))
+ (init_copy &&
+ ! init_copy(tmp_data, a_data)))
return NULL;
+ *dest = tmp;
return dest;
}
return NULL;
diff --git a/libc3/array.h b/libc3/array.h
index affc415..f6f8fab 100644
--- a/libc3/array.h
+++ b/libc3/array.h
@@ -26,7 +26,7 @@ s_array * array_init_copy (s_array *a, const s_array *src);
/* Observers */
s_str * array_inspect (const s_array *array, s_str *dest);
void * array_data (const s_array *a, const uw *address);
-s_tag * array_data_tag (s_tag *a, const s_tag *address,
+s_tag * array_data_tag (const s_tag *a, const s_tag *address,
s_tag *dest);
/* Operators */
diff --git a/libc3/tag.c b/libc3/tag.c
index 0357cea..73c2c09 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -211,7 +211,7 @@ void tag_clean (s_tag *tag)
}
}
-s_tag * tag_brackets (s_tag *tag, const s_tag *address,
+s_tag * tag_brackets (const s_tag *tag, const s_tag *address,
s_tag *dest)
{
assert(tag);
diff --git a/libc3/tag.h b/libc3/tag.h
index 55ff36d..33304d3 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -20,7 +20,6 @@
#define LIBC3_TAG_H
#include <stdarg.h>
-#include <stdio.h>
#include "tag_init.h"
#include "tag_type.h"
@@ -76,7 +75,8 @@ bool * tag_and (const s_tag *a, const s_tag *b, bool *dest);
s_tag * tag_band (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_bnot (const s_tag *tag, s_tag *dest);
s_tag * tag_bor (const s_tag *a, const s_tag *b, s_tag *dest);
-s_tag * tag_brackets (s_tag *tag, const s_tag *address, s_tag *dest);
+s_tag * tag_brackets (const s_tag *tag, const s_tag *address,
+ s_tag *dest);
s_tag * tag_bxor (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest);
bool * tag_lt (const s_tag *a, const s_tag *b, bool *dest);