@@ -25,18 +25,28 @@
26// Closures
26// Closures
27typedef enum {
27typedef 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,
29 CT_BITS8, CT_BITS16, CT_BITS32, CT_BITS64, CT_UNIT, CT_PTR, CT_REF,
29 CT_BITS8, CT_BITS16, CT_BITS32, CT_BITS64, CT_UNIT, CT_PTR, CT_REF,
30 CT_FWD, CT_MANAGEDPTR, CT_RAWDATA, CT_CDATA
30 CT_FWD, CT_MANAGEDPTR, CT_RAWDATA, CT_CDATA
31} ClosureType;
31} ClosureType;
33typedef struct Closure *VAL;
33typedef struct Closure *VAL;
35+// A constructor, consisting of a tag, an arity (16 bits each of the
36+// tag_arity field) and arguments
35typedef struct {
37typedef struct {
36 uint32_t tag_arity;
38 uint32_t tag_arity;
37 VAL args[];
39 VAL args[];
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)
40typedef struct {
50typedef struct {
42 size_t offset;
52 size_t offset;
@@ -62,6 +72,7 @@ typedef struct Closure {
62 uint32_t ty;
72 uint32_t ty;
67 String str;
78 String str;
@@ -312,6 +323,11 @@ void idris_free(void* ptr, size_t size);
313#define NULL_CON(x) nullary_cons[x]
324#define NULL_CON(x) nullary_cons[x]
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;
315int idris_errno(void);
331int idris_errno(void);
316char* idris_showerror(int err);
332char* idris_showerror(int err);
@@ -407,6 +423,11 @@ VAL idris_newRef(VAL x);
407void idris_writeRef(VAL ref, VAL x);
423void idris_writeRef(VAL ref, VAL x);
408VAL idris_readRef(VAL ref);
424VAL idris_readRef(VAL ref);
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);
410// system infox
431// system infox
411// used indices:
432// used indices:
412// 0 returns backend
433// 0 returns backend