unsigned vla_decl_space(decl *d) { const unsigned pws = platform_word_size(); type *t; unsigned sz; if(STORE_IS_TYPEDEF(d->store)) sz = 0; /* just the sizes */ else if(type_is_vla(d->ref, VLA_ANY_DIMENSION)) sz = pws * 2; /* T *ptr; void *orig_sp; */ else sz = pws; /* T *ptr; - no stack res, no orig_sp */ for(t = d->ref; t; t = type_next(t)) if(type_is_vla(t, VLA_TOP_DIMENSION)) sz += pws; return sz; }
static int calc_ptr_step(type *t) { type *tnext; /* we are calculating the sizeof *t */ if(type_is_primitive(type_is_ptr(t), type_void)) return type_primitive_size(type_void); if(type_is_primitive(t, type_unknown)) return 1; tnext = type_next(t); if(type_is_vla(tnext, VLA_ANY_DIMENSION)) return -1; return type_size(tnext, NULL); }