// convert dynamic array to static array
n2 = n1;
n2.op = OINDREG;
- n2.xoffset = offsetof(Array,array);
+ n2.xoffset = Array_array;
n2.type = types[tptr];
gins(AMOVQ, &n2, &n1);
}
if(isptrdarray(n->type) && isptrsarray(nl->type)) {
// conver static array to dynamic array
// it is assumed that the dope is just before the array
- nodconst(&n2, types[tptr], sizeof(Array));
+ nodconst(&n2, types[tptr], sizeof_Array);
gins(ASUBQ, &n2, &n1);
}
gmove(&n1, res);
cgen(nl, &n1);
n1.op = OINDREG;
n1.type = types[TUINT32];
- n1.xoffset = offsetof(Array,nel);
+ n1.xoffset = Array_nel;
gmove(&n1, res);
regfree(&n1);
break;
agen(nl, &n1);
n1.op = OINDREG;
n1.type = types[TUINT32];
- n1.xoffset = offsetof(Array,nel);
+ n1.xoffset = Array_nel;
gmove(&n1, res);
regfree(&n1);
break;
cgen(nl, &n1);
n1.op = OINDREG;
n1.type = types[TUINT32];
- n1.xoffset = offsetof(Array,cap);
+ n1.xoffset = Array_cap;
gmove(&n1, res);
regfree(&n1);
break;
agen(nl, &n1);
n1.op = OINDREG;
n1.type = types[TUINT32];
- n1.xoffset = offsetof(Array,cap);
+ n1.xoffset = Array_cap;
gmove(&n1, res);
regfree(&n1);
break;
n1 = n3;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, nel);
+ n1.xoffset = Array_nel;
nodconst(&n2, types[TUINT64], v);
gins(optoas(OCMP, types[TUINT32]), &n1, &n2);
p1 = gbranch(optoas(OGT, types[TUINT32]), T);
n1 = n3;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, array);
+ n1.xoffset = Array_array;
gmove(&n1, &n3);
} else
if(!debug['B']) {
n1 = n3;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, nel);
+ n1.xoffset = Array_nel;
} else {
nodconst(&n1, types[TUINT64], nl->type->bound);
if(isptrsarray(nl->type))
n1 = n3;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, array);
+ n1.xoffset = Array_array;
gmove(&n1, &n3);
}
agen(nl, &n1);
n2 = n1;
n2.op = OINDREG;
- n2.xoffset = offsetof(Array,array);
+ n2.xoffset = Array_array;
nodconst(&tmp, types[tptr], 0);
gins(optoas(OCMP, types[tptr]), &n2, &tmp);
patch(gbranch(a, types[tptr]), to);
EXTERN Node* throwindex;
EXTERN Node* throwreturn;
+/*
+ * note this is the runtime representation
+ * of the compilers arrays.
+ *
+ * typedef struct
+ * { // must not move anything
+ * uchar array[8]; // pointer to data
+ * uchar nel[4]; // number of elements
+ * uchar cap[4]; // allocated number of elements
+ * } Array;
+ */
+EXTERN int Array_array; // runtime offsetof(Array,array)
+EXTERN int Array_nel; // runtime offsetof(Array,nel)
+EXTERN int Array_cap; // runtime offsetof(Array,cap)
+EXTERN int sizeof_Array; // runtime sizeof(Array)
+
/*
* gen.c
*/
n2 = *reg;
n2.op = OINDREG;
n2.type = types[tptr];
- n2.xoffset = offsetof(Array, nel);
+ n2.xoffset = Array_nel;
} else {
nodconst(&n2, types[TUINT64], l->type->bound);
if(o & OPtrto)
n2 = *reg;
n2.op = OINDREG;
n2.type = types[tptr];
- n2.xoffset = offsetof(Array, array);
+ n2.xoffset = Array_array;
gmove(&n2, reg);
}
n1 = *reg;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, nel);
+ n1.xoffset = Array_nel;
nodconst(&n2, types[TUINT64], v);
gins(optoas(OCMP, types[TUINT32]), &n1, &n2);
p1 = gbranch(optoas(OGT, types[TUINT32]), T);
n1 = *reg;
n1.op = OINDREG;
n1.type = types[tptr];
- n1.xoffset = offsetof(Array, array);
+ n1.xoffset = Array_array;
gmove(&n1, reg);
} else
char s[3]; // variable
};
-/*
- * note this is the runtime representation
- * of the compilers arrays. it is probably
- * insafe to use it this way, but it puts
- * all the changes in one place.
- */
-typedef struct Array Array;
-struct Array
-{ // must not move anything
- uchar array[8]; // pointer to data
- uchar nel[4]; // number of elements
- uchar cap[4]; // allocated number of elements
-};
-
/*
* note this is the runtime representation
* of hashmap iterator. it is probably