@@ -25,18 +25,28 @@
2525
2626// Closures
2727typedef enum {
28− CT_CON, CT_INT, CT_BIGINT, CT_FLOAT, CT_STRING, CT_STROFFSET,
28+ CT_CON, CT_ARRAY, CT_INT, CT_BIGINT, CT_FLOAT, CT_STRING, CT_STROFFSET,
2929 CT_BITS8, CT_BITS16, CT_BITS32, CT_BITS64, CT_UNIT, CT_PTR, CT_REF,
3030 CT_FWD, CT_MANAGEDPTR, CT_RAWDATA, CT_CDATA
3131} ClosureType;
3232
3333typedef struct Closure *VAL;
3434
35+// A constructor, consisting of a tag, an arity (16 bits each of the
36+// tag_arity field) and arguments
3537typedef struct {
3638 uint32_t tag_arity;
3739 VAL args[];
3840} con;
3941
42+// An array; similar to a constructor but with a length, and contents
43+// initialised to NULL (high level Idris programs are responsible for
44+// initialising them properly)
45+typedef struct {
46+ uint32_t length;
47+ VAL content[];
48+} array;
49+
4050typedef struct {
4151 VAL str;
4252 size_t offset;
@@ -62,6 +72,7 @@ typedef struct Closure {
6272 uint32_t ty;
6373 union {
6474 con c;
75+ array arr;
6576 int i;
6677 double f;
6778 String str;
@@ -312,6 +323,11 @@ void idris_free(void* ptr, size_t size);
312323
313324#define NULL_CON(x) nullary_cons[x]
314325
326+#define allocArray(cl, vm, len, o) \
327+ cl = allocate(sizeof(Closure) + sizeof(VAL)*len, o); \
328+ SETTY(cl, CT_ARRAY); \
329+ cl->info.arr.length = len;
330+
315331int idris_errno(void);
316332char* idris_showerror(int err);
317333
@@ -407,6 +423,11 @@ VAL idris_newRef(VAL x);
407423void idris_writeRef(VAL ref, VAL x);
408424VAL idris_readRef(VAL ref);
409425
426+// Support for IOArrays
427+VAL idris_newArray(VM* vm, int size, VAL def);
428+void idris_arraySet(VAL arr, int index, VAL newval);
429+VAL idris_arrayGet(VAL arr, int index);
430+
410431// system infox
411432// used indices:
412433// 0 returns backend