static void ensure_lvar_init(Node *node) { assert(node->type == AST_LVAR); if (node->lvarinit) { emit_zero_filler(node->loff, node->loff + node->ctype->size); emit_decl_init(node->lvarinit, node->loff); } node->lvarinit = NULL; }
static void emit_decl(Node *node) { SAVE; if (!node->declinit) return; emit_zero_filler(node->declvar->loff, node->declvar->loff + node->declvar->ctype->size); emit_decl_init(node->declinit, node->declvar->loff); }
static void emit_fill_holes(Vector *inits, int off, int totalsize) { // If at least one of the fields in a variable are initialized, // unspecified fields has to be initialized with 0. int len = vec_len(inits); Node **buf = malloc(len * sizeof(Node *)); for (int i = 0; i < len; i++) buf[i] = vec_get(inits, i); qsort(buf, len, sizeof(Node *), cmpinit); int lastend = 0; for (int i = 0; i < len; i++) { Node *node = buf[i]; if (lastend < node->initoff) emit_zero_filler(lastend + off, node->initoff + off); lastend = node->initoff + node->totype->size; } emit_zero_filler(lastend + off, totalsize + off); }